Skip to content

Commit ccafb01

Browse files
Merge from upstream (#28)
* Update particle_analysis.rst * Add 3D plotting of properties * Add tests for 3D plotting * Update test_plotting.py * Update test_plotting.py * Update ptcl_class.py * Update 3D plot label setting * Fix plotting bug * Update ptcl_class.py * Update test_plotting.py * Add 3D plotting to docs * Update 3D plotting * Add additional 3d plotting functionality * Bugfix for area unit calculation * added Niblack and Sauvola segmentation Added two additional local segmentation methods: Niblack and Sauvola. Also converted local threshold method to odd integers only, as specified by skimage.filters.threshold_local * Bugfix for Invert check in SegUI Fixed invert toggle not applying to SegUI image after 'Update'. Fixed typo in ParticleAnalysis A typo in docs Changes to segmentation.rst to add Niblack and Sauvola. changed parameter files back. * Revert "Bugfix for Invert check in SegUI" This reverts commit 3e65293. * no altered parameters files commit back to 3e65293 without broken parameters files * Assitional clustering tests added new clustering test capable of sets of parameters for each thresholding method * changed test-clustering * fixed test particle clustering * more Parameter testing test particle clustering extended to all thresholding methods apart from sauvola. * Local Filter kernel Fixes disables option to change local filter kernel until a local segmentation method is selected. For Niblack, Sauvola and Local thresholding methods local kernel filter is locked to odd numbers updated parameters file to account for new local filter kernel values * test for scikit image update * remove parameters in regionprops * Update test_parameters.dat * updated test_parameters * updated watershed function used * Updated watershed in SegUI * Update test_params.dat again * corrected clean_borders corrected clean borders to take place after watershed separation to exclude less complete particles * improved compatibility for scikits reverted scikit-learn earliest to 0.21 and scikit-image to 0.17.1 * updated test parameters updated test parameters in test_parameters.dat. updated the default parameters as these were overriding the user-created parameters if they were set at zero * Update setup.py * adds new clustering methods added new clustering methods for individual hyperspy objects and series of hyperspy objects * Update ParticleAnalysis.py * Update test_parameters.dat * Update test_particle_clustering.py * more filter parameters * Update ParticleAnalysis.py * New SegUI tab added new SegUI tab to develop improved labelling methods * added Radion buttons for different tools * added line tool * Update SegUI.py * fixed tool alignment * Fixed Tool selection * added polygon tool * Updated coordinates of SegUI to use QPoints * Tidied Tools and line drawings * Fixed flood Fill flood fill no longer darkens touside of image and correctly fills enclosed shapes * arr flipped to ARGB * updated colour selection of flood fill * moved flood fill to separate function * added test for learn clustering * added documentation and test fix * updated tests * New SegUI tab added new SegUI tab to develop improved labelling methods * added Radion buttons for different tools * added line tool * Update SegUI.py * fixed tool alignment * Fixed Tool selection * added polygon tool * Updated coordinates of SegUI to use QPoints * Tidied Tools and line drawings * Fixed flood Fill flood fill no longer darkens touside of image and correctly fills enclosed shapes * arr flipped to ARGB * updated colour selection of flood fill * moved flood fill to separate function * fixed color flood filling and added color tool buttons * flood fill colour is pen dependent * fixed flooding * added clear button * updated saving labels * added trainable segmentation * updated SegUI layout * corrected trainables * updated classifier * tidied SegUI * commented ClusterTrained * Working trainable segmentation * Update ParticleAnalysis.py * Update labels to v0.5.0 * added difference of gaussians * added membrane projection kernel * added documentation * added training to SegUI * fixed labels displaying on canvas * Update SegUI.py * fixed clustering methods * Adds docs and moves functions Moved all functions related to clustering and classifying to a new file 'segimgs.py' * rewrites clustering algorithms * moves segimgs.py to correct folder * improves docs & fixes bugs * adds partial test and bugfixes * adds test for trainSeg * Update test_particle_clustering.py * removes saving mask to png * fixes tests * updates docs updates docs with example of classifying multiple images * Update segmentation.rst * Update test_particle_clustering.py Co-authored-by: CameronGBell <cameronbell2236@gmail.com> Co-authored-by: CameronGBell <70440659+CameronGBell@users.noreply.github.com>
1 parent aed7211 commit ccafb01

11 files changed

Lines changed: 661 additions & 53 deletions

File tree

ParticleSpy/Data/trainingmask.png

2.9 KB
Loading

ParticleSpy/ParticleAnalysis.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
from ParticleSpy.segptcls import process
99
import numpy as np
1010
from ParticleSpy.ptcl_class import Particle, Particle_list
11+
from ParticleSpy.custom_kernels import membrane_projection
1112
from skimage import filters, morphology
1213
from skimage.measure import label, regionprops, perimeter
14+
from sklearn import preprocessing
15+
from sklearn.cluster import DBSCAN, KMeans
1316
import ParticleSpy.find_zoneaxis as zone
1417
import warnings
1518
import h5py
1619
import inspect
17-
import matplotlib.pyplot as plt
1820
import pandas as pd
1921
import trackpy
2022
import os
@@ -35,8 +37,8 @@ def ParticleAnalysis(acquisition,parameters,particles=None,mask=np.zeros((1))):
3537
List of already analysed particles that the output can be appended
3638
to.
3739
mask: Numpy array
38-
Numpy array of same 2D size as acquisition that contains a mask of presegmented
39-
particles.
40+
Numpy array of same 2D size as acquisition that contains a mask of
41+
presegmented particles.
4042
4143
Returns
4244
-------
@@ -170,7 +172,7 @@ def ParticleAnalysisSeries(image_series,parameters,particles=None):
170172
171173
Parameters
172174
----------
173-
image_series: Hyperpsy signal object or list of hyperspy signal objects.
175+
image_series: Hyperspy signal object or list of hyperspy signal objects.
174176
Hyperpsy signal object containing nanoparticle images or a list of signal
175177
objects that contains a time series.
176178
parameters: Dictionary of parameters
@@ -231,7 +233,7 @@ def timeseriesanalysis(particles,max_dist=1,memory=3,properties=['area']):
231233

232234
t = trackpy.link(df,max_dist,memory=memory)
233235
return(t)
234-
236+
235237
def store_image(particle,image,params):
236238
ii = np.where(particle.mask)
237239

0 commit comments

Comments
 (0)