impy

Speed up coding/extending image analysis in Python.

BSD-3-CLAUSE License

Downloads
2.2K
Stars
30
Committers
2
impy - Improvements and New Functions

Published by hanjinliu over 3 years ago

Improvements

  • __getitem__, especially axis targeted slicing is faster.
  • numba, napari, and trackpy were imported at the same time as importing impy before, which slowed down importing time up to ~4 sec. These modules are now imported just after they are needed.
  • specify is re-implemented with numba and now it is much faster.
  • reslice is re-implemented. It's up to ~50 times faster and supports 3D reslicing.
  • refine_sm now works for n-D images.
  • skeletonize takes radius argument.

New Functions

  1. PhaseArray (new)
    This class is specialized in phase images. PhaseArray supports:
  • radian/degree conversion
  • mean_filter with correct averaging formula.
  • regionprops with specialized properties "phase_mean" and "phase_std".
  1. ImgArray
  • voronoi for image segmentation.
  • area_opening, area_closing, diameter_opening, diameter_closing.
  • flood for flood-fill labeling.
  • split_pixel_unit, stokes for polarization microscopy.
  • pointprops to measure floating coordinates.
  • label_if is useful for filtering labels upon labeling.
  • Many binary object detections.
  1. PropArray
  • hist method for plotting histogram.
  1. Axes
  • replace method is useful for replacing axes symbols.

Changes

  • reslice no longer takes linewidth argument because it is useless and difficult to implement for 3D images.
  • affine_correction is less flexible (it doesn't take reference image as an argument) but this change does not lose generality because you can access the optimal matrices by out.temp anyway.
impy - New Functions

Published by hanjinliu over 3 years ago

News

  • lineprops for measuring lines, such as mean intensities along a line.
  • gauss_correction for direct correction and background subtraction.
  • directional_median_filter for filtering salt and pepper noise while preserving edges.
  • random_walker for segmentation.
  • lbp, glcm_filter, glcm_props for texture classification. Especially, some functions are available that were not in skimage. Currently main for-loop in glcm_props are coded in pure Python so that it is very slow. It is partly implemented using numba (if available). After numba can efficiently compile numpy functions (especially np.sum, which get slower in numba), I'll fix this problem.
  • hessian_angle, gabor_angle for calculating filament angle (for those who want to analyze such as DNA or cytoskeletons). Accordingly, PhaseArray is newly implemented for phase images. Attached napari viewer can recognize PhaseArray and show in cyclic colormap.

Improvements

  • Broadcasting abolished image axes before. Also, __getitem__ method could not make full use of axes information. Now in v1.7.0 axes-based broadcasting is smarter.
    img ← 4-dimensional image with tzyx-axes
    thr ← 3-dimensional boolean image with tyx-axes
    then,
    img[thr] ← this works!

  • Some labeling functions are moved to LabeledArray from ImgArray, for compatibility between PhaseArray.

  • napari is imported inside a function. The startup time is shorter now.

impy - Trackpy Supports and Simple DataFrame Handling, and Some New Functions

Published by hanjinliu over 3 years ago

News

  1. New Functions of ImgArray
  • wiener for deconvolution.
  • extract for extraction of certain region of image according to labels.
  • defocus for z-padding, which is very useful for FFT preprocessing.
  • focus_map to find focal plane of 3D image stack, using variance of Laplacian method.
  • std_filter, coef_filter are filters based on standard deviation. scipy.ndimage.generic_filter is very slow so I implemented in E[X^2] - E[X]^2 method.
  • doh_filter (determinant of Hessian), log_filter (Laplacian of Gaussian) are implemented aimed at single molecule detection in microscopic images. They can used in find_sm.
  1. Other News
  • MarkerFrame and TrackFrame, (subclass of pd.DataFrame) are defined. They have simple interface between trackpy. You can track particles with lnk = df.link(...), and return individual MSDs by lnk.imsd(...). They also supports ImgArray-like slicing, like df["t=0;c=1"].

Improvements

  • The use of MarkerArray was a little bit confusing so now all the functions that use coordinates supports interface with AxesFrame or its subclasses.
  • ip.window.add(X) now supports MarkerFrame/TrackFrame for drawing points/tracks.
  • Automatic color mapping in ip.window.add(X)
  • filt argument in specify, centroid_sm and gauss_sm, which filters if labels/markers should be added.
  • reslice returns PropArray instead or ImgArray to enable direct plot and curve_fit.

Bug Fix

  • specify could not draw labels when certain values are set to radius because of my misunderstanding of scikit-image's disk and ball functions. → Now it works for any values.
  • split did not inherit scales. &rrar; fixed.
impy - napari is partially working! And new functions

Published by hanjinliu over 3 years ago

News

  • ip.window will be imported if possible, and this object makes it easy to visualize image with napari.
  • curve_fit is working in PropArray, which can run scipy.optimize.curve_fit along any axis.
  • specify is totally modified and now it is very useful for labeling in square or circular shape.
  • melt is working in PropArray, which makes it easier to iterate along all the labels.

Improvements

  • Some of filter functions are implemented using functions provided in scipy.ndimage rather than skimage because they are much faster.
  • For images with size less than 10^7 pixels, parallel do not choose multiprocessing because it might be slower.
  • Scales of axes can be set with set_scale so that you don't need to specify pixel size in such as hessian_eigval.
  • peak_local_max takes percentile as an argument instead of absolute threshold because it is more useful.

Bug Fix

  • In some functions update=True did not work
  • split did split the image itself but did not split labels.

Important Changes

  • __getitem__ is zero-start now, like in napari.
  • All the plugin is deleted and moved into ImgArray methods.
impy - More Generalized Implementation and New Functions

Published by hanjinliu over 3 years ago

New Functions

  • enhance_contrast, entropy_filter ... feature detection.
  • skeletonize, fill_hole ... binary operation.
  • empty_like, zeros_like ... easily make image arrays with same parameters.
  • labels will also be inherited correctly, especially when xy-size changed by __getitem__.
  • You can prevent unwanted image analysis using freeze function.

Deleted/Modified

  • lut no longer works because it is not useful.
  • All the light_bg arguments are removed because you can do it by inverting image.
  • lucy2d and lucy3d are integrated as lucy.
  • peak_local_max returns PropArray with IndexArray now, which is convenient for multi-dimensional images.

Simplifications

  • __array_ufunc__, __array_finalize__ and _set_info had very similar part while they had separated codes. Now they are much more clearer.
  • To specify along which axes to iterate, you can use dims keyword argument for many functions commonly. This is achieved by using decorator dims_to_spatial_axes.

Immediate Goals

  • I want to integrate units (such as nm, msec, or maybe channel names) into Axes to enable efficient tracking of scales. After this is done, scaling parameters such as pxsize in hessian_eig will be removed.
  • For data visualization, I'll depend on napari. Of course it will be coded in plugin folder.
impy - Bug fix and new methods

Published by hanjinliu over 3 years ago

Bug Fix

  • gaussian_filter did not work in previous version because of slightly different implementation of other running-kernel filters.
  • impy.zeros did not work because I forgot adding it in __init__.py.
  • clip_outliers and rescale_intensity did not work in some cases because of bad implementation.

New Methods

  • gaussfit_particle
  • structure_tensor_eigval
  • structure_tensor_eig
  • dog_filter
  • peak_local_max

Changes

  • Following methods now support new keyword argument update : bool -- mean_filter, median_filter, gaussian_filter, tophat, erosion, dilation, opening, closing. If update=True, the original image is updated just like filters in ImageJ.
  • Gaussian functions are integrated in gauss.py and now it can be utilized for generating images and fitting to single molecules.
impy - First Release

Published by hanjinliu over 3 years ago

I want to write in the future:

  • RANSAC Gaussian fitting.
  • Hessian method for cytoskeleton, cell surface, axon detection.
  • Single molecule tracking and cell tracking
  • ImageJ ROI → attribute labels