impy.utils package¶
Submodules¶
impy.utils.axesop module¶
- impy.utils.axesop.add_axes(axes, shape, key, key_axes='yx')[source]¶
Stack key to make its shape key_axes-> axes.
- impy.utils.axesop.axes_included(img, label)[source]¶
e.g.) img.axes = “tyx”, label.axes = “yx” -> True img.axes = “tcyx”, label.axes = “zyx” -> False
impy.utils.deco module¶
- impy.utils.deco.dims_to_spatial_axes(func)[source]¶
Decorator to convert input dims to correct spatial axes. Compatible with ImgArray and LazyImgArray e.g.) dims=None (default) -> “yx” or “zyx” depend on the input image dims=2 -> “yx” dims=3 -> “zyx” dims=”ty” -> “ty”
- impy.utils.deco.record(func=None, *, append_history=True, record_label=False, only_binary=False, need_labels=False)[source]¶
- impy.utils.deco.same_dtype(func=None, asfloat=False)[source]¶
Decorator to assure output image has the same dtype as the input image. This decorator is compatible with both ImgArray and LazyImgArray.
- Parameters
asfloat (bool, optional) – If input image should be converted to float first, by default False
impy.utils.gauss module¶
- class impy.utils.gauss.DiagonalGaussian(params=None)[source]¶
Bases:
impy.utils.gauss.Gaussian
- property mu¶
- property ndim¶
- property params¶
- property sg¶
impy.utils.io module¶
- impy.utils.io.imwrite(file, data=None, shape=None, dtype=None, **kwargs)[source]¶
Write numpy array to TIFF file.
Refer to the TiffWriter class and its write function for documentation.
A BigTIFF file is created if the data’s size is larger than 4 GB minus 32 MB (for metadata), and ‘bigtiff’ is not specified, and ‘imagej’ or ‘truncate’ are not enabled.
- Parameters
file (str, path-like, or binary stream) – File name or writable binary stream, such as an open file or BytesIO.
data (array-like) – Input image. The last dimensions are assumed to be image depth, length, width, and samples. If None, an empty array of the specified shape and dtype is saved to file. Unless ‘byteorder’ is specified in ‘kwargs’, the TIFF file byte order is determined from the data’s dtype or the dtype argument.
shape (tuple) – If ‘data’ is None, shape of an empty array to save to the file.
dtype (numpy.dtype) – If ‘data’ is None, datatype of an empty array to save to the file.
kwargs (dict) – Parameters ‘append’, ‘byteorder’, ‘bigtiff’, ‘imagej’, and ‘ome’, are passed to TiffWriter(). Other parameters are passed to TiffWriter.write().
- Returns
offset, bytecount – If the ‘returnoffset’ argument is True and the image data are written contiguously, return offset and bytecount of image data in the file.
- Return type
tuple or None
- impy.utils.io.memmap(filename, shape=None, dtype=None, page=None, series=0, level=0, mode='r+', **kwargs)[source]¶
Return memory-mapped numpy array stored in TIFF file.
Memory-mapping requires data stored in native byte order, without tiling, compression, predictors, etc. If ‘shape’ and ‘dtype’ are provided, existing files are overwritten or appended to depending on the ‘append’ parameter. Otherwise the image data of a specified page or series in an existing file are memory-mapped. By default, the image data of the first series are memory-mapped. Call flush() to write any changes in the array to the file. Raise ValueError if the image data in the file are not memory-mappable.
- Parameters
filename (str or path-like) – Name of the TIFF file which stores the array.
shape (tuple) – Shape of the empty array.
dtype (numpy.dtype) – Datatype of the empty array.
page (int) – Index of the page which image data to memory-map.
series (int) – Index of the page series and pyramid level which image data to memory-map.
level (int) – Index of the page series and pyramid level which image data to memory-map.
mode ({'r+', 'r', 'c'}) – The file open mode. Default is to open existing file for reading and writing (‘r+’).
kwargs (dict) – Additional parameters passed to imwrite() or TiffFile().
- Returns
Image data in TIFF file.
- Return type
numpy.memmap
impy.utils.misc module¶
impy.utils.slicer module¶
- impy.utils.slicer.axis_targeted_slicing(arr: numpy.ndarray, axes: str, string: str) Tuple[Union[slice, int], ...] [source]¶
Make a conventional slices from an axis-targeted slicing string.
- Parameters
arr (np.ndarray) – Array to be sliced.
axes (str) – Axes of input ndarray.
string (str) – Axis-targeted slicing string. If an axis that does not exist in axes is contained, this function will raise ValueError.
- Returns
- Return type
slices