jnormcorre.utils package

Submodules

jnormcorre.utils.lazy_array module

class jnormcorre.utils.lazy_array.lazy_data_loader[source]

Bases: ABC

This captures the numpy array-like functionality that all data loaders for motion correction need to contain

Key: To implement support for a new file type, you just need to specify the key properties below (dtype, shape, ndim) and then implement the function _compute_at_indices. Adapted from mesmerize core: https://github.com/nel-lab/mesmerize-core/blob/master/mesmerize_core/arrays/_base.py

abstract property dtype: str

data type

property ndim: int

Number of dimensions

abstract property shape: Tuple[int, int, int]

Array shape (n_frames, dims_x, dims_y)

jnormcorre.utils.registrationarrays module

class jnormcorre.utils.registrationarrays.FilteredArray(raw_data_loader: lazy_data_loader, filter_function: Callable, batching: int = 100)[source]

Bases: lazy_data_loader

__init__(raw_data_loader: lazy_data_loader, filter_function: Callable, batching: int = 100)[source]

Class for loading and filtering data; this is broadly useful because we often want to spatially filter data to expose salient signals. We use this filtered version of the data to estimate shifts :param raw_data_loader: An object that supports the lazy_data_loader interface.

This can be for e.g. a custom object that reads data from disk, an array in RAM (like a numpy ndarray) or anything else

Parameters:
  • filter_function (Callable) – A function that applies a spatial filter to every frame of a data array. It takes an input movie of shape (frames, fov dim 1, fov dim 2) and returns a filtered movie of the same shape. The type of the output is cast to numpy array in this function.

  • batching (int) – Max number of frames we process on GPU at a time, used to avoid OOM errors.

property batching
property dtype: str

data type

property filter_function: Callable
property ndim: int

Number of dimensions

property raw_data_loader: lazy_data_loader
property shape: Tuple[int, int, int]

Array shape (n_frames, dims_x, dims_y)

class jnormcorre.utils.registrationarrays.Hdf5Array(filename: str, field: str)[source]

Bases: lazy_data_loader

__init__(filename: str, field: str) None[source]

Generic lazy loader for Hdf5 files video files, where data is stored as (T, x, y). T is number of frames, x and y are the field of view dimensions (height and width).

Parameters:
  • filename (str) – Path to filename

  • field (str) – Field of hdf5 file containing data

property dtype: str

str data type

property ndim: int

int Number of dimensions

property shape: Tuple[int, int, int]

Tuple[int] (n_frames, dims_x, dims_y)

class jnormcorre.utils.registrationarrays.RegistrationArray(registration_obj: FrameCorrector, data_to_register: lazy_data_loader, pw_rigid=False, reference_data: lazy_data_loader | None = None)[source]

Bases: lazy_data_loader

__init__(registration_obj: FrameCorrector, data_to_register: lazy_data_loader, pw_rigid=False, reference_data: lazy_data_loader | None = None)[source]

Class for registering 2D functional imaging data on the fly. Useful for visualization libraries etc.

Parameters:
  • registration_obj (jnormcorre.motion_correction.FrameCorrector) – Object which can perform registration

  • data_to_register (jnormcorre.utils.lazy_array.lazy_data_loader) – Data loading object

  • pw_rigid (bool) – Indicates whether we apply rigid or piecewise rigid registration to frames

  • [Optional (reference_data) – A reference stack. If provided, the algorithm will find optimal alignment between template and each frame of this stack. It will then apply these shifts to “data_to_register”

property batching
property dtype

data type

property ndim

Number of dimensions

property shape

Array shape (n_frames, dims_x, dims_y)

property template: ndarray

The template used for registration

class jnormcorre.utils.registrationarrays.TiffArray(filename)[source]

Bases: lazy_data_loader

__init__(filename)[source]

TiffArray data loading object. Supports loading data from multipage tiff files.

Parameters:

filename (str) – Path to file

property dtype: str

str data type

property ndim: int

int Number of dimensions

property shape: Tuple[int, int, int]

Tuple[int] (n_frames, dims_x, dims_y)

Module contents