Skip to content

Comments

Add a function to show segmented particle images/masks as montage#51

Draft
YichiWang wants to merge 28 commits intoePSIC-DLS:masterfrom
YichiWang:master
Draft

Add a function to show segmented particle images/masks as montage#51
YichiWang wants to merge 28 commits intoePSIC-DLS:masterfrom
YichiWang:master

Conversation

@YichiWang
Copy link

Plus some .pyc cache files and parameter.h5 file were manually chosen to be ignored because they cannot be ignored automatically on my PC.

YichiWang added 16 commits July 3, 2020 16:36
test if local change can be commit to remote github
This reverts commit 6ec6344.
Set default store_im to ture to store segmented particles after call ps.ParticleAnalysis
eg. particles.show(). The displayed particles were normalize_boxing. Next step should enable option to display all particle images without normalize_boxing
This reverts commit 67ddc5b.
Allow segmented particle images output as a list of 2D numpy arrays (without hyperspy metadata).

e.g.
particles = ps.ParticleAnalysis(image, params)
particles.normalize_boxing()
pim_ls = particles.show(output=True)
This reverts commit ed2a093.
This reverts commit 1924709.
e.g.
particle_list.show('mask')
or particle_list.show('Image')
@codecov
Copy link

codecov bot commented Jul 10, 2020

Codecov Report

Merging #51 into master will decrease coverage by 2.66%.
The diff coverage is 12.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #51      +/-   ##
==========================================
- Coverage   80.99%   78.32%   -2.67%     
==========================================
  Files          13       13              
  Lines         784      812      +28     
==========================================
+ Hits          635      636       +1     
- Misses        149      176      +27     
Impacted Files Coverage Δ
ParticleSpy/ptcl_class.py 65.51% <6.89%> (-11.73%) ⬇️
ParticleSpy/ParticleAnalysis.py 93.92% <100.00%> (-0.03%) ⬇️

Allow show segmented particles in a montage with adjustable number of columns.

e.g. particle_list.show(cols=1). Default montage try to display all particles into a square arrangement.
Plus correct particle only image 'p_im'
…lculating image intensity

default is True, i.e. perform background subtraction
Default is perform background subtraction for intensity calculation and for stored particle image.
With particle.store['pad']=None and particle.store['store_im']=True, the saved particle image is masked from original survey image and have save dimension as survey image and saved mask.
Main: Use np.ma.masked_array to mask particle image, so intensity std do not calculate the background area.

Others: 1. all intensity are background subtracted intensity. 2. Background value are saved as property.
@TomSlater
Copy link
Contributor

This has broken things for me. The first particle has an image stored correctly but all others just have zeros.

I'm not sure I follow all of your changes in terms of the background subtraction and the boxing/padding. Are you sure this is all correct?

Few more functions. This is a standalone script and not merged with ParticleSpy yet.

-find boundary pixel in a clock-wise seqeunce
-calculate boundary curvature (signed) use least squre circle fit.
-average boundary curvature by given angle interval so at same direction boundary curvatures of two particle with different size (i.e. different boundary pixels) are comparable.

Normalised boundary curvature by particle's equivalent diameter is not implemented yet.
pad = params.store['pad']

if params.store['bkg_sub']==True:
image.data = image.data - particle.properties['background']['value']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change the image out of the function and so will subtract the value every loop.


if params.store['p_only']==True:
image = image*particle.mask
image.data = image.data*particle.mask
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change the image outside of the function and so results in everything other than the first particle being zero.

p_boxed = image.isig[(box_y_min):(box_y_max),(box_x_min):(box_x_max)]
else:
p_boxed = image.isig[(box_y_min):(box_y_max),(box_x_min):(box_x_max)]
p_boxed = image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why you've changed this. This will store the full image and not just the particle.

@TomSlater TomSlater added this to the v0.5.0 milestone Aug 4, 2020
@TomSlater TomSlater removed this from the v0.5.0 milestone Oct 9, 2020
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.

2 participants