fissa.extraction module#
DataHandler classes to handle and manipulate image and ROI objects.
- Authors:
Sander W Keemink <swkeemink@scimail.eu>
Scott C Lowe <scott.code.lowe@gmail.com>
- class fissa.extraction.DataHandlerAbstract[source]#
Bases:
abc.ABC
Abstract class for a data handler.
See also
Methods
extracttraces
(masks)Extract from data the average signal within each mask, across time.
Determine the shape of each frame within the recording.
getmean
()Determine the mean image across all frames.
Load data (from a path) as an array, or similar internal structure.
rois2masks
(rois, data)Convert ROIs into a collection of binary masks.
- abstract extracttraces(masks)[source]#
Extract from data the average signal within each mask, across time.
Must return a 2D
numpy.ndarray
.- Parameters
- datadata_type
The same object as returned by
image2array()
.- masksmask_type
The same object as returned by
rois2masks()
.
- Returns
- tracesnumpy.ndarray
Trace for each mask, shaped
(len(masks), n_frames)
.
- abstract get_frame_size()[source]#
Determine the shape of each frame within the recording.
- Parameters
- datadata_type
The same object as returned by
image2array()
.
- Returns
- shapetuple of ints
The 2D, y-by-x, shape of each frame in the movie.
- abstract getmean()[source]#
Determine the mean image across all frames.
Must return a 2D
numpy.ndarray
.- Parameters
- datadata_type
The same object as returned by
image2array()
.
- Returns
- meannumpy.ndarray
Mean image as a 2D, y-by-x, array.
- abstract image2array()[source]#
Load data (from a path) as an array, or similar internal structure.
- Parameters
- imageimage_type
Some handle to, or representation of, the raw imagery data.
- Returns
- datadata_type
Internal representation of the images which will be used by all the other methods in this class.
- classmethod rois2masks(rois, data)[source]#
Convert ROIs into a collection of binary masks.
- Parameters
- roisstr or list of array_like
Either a string containing a path to an ImageJ roi zip file, or a list of arrays encoding polygons, or list of binary arrays representing masks.
- datadata_type
The same object as returned by
image2array()
.
- Returns
- masksmask_type
Masks, in a format accepted by
extracttraces()
.
- class fissa.extraction.DataHandlerPillow[source]#
Bases:
fissa.extraction.DataHandlerAbstract
Extract data from TIFF images frame-by-frame using Pillow (
PIL.Image
).Slower, but less memory-intensive than
DataHandlerTifffile
.Methods
extracttraces
(data, masks)Extract the average signal within each mask across the data.
get_frame_size
(data)Determine the shape of each frame within the recording.
getmean
(data)Determine the mean image across all frames.
image2array
(image)Open an image file as a
PIL.Image
instance.rois2masks
(rois, data)Convert ROIs into a collection of binary masks.
- static extracttraces(data, masks)[source]#
Extract the average signal within each mask across the data.
- Parameters
- dataPIL.Image
An open
PIL.Image
handle to a multi-frame TIFF image.- maskslist of array_like
List of binary arrays.
- Returns
- tracesnumpy.ndarray
Trace for each mask, shaped
(len(masks), n_frames)
.
- static get_frame_size(data)[source]#
Determine the shape of each frame within the recording.
- Parameters
- dataPIL.Image
An open
PIL.Image
handle to a multi-frame TIFF image.
- Returns
- shapetuple of ints
The 2D, y-by-x, shape of each frame in the movie.
- static getmean(data)[source]#
Determine the mean image across all frames.
- Parameters
- dataPIL.Image
An open
PIL.Image
handle to a multi-frame TIFF image.
- Returns
- meannumpy.ndarray
y-by-x array for the mean values.
- static image2array(image)[source]#
Open an image file as a
PIL.Image
instance.- Parameters
- imagestr or file
A filename (string) of a TIFF image file, a
pathlib.Path
object, or a file object.
- Returns
- dataPIL.Image
Handle from which frames can be loaded.
- class fissa.extraction.DataHandlerTifffile[source]#
Bases:
fissa.extraction.DataHandlerAbstract
Extract data from TIFF images using tifffile.
Methods
extracttraces
(data, masks)Extract a temporal trace for each spatial mask.
get_frame_size
(data)Determine the shape of each frame within the recording.
getmean
(data)Determine the mean image across all frames.
image2array
(image)Load a TIFF image from disk.
rois2masks
(rois, data)Convert ROIs into a collection of binary masks.
- static extracttraces(data, masks)[source]#
Extract a temporal trace for each spatial mask.
- Parameters
- dataarray_like
Data array as made by
image2array()
, shaped(frames, y, x)
.- masks
list
of array_like List of binary arrays.
- Returns
- tracesnumpy.ndarray
Trace for each mask, shaped
(len(masks), n_frames)
.
- static get_frame_size(data)[source]#
Determine the shape of each frame within the recording.
- Parameters
- datadata_type
The same object as returned by
image2array()
.
- Returns
- shapetuple of ints
The 2D, y-by-x, shape of each frame in the movie.
- static getmean(data)[source]#
Determine the mean image across all frames.
- Parameters
- dataarray_like
Data array as made by
image2array()
, shaped(frames, y, x)
.
- Returns
- numpy.ndarray
y by x array for the mean values
- static image2array(image)[source]#
Load a TIFF image from disk.
- Parameters
- imagestr or array_like shaped (time, height, width)
Either a path to a TIFF file, or array_like data.
- Returns
- numpy.ndarray
A 3D array containing the data, with dimensions corresponding to
(frames, y_coordinate, x_coordinate)
.
- class fissa.extraction.DataHandlerTifffileLazy[source]#
Bases:
fissa.extraction.DataHandlerAbstract
Extract data from TIFF images using tifffile, with lazy loading.
Methods
extracttraces
(data, masks)Extract a temporal trace for each spatial mask.
get_frame_size
(data)Determine the shape of each frame within the recording.
getmean
(data)Determine the mean image across all frames.
image2array
(image)Load a TIFF image from disk.
rois2masks
(rois, data)Convert ROIs into a collection of binary masks.
- static extracttraces(data, masks)[source]#
Extract a temporal trace for each spatial mask.
- Parameters
- datatifffile.TiffFile
Open tifffile.TiffFile object.
- maskslist of array_like
List of binary arrays.
- Returns
- tracesnumpy.ndarray
Trace for each mask, shaped
(len(masks), n_frames)
.
- static get_frame_size(data)[source]#
Determine the shape of each frame within the recording.
- Parameters
- datadata_type
The same object as returned by
image2array()
.
- Returns
- shapetuple of ints
The 2D, y-by-x, shape of each frame in the movie.