Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic/interactive dark spot counter for CL maps #214

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aidanc151
Copy link

@aidanc151 aidanc151 commented Sep 13, 2024

Performs HyperSpy's find_peaks_log on Signal2D, creates markers using obtained peak positions and then applies markers to signal. Secondly, interactive marker placement and removal is enabled by mouse clicking inside the figure. Either of the functionalities can be used independently. Using the signal area and the number of markers placed, the density of dark spots is calculated, applied to the signal metadata, and also displayed as the figure title.

Description of the change

A few sentences and/or a bulleted list to describe and motivate the change:

  • For automation of the counting of threading dislocations/dark spots in Cathodoluminescence maps
  • Laplacian of Gaussian (LoG) algorithm enables quantitative identification of dark spots
  • Saving of calculated density and markers to metadata for convenience and reproducibility of results

Progress of the PR

  • add writing of LoG parameters to metadata functionality,
  • add tests,
  • add a changelog entry,
  • ready for review.

Minimal example of the bug fix or the new feature

import hyperspy.api as hs
from lumispy.utils.signals import dark_spot_counter

# Interactive functionality does not work well with qt6
%matplotlib widget

panchromatic_map_arr = np.loadtxt('CL_panchromatic_map.txt')
panchromatic_map = hs.signals.Signal2D(panchromatic_map_arr,
                                       axes = [dict(units='µm', scale=5.66563),
                                               dict(units='µm', scale=5.66563)])


dark_spot_counter(panchromatic_map, log_algorithm=True, threshold = 0.005, min_sigma=8, color='blue', r=0.14, click_tolerance=0.1)

CL_panchromatic_map.txt

Performs HyperSpy find_peaks_log() and then applies circle markers to the peak positions on the Signal2D. Secondly, interactive marker placement and removal is enabled by mouse clicking inside the plot. Either of the functionalities can be used independently. Using the signal scale and the number of markers, the density of dark spots is calculated and applied to the signal metadata.
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 9.43396% with 48 lines in your changes missing coverage. Please review.

Project coverage is 91.95%. Comparing base (9c402c0) to head (f820e99).
Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
lumispy/utils/signals.py 9.43% 48 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##              main     #214      +/-   ##
===========================================
- Coverage   100.00%   91.95%   -8.05%     
===========================================
  Files           12       12              
  Lines          556      597      +41     
===========================================
- Hits           556      549       -7     
- Misses           0       48      +48     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jlaehne
Copy link
Contributor

jlaehne commented Oct 21, 2024

For me widget/ipympl is the backend that gives inline display and it I neither see the markers nor can I add/remove some.

@CSSFrancis you have more experience with markers and matplotlib, can you give some guidance to implement the interactive display/adding/removing of markers to work with the different backends?

@CSSFrancis
Copy link

@jlaehne Hopefully I can get around to looking at this today :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants