pyImagingMSpec package¶
Subpackages¶
Submodules¶
pyImagingMSpec.image_measures module¶
-
pyImagingMSpec.image_measures.
isotope_image_correlation
(images_flat, weights=None)[source]¶ Function for calculating a weighted average measure of image correlation with the principle image.
Parameters: - images_flat – 2d array (or sequence of 1d arrays) of pixel intensities with shape (d1, d2) where d1 is the number of images and d2 is the number of pixels per image, i.e.
images_flat[i]
is the i-th flattened image - weights – 1d array (or sequence) of weights with shape (d1 - 1), i.e
weights[i]
is the weight to put on the correlation between the first and the i-th image. If omitted, all correlations are weighted equally
Returns: measure_value (zero if less than 2 images are given)
Raises: - TypeError – if images are not 1d
- ValueError – if images are not equally shaped or if the number of correlations and the number of weights (if given) differ
- images_flat – 2d array (or sequence of 1d arrays) of pixel intensities with shape (d1, d2) where d1 is the number of images and d2 is the number of pixels per image, i.e.
-
pyImagingMSpec.image_measures.
isotope_pattern_match
(images_flat, theor_iso_intensities)[source]¶ This function calculates a match between a list of isotope ion images and a theoretical intensity vector.
Parameters: - images_flat – 2d array (or sequence of 1d arrays) of pixel intensities with shape (d1, d2) where d1 is the number of images and d2 is the number of pixels per image, i.e.
images_flat[i]
is the i-th flattened image - theor_iso_intensities – 1d array (or sequence) of theoretical isotope intensities with shape d1, i.e
theor_iso_intensities[i]
is the theoretical isotope intensity corresponding to the i-th image
Returns: measure value between 0 and 1, bigger is better
Return type: float
Raises: - TypeError – if images are not 1d
- ValueError – if images are not equally shaped or if the number of images and the number of intensities differ
- images_flat – 2d array (or sequence of 1d arrays) of pixel intensities with shape (d1, d2) where d1 is the number of images and d2 is the number of pixels per image, i.e.
-
pyImagingMSpec.image_measures.
measure_of_chaos
(im, nlevels, overwrite=True, statistic=None)[source]¶ Compute a measure for the spatial chaos in given image using the level sets method.
Parameters: - im – 2d array
- nlevels (int) – how many levels to use
- overwrite (bool) – Whether the input image can be overwritten to save memory
- statistic – callable that calculates a score (a number) for the object counts in the level sets. If
specified, this statistic will be used instead of the default one. The callable must take two arguments - the object counts (sequence of ints) and the number of non-zero pixels in the original image (int) - and output a number :return: the measured value :rtype: float :raises ValueError: if nlevels <= 0 or q_val is an invalid percentile or an unknown interp value is used
pyImagingMSpec.imutils module¶
-
pyImagingMSpec.imutils.
interpolate
(im, notnull_mask=None)[source]¶ Use spline interpolation to fill in missing values.
Parameters: - im – the entire image, including nan or zero values
- notnull_mask – index array for the values greater than zero. If None, no mask is used
Returns: the interpolated array
-
pyImagingMSpec.imutils.
nan_to_zero
(im)[source]¶ Set all values to zero that are less than zero or nan; return the indices of all elements that are zero after the modification (i.e. those that have been nan or smaller than or equal to zero before calling this function). The returned boolean array has the same shape, False denotes that a value is zero now.
Parameters: im – the array which nan-values will be set to zero in-place Returns: A boolean array of the same shape as im
-
pyImagingMSpec.imutils.
quantile_threshold
(im, q_val, notnull_mask=None)[source]¶ Set all values greater than the
q_val
-th percentile to theq_val
-th percentile (i.e. flatten out everything greater than theq_val
-th percentile). For determining the percentile, only nonzero pixels are taken into account, that isim[notnull_mask]
.Parameters: - im – the array to remove the hotspots from
- q_val – percentile to use
- notnull_mask – index array for the values greater than zero. If None, no mask is used
Returns: The
q_val
-th percentile
pyImagingMSpec.inMemoryIMS module¶
pyImagingMSpec.ion_datacube module¶
-
class
pyImagingMSpec.ion_datacube.
ion_datacube
(step_size=[])[source]¶ -
-
apply_image_processing
(smooth_method, **smooth_params)[source]¶ Function to apply pre-defined image processing methods to ion_datacube #todo: expose parameters in config :param ion_datacube:
object from pyImagingMSpec.ion_datacube already containing imagesReturns: ion_datacube is updated in place. None returned
-