PartSegImage¶
- class PartSegImage.Channel(value)[source]¶
Bases:
objectThis class is introduced to distinguish numerical algorithm parameter from choose channel. In autogenerated interface field with this type limits input values to number of current image channels
- class PartSegImage.ChannelInfo(*, name, color_map=None, contrast_limits=None)[source]¶
Bases:
object
- class PartSegImage.ChannelInfoFull(*, name, color_map, contrast_limits)[source]¶
Bases:
objectFull channel information used in
Image
- class PartSegImage.CziImageReader(callback_function=None)[source]¶
Bases:
BaseImageReaderBufferThis class is to read data from czi files. Masks will be treated as TIFF.
- read(image_path, mask_path=None, ext=None)[source]¶
Main function to read image. If ext is not set then it may be deduced from path to file. If BytesIO is given and non default data file type is needed then ext need to be set
- classmethod read_image(image_path, mask_path=None, callback_function=None, default_spacing=None)¶
read image file with optional mask file
- Parameters:
image_path (
Union[str,Path,BytesIO]) – path or opened file contains imagemask_path
callback_function (
Optional[Callable]) – function for provide information about progress in reading file (for progressbar)default_spacing (
Optional[tuple[float,float,float]]) – used if file do not contains information about spacing (or metadata format is not supported)
- Return type:
- Returns:
image
- classmethod return_order()¶
Order to which image axes should be rearranged before pass to
image_classconstructor. Default isimage_class.return_order- Return type:
- class PartSegImage.GenericImageReader(callback_function=None)[source]¶
Bases:
BaseImageReaderBufferThis class try to decide which method use base on path
- read(image_path, mask_path=None, ext=None)[source]¶
Main function to read image. If ext is not set then it may be deduced from path to file. If BytesIO is given and non default data file type is needed then ext need to be set
- classmethod read_image(image_path, mask_path=None, callback_function=None, default_spacing=None)¶
read image file with optional mask file
- Parameters:
image_path (
Union[str,Path,BytesIO]) – path or opened file contains imagemask_path
callback_function (
Optional[Callable]) – function for provide information about progress in reading file (for progressbar)default_spacing (
Optional[tuple[float,float,float]]) – used if file do not contains information about spacing (or metadata format is not supported)
- Return type:
- Returns:
image
- classmethod return_order()¶
Order to which image axes should be rearranged before pass to
image_classconstructor. Default isimage_class.return_order- Return type:
- class PartSegImage.IMAGEJImageWriter[source]¶
Bases:
BaseImageWriterclass for saving TIFF images
- class PartSegImage.Image(data, *, spacing, time_increment=1.0, file_path=None, mask=None, channel_info=None, axes_order=None, shift=None, name='', metadata_dict=None)[source]¶
Bases:
objectBase class for Images used in PartSeg
- Parameters:
data (
Union[list[ndarray],ndarray]) – 5-dim array with order: time, z, y, x, channelspacing (
tuple[Union[float,int],...]) – spacing for z, y, xfile_path – path to image on disc
channel_info (
list[ChannelInfo|ChannelInfoFull] |None) – list of metadata stored per channelaxes_order (
str|None) – allow to create Image object form data with different axes order, or missed axes
- Variables:
~.axis_order (str) – internal order of axes
It is prepared for subclassing with changed internal order. Eg:
>>> class ImageJImage(Image): >>> axis_order = "TZCYX"
- static calc_index_to_frame(array_axis, important_axis)[source]¶
calculate in which axis frame should be added
- clip_array(array, **kwargs)[source]¶
Clip array by axis. Axis is selected by single letter from
axis_order
- cut_image(cut_area, replace_mask=False, frame=2, zero_out_cut_area=True)[source]¶
Create new image base on mask or list of slices :type bool replace_mask: :param bool replace_mask: if cut area is represented by mask array, then in result image the mask is set base on cut_area if cur_area is np.ndarray :type cut_area:
Union[ndarray,Iterable[slice]] :param cut_area: area to cut. Defined with slices or mask :type frame:int:param frame: additional frame around cut_area :type zero_out_cut_area:bool:param zero_out_cut_area:- Return type:
- Returns:
Image
- fit_array_to_image(array)[source]¶
Change shape of array with inserting single dimensional entries
- Parameters:
array (
ndarray) – array to be fitted- Return type:
- Returns:
reshaped array with added missing 1 in shape
- Raises:
ValueError – if cannot fit array
- fit_mask_to_image(array)[source]¶
call
fit_array_to_image()and then relabel and change type to minimal which fit all information- Return type:
- get_data_by_axis(**kwargs)[source]¶
Get part of data extracted by sub axis. Axis is selected by single letter from
axis_order- Parameters:
kwargs – axis list with
- Returns:
- Return type:
- get_dimension_letters()[source]¶
- Return type:
- Returns:
letters which indicates non trivial dimensions
- property is_2d: bool¶
Check if image z and time dimension are equal to 1. Equivalent to: image.layers == 1 and image.times == 1
- merge(image, axis)[source]¶
Produce new image merging image data along given axis. All metadata are obtained from self.
- set_mask(mask, axes=None)[source]¶
Set mask for image, check if it has proper shape.
- Parameters:
- Raises:
ValueError – on wrong shape
- property shape¶
Whole image shape. order of axes my change. Current order is in
return_order
- substitute(data=None, image_spacing=None, time_increment=None, file_path=None, mask=<object object>, default_coloring=None, ranges=None, channel_names=None)[source]¶
Create copy of image with substitution of not None elements
- Return type:
- swap_time_and_stack()[source]¶
Swap time and stack axes. For example my be used to convert time image in 3d image.
- property time_pos¶
Time axis. Need to have ‘T’ in
axis_order
- class PartSegImage.ImageWriter[source]¶
Bases:
BaseImageWriterclass for saving TIFF images
- class PartSegImage.ObsepImageReader(callback_function=None)[source]¶
Bases:
BaseImageReader- read(image_path, mask_path=None, ext=None)[source]¶
Main function to read image. If ext is not set then it may be deduced from path to file. If BytesIO is given and non default data file type is needed then ext need to be set
- classmethod read_image(image_path, mask_path=None, callback_function=None, default_spacing=None)¶
read image file with optional mask file
- Parameters:
image_path (
Union[str,Path]) – path or opened file contains imagemask_path
callback_function (
Optional[Callable]) – function for provide information about progress in reading file (for progressbar)default_spacing (
Optional[tuple[float,float,float]]) – used if file do not contains information about spacing (or metadata format is not supported)
- Return type:
- Returns:
image
- classmethod return_order()¶
Order to which image axes should be rearranged before pass to
image_classconstructor. Default isimage_class.return_order- Return type:
- class PartSegImage.OifImagReader(callback_function=None)[source]¶
Bases:
BaseImageReader- read(image_path, mask_path=None, ext=None)[source]¶
Main function to read image. If ext is not set then it may be deduced from path to file. If BytesIO is given and non default data file type is needed then ext need to be set
- classmethod read_image(image_path, mask_path=None, callback_function=None, default_spacing=None)¶
read image file with optional mask file
- Parameters:
image_path (
Union[str,Path]) – path or opened file contains imagemask_path
callback_function (
Optional[Callable]) – function for provide information about progress in reading file (for progressbar)default_spacing (
Optional[tuple[float,float,float]]) – used if file do not contains information about spacing (or metadata format is not supported)
- Return type:
- Returns:
image
- classmethod return_order()¶
Order to which image axes should be rearranged before pass to
image_classconstructor. Default isimage_class.return_order- Return type:
- exception PartSegImage.TiffFileException[source]¶
Bases:
Exceptionexception raised if reading tiff file fails. Created for distinguish exceptions which should reported as warning message (not for report)
- add_note()¶
Exception.add_note(note) – add a note to the exception
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class PartSegImage.TiffImageReader(callback_function=None)[source]¶
Bases:
BaseImageReaderBufferTIFF/LSM files reader. Base reading with
BaseImageReader.read_image()image_file: tifffile.TiffFile mask_file: tifffile.TiffFile
- static decode_int(val)[source]¶
This function split 32 bits int on 4 8-bits ints
- Parameters:
val (
int) – value to decode- Returns:
list of four numbers with values from [0, 255]
- classmethod read_image(image_path, mask_path=None, callback_function=None, default_spacing=None)¶
read image file with optional mask file
- Parameters:
image_path (
Union[str,Path,BytesIO]) – path or opened file contains imagemask_path
callback_function (
Optional[Callable]) – function for provide information about progress in reading file (for progressbar)default_spacing (
Optional[tuple[float,float,float]]) – used if file do not contains information about spacing (or metadata format is not supported)
- Return type:
- Returns:
image
- read_imagej_metadata(image_file)[source]¶
Read metadata from the ImageJ tiff file.
Read spacing, colors, channel names, ranges and other metadata. Save original metadata in
metadata- Parameters:
image_file (
TiffFile) – file to read- Return type:
- classmethod return_order()¶
Order to which image axes should be rearranged before pass to
image_classconstructor. Default isimage_class.return_order- Return type:
- classmethod update_array_shape(array, axes)¶
Rearrange order of array axes to get proper internal axes order
PartSegImage.image_reader¶
- class PartSegImage.image_reader.BaseImageReader(callback_function=None)[source]¶
Bases:
objectBase class for reading image using Christopher Gholike libraries
- abstractmethod read(image_path, mask_path=None, ext=None)[source]¶
Main function to read image. If ext is not set then it may be deduced from path to file. If BytesIO is given and non default data file type is needed then ext need to be set
- classmethod read_image(image_path, mask_path=None, callback_function=None, default_spacing=None)[source]¶
read image file with optional mask file
- Parameters:
image_path (
Union[str,Path]) – path or opened file contains imagemask_path
callback_function (
Optional[Callable]) – function for provide information about progress in reading file (for progressbar)default_spacing (
Optional[tuple[float,float,float]]) – used if file do not contains information about spacing (or metadata format is not supported)
- Return type:
- Returns:
image
- classmethod return_order()[source]¶
Order to which image axes should be rearranged before pass to
image_classconstructor. Default isimage_class.return_order- Return type:
- class PartSegImage.image_reader.BaseImageReaderBuffer(callback_function=None)[source]¶
Bases:
BaseImageReader- abstractmethod read(image_path, mask_path=None, ext=None)[source]¶
Main function to read image. If ext is not set then it may be deduced from path to file. If BytesIO is given and non default data file type is needed then ext need to be set
- classmethod read_image(image_path, mask_path=None, callback_function=None, default_spacing=None)[source]¶
read image file with optional mask file
- Parameters:
image_path (
Union[str,Path,BytesIO]) – path or opened file contains imagemask_path
callback_function (
Optional[Callable]) – function for provide information about progress in reading file (for progressbar)default_spacing (
Optional[tuple[float,float,float]]) – used if file do not contains information about spacing (or metadata format is not supported)
- Return type:
- Returns:
image
- class PartSegImage.image_reader.CziImageReader(callback_function=None)[source]¶
Bases:
BaseImageReaderBufferThis class is to read data from czi files. Masks will be treated as TIFF.
- class PartSegImage.image_reader.GenericImageReader(callback_function=None)[source]¶
Bases:
BaseImageReaderBufferThis class try to decide which method use base on path
- class PartSegImage.image_reader.ObsepImageReader(callback_function=None)[source]¶
Bases:
BaseImageReader
- class PartSegImage.image_reader.OifImagReader(callback_function=None)[source]¶
Bases:
BaseImageReader
- exception PartSegImage.image_reader.TiffFileException[source]¶
Bases:
Exceptionexception raised if reading tiff file fails. Created for distinguish exceptions which should reported as warning message (not for report)
- class PartSegImage.image_reader.TiffImageReader(callback_function=None)[source]¶
Bases:
BaseImageReaderBufferTIFF/LSM files reader. Base reading with
BaseImageReader.read_image()image_file: tifffile.TiffFile mask_file: tifffile.TiffFile
- static decode_int(val)[source]¶
This function split 32 bits int on 4 8-bits ints
- Parameters:
val (
int) – value to decode- Returns:
list of four numbers with values from [0, 255]
- PartSegImage.image_reader.name_to_scalar = {'Es': 1000000000000000000, 'Gs': 1000000000, 'Ms': 1000000, 'Ps': 1000000000000000, 'Ts': 1000000000000, 'Ys': 1000000000000000000000000, 'Zs': 1000000000000000000000, '\\u00B5m': 1e-06, 'as': 1e-18, 'cal': 0.025400000000000002, 'centimeter': 0.01, 'cm': 0.01, 'cs': 0.01, 'd': 86400, 'das': 10, 'ds': 0.1, 'fs': 1e-15, 'h': 3600, 'hs': 100, 'ks': 1000, 'micron': 1e-06, 'millimeter': 0.001, 'min': 60, 'mm': 0.001, 'ms': 0.001, 'nanometer': 1e-09, 'nm': 1e-09, 'ns': 1e-09, 'picometer': 1e-24, 'pm': 1e-12, 'ps': 1e-12, 's': 1, 'um': 1e-06, 'ys': 1e-24, 'zs': 1e-21, 'µm': 1e-06, 'µs': 1e-06}¶
dict with known names of scalar to scalar value. Some may be missed