ParticleSpy package

Submodules

particlespy.particle_analysis module

Created on Tue Jul 31 13:35:23 2018

@author: qzo13262

particlespy.particle_analysis.get_composition(particle, params)[source]
class particlespy.particle_analysis.parameters[source]

Bases: object

A parameters object.

generate(threshold='otsu', watershed=False, watershed_size=0, watershed_erosion=0, invert=False, min_size=0, store_im=False, pad=5, rb_kernel=0, gaussian=0, local_size=1)[source]
generate_eds(eds_method=False, elements=False, factors=False, store_maps=False)[source]
load(filename='/home/travis/build/ePSIC-DLS/particlespy/particlespy/parameters/parameters_current.hdf5')[source]
save(filename='/home/travis/build/ePSIC-DLS/particlespy/particlespy/parameters/parameters_current.hdf5')[source]
particlespy.particle_analysis.particle_analysis(acquisition, parameters, particles=None, mask=array([0.0]))[source]

Perform segmentation and analysis of images of particles.

acquisition: Hyperpsy signal object or list of hyperspy signal objects.
Hyperpsy signal object containing a nanoparticle image or a list of signal

objects that contains an image at position 0 and other datasets following.

parameters: Dictionary of parameters

The parameters can be input manually in to a dictionary or can be generated using param_generator().

particles: list

List of already analysed particles that the output can be appended to.

mask: Numpy array

Numpy array of same 2D size as acquisition that contains a mask of presegmented particles.

Particle_list object

particlespy.particle_analysis.particle_analysis_series(image_series, parameters, particles=None)[source]

Perform segmentation and analysis of times series of particles.

image_series: Hyperspy signal object or list of hyperspy signal objects.
Hyperpsy signal object containing nanoparticle images or a list of signal

objects that contains a time series.

parameters: Dictionary of parameters

The parameters can be input manually in to a dictionary or can be generated using param_generator().

particles: list

List of already analysed particles that the output can be appended to.

Particle_list object

particlespy.particle_analysis.store_image(particle, image, params)[source]
particlespy.particle_analysis.store_maps(particle, ac, params)[source]
particlespy.particle_analysis.store_spectrum(particle, ac, stype)[source]
particlespy.particle_analysis.time_series_analysis(particles, max_dist=1, memory=3, properties=['area'])[source]

Perform tracking of particles for times series data.

particles : Particle_list object. max_dist : int

The maximum distance between the same particle in subsequent images.

memoryint

The number of frames to remember particles over.

propertieslist

A list of particle properties to track over the time series.

Pandas DataFrame of tracjectories.

class particlespy.particle_analysis.trainable_parameters(gaussian=[True, 1], diff_gaussian=[True, [False, 1], 1, 16], median=[True, [False, 1], 20], minimum=[True, [False, 1], 20], maximum=[True, [False, 1], 20], sobel=[True, [True, 1]], hessian=[False, [False, 1]], laplacian=[False, [False, 1]], membrane=[[False, 1], True, False, False, False, False, False])[source]

Bases: object

A parameters object for trainable segmentation.

set_diff_gaussian(enabled=True, prefilter=True, prefilter_sigma=1, low_sigma=1, high_sigma=16)[source]
set_gaussian(enabled=True, sigma=1)[source]
set_global_disk_size(disk_size)[source]
set_global_prefilter(sigma)[source]
set_global_sigma(sigma)[source]
set_hessian(enabled=True, prefilter=True, prefilter_sigma=1)[source]
set_laplacian(enabled=True, prefilter=True, prefilter_sigma=1)[source]
set_maximum(enabled=True, prefilter=True, prefilter_sigma=1, disk_size=20)[source]
set_median(enabled=True, prefilter=True, prefilter_sigma=1, disk_size=20)[source]
set_membrane(enabled=True, prefilter=True, prefilter_sigma=1, summ=True, mean=True, stddev=True, maximum=True, minimum=True, median=True)[source]
set_minimum(enabled=True, prefilter=True, prefilter_sigma=1, disk_size=20)[source]
set_sobel(enabled=True, prefilter=True, prefilter_sigma=1)[source]

particlespy.seg_ui module

Created on Mon Oct 22 15:50:08 2018

@author: qzo13262

class particlespy.seg_ui.Application(im_hs, height)[source]

Bases: PyQt5.QtWidgets.QMainWindow

changeIm()[source]
changeInvert(state)[source]
changeWatershed(state)[source]
change_disk()[source]
change_high_sigma()[source]
change_sigma()[source]
classifier_choice()[source]
gaussian()[source]
getim(im_hs)[source]
getparams()[source]
local()[source]
minsize()[source]
return_params(params)[source]
rollingball()[source]
save_and_close()[source]
save_array()[source]
threshold_choice()[source]
toggle_fk(tool)[source]
train_classifier()[source]
undo()[source]
update(self)[source]
update(self, QRect) None
update(self, QRegion) None
Application.update(self, int, int, int, int) -> None
updateLocalSize()[source]
watershed()[source]
watershed_e()[source]
class particlespy.seg_ui.Canvas(pixmap, canvas_size)[source]

Bases: PyQt5.QtWidgets.QLabel

LineTool(e)[source]
PolyTool(e)[source]
changePen(brush)[source]
clearCanvas()[source]
clearLabels()[source]
drawLabels(thin_labels)[source]
flood(e)[source]
lineDraw(pos1, pos2)[source]
mouseMoveEvent(self, QMouseEvent)[source]
mousePressEvent(self, QMouseEvent)[source]
mouseReleaseEvent(self, QMouseEvent)[source]
redrawLabels()[source]
savearray(image)[source]
scaleImage(factor)[source]
set_pen_color(c)[source]
wheelEvent(self, QWheelEvent)[source]
class particlespy.seg_ui.QPaletteButton(color)[source]

Bases: PyQt5.QtWidgets.QPushButton

class particlespy.seg_ui.ToolButton(tool)[source]

Bases: PyQt5.QtWidgets.QPushButton

particlespy.seg_ui.main(image, height)[source]
particlespy.seg_ui.seg_ui(image)[source]

Function to launch the Segmentation User Interface.

particlespy.api module

Created on Mon Nov 5 09:48:31 2018

@author: qzo13262

particlespy.api.load(filename)[source]
particlespy.api.plot(particle_lists, prop_list=['area'], **kwargs)[source]

Plots properties of all particles in the Particle_lists.

If one property given, displays a histogram of the chosen particle property.

If two properties given, displays a scatter plot of the two properties.

particle_listslist

A list of Particle_list objects.

prop_liststr or list

The name of a property or a list of the properties to plot.

binsint

The number of bins in the histogram if plotting one property.

plot([particles],[‘area’])

particlespy.find_zoneaxis module

Created on Thu Jun 14 13:59:52 2018

@author: qzo13262

particlespy.find_zoneaxis.find_zoneaxis(im)[source]

Determines whether an atomic resolution image is solely of a major zone axis (001, 011, 111) for cubic materials.

im: Numpy array

Atomic resolution image of sample.

str : Zone axis of material in image (eg. ‘011’)

particlespy.find_zoneaxis.set_circle(im_dim=(2048, 2048), radius=150)[source]

particlespy.particle_io module

particlespy.particle_load module

Created on Wed Nov 28 17:11:22 2018

@author: qzo13262

particlespy.particle_load.load_plist(filename)[source]

particlespy.particle_save module

Created on Thu Nov 22 12:23:59 2018

@author: qzo13262

particlespy.particle_save.save_plist(p_list, filename)[source]

particlespy.ptcl_class module

Created on Tue Jul 31 14:51:58 2018

@author: qzo13262

class particlespy.ptcl_class.particle[source]

Bases: object

A segmented particle object.

propertiesdict

Dictionary of particle properties created by the ParticleAnalysis() function.

originstr

Origin of particle data, e.g. filename or acquisition number.

zonestr

Zone axis of particle.

maskarray

Boolean array corresponding to the particle pixels on the original image.

imageHyperspy signal object

Image of particle.

mapsdict

Dictionary containing elemental maps of the particle.

spectrumHyperspy signal object

Spectrum obtained from the particle.

compositiondict

Dictionary of composition values for the particle.

maps_gen()[source]
set_area(area, units)[source]
set_axes_lengths(axeslengths, units)[source]
set_boundingbox(bbox)[source]
set_circdiam(circdiam, units)[source]
set_circularity(circularity)[source]
set_eccentricity(eccentricity)[source]
set_intensity(intensity)[source]
set_mask(mask)[source]
set_origin(origin)[source]

A container for the origin of data (filename, acquisition number etc.)

set_property(propname, value, units)[source]

Give a particle() object an arbitrary property.

propnamestr

The name of the property to set.

value

The value of the property.

units :

The units of the property.

>>> particle.set_property('area',10.0,'nm')
set_zone(zone)[source]
store_composition(composition)[source]
store_im(p_im)[source]
store_map(p_map, element)[source]
store_spectrum(spectrum, stype)[source]
class particlespy.ptcl_class.particle_list[source]

Bases: object

A particle list object.

append(particle)[source]
cluster_particles(algorithm='Kmeans', properties=None, n_clusters=2, eps=0.2, min_samples=5)[source]

Cluster particles in to different populations based on specified properties.

algorithm: str

The algorithm to use for clustering. Options are ‘Kmeans’,’DBSCAN’,’OPTICS’,’AffinityPropagation’.

properties: list

A list of the properties upon which to base the clustering.

n_clusters: int

The number of clusters to split the data into. Used for Kmeans.

eps: float

The distance between samples. Used for DBSCAN.

min_samples: int

The minimum number of samples within the eps distance to be classed as a cluster. Used for DBSCAN and OPTICS.

List of Particle_list() objects.

normalize_boxing(even=False)[source]

Normalizes the size of all particle images so that their dimensions are equal.

>>> particles.normalize_boxing()
plot(prop_list=['area'], **kwargs)[source]

Plots properties of all particles in the Particle_list.

If one property given, displays a histogram of the chosen particle property.

If two properties given, displays a scatter plot of the two properties.

prop_liststr or list

A particle property or a list of the names of the properties to plot.

**kwargs

Keyword arguments for matplotlib plotting functions.

particles.plot(‘area’, bins=20)

particles.plot([‘equivalent circular diameter’,’circularity’])

save(filename)[source]

particlespy.radial_profile module

Created on Tue May 28 09:58:37 2019

@author: qzo13262

particlespy.radial_profile.concentric_scan_absolutedis(element_map)[source]
Return:

dis_count_dict: keys ordered dict {dis0: countX0, dis1: countX1, …}

particlespy.radial_profile.plot_profile(dist_count_dic, scale, units, mark_radius=False, radius=1.0, save=False, dir_save=None)[source]

Function to plot a radial profile of particle signals.

dist_count_dicdict

Dictionary containing the distances and counts of the profile.

scale : float units : str mark_radius : bool

If true, mark the particle radius on the profile plot.

radius : float save : bool dir_save : str

Default : None

particlespy.radial_profile.radial_profile(particle, signals, plot=True, mark_radius=False)[source]

Function to calculate and plot a radial profile of a signal from an individual particle.

particleParticleSpy particle object

The particle object.

signalslist

List of signals to plot, either ‘Image’ or element name, e.g. ‘Ag’.

plotbool

True if plotting, False otherwise.

mark_radiusbool

If true, mark the particle radius on the profile plot.

particlespy.segptcls module

Created on Tue Jul 31 15:06:08 2018

@author: qzo13262

particlespy.segptcls.p_watershed(thresh_image, min_size, erosion)[source]
particlespy.segptcls.process(im, param)[source]

Perform segmentation of an image of particles.

im: Hyperpsy signal object

Hyperpsy signal object containing a nanoparticle image.

process_param: Dictionary of parameters

The parameters for segmentation.

numpy array: Labels corresponding to particles in the image.

particlespy.segptcls.rolling_ball(img, kernelsize=0)[source]
particlespy.segptcls.threshold(data, process_param)[source]

Module contents