neuralib.scan.core.AbstractScanner

class neuralib.scan.core.AbstractScanner[source]

Bases: object

Abstract Base Class for confocal microscopy image data loaders.

Provides a common interface for accessing metadata and image data from various confocal file formats

__init__(filepath)[source]
Parameters:

filepath (str | Path | PathLike[str])

Methods

__init__(filepath)

close()

Explicitly close any open resources associated with the scanner.

get_channel_names(scene_idx)

Get the names of the fluorescence channels for a specific scene.

view(**kwargs)

view the 2D imaging array.

z_projection(stacks[, project_type, axis])

Computes a z-projection of a stack of images along a specified axis using a chosen method of projection.

Attributes

dimcode

Get dimension code for the image array

filepath

The absolute path to the loaded confocal file.

metadata

Return the metadata dictionary parsed from the file.

n_scenes

Total number of scenes (positions/series) in the file.

__init__(filepath)[source]
Parameters:

filepath (str | Path | PathLike[str])

close()[source]

Explicitly close any open resources associated with the scanner. Subclasses should override this if they open files or other resources.

property filepath: Path

The absolute path to the loaded confocal file.

property metadata: dict[str, Any]

Return the metadata dictionary parsed from the file.

abstract property dimcode: str

Get dimension code for the image array

abstract property n_scenes: int

Total number of scenes (positions/series) in the file.

abstractmethod get_channel_names(scene_idx)[source]

Get the names of the fluorescence channels for a specific scene.

Parameters:

scene_idx (int) – The 0-based index of the scene.

Returns:

A list of strings representing the channel names. Returns generic names (e.g., [‘Channel 1’, ‘Channel 2’]) if specific names are not available.

Raises:

IndexError – If scene_idx is out of bounds.

Return type:

list[str]

abstractmethod view(**kwargs)[source]

view the 2D imaging array. :return: A NumPy image array for view. Array[Any, [X, Y]]

Return type:

ndarray

static z_projection(stacks, project_type='max', axis=0)[source]

Computes a z-projection of a stack of images along a specified axis using a chosen method of projection. The function provides flexibility to select different projection types such as average, maximum, minimum, standard deviation, or median. The default projection type is max.

Parameters:
  • stacks (ndarray) – A multidimensional NumPy array representing the stack of images for z-projection.

  • project_type (Literal['avg', 'max', 'min', 'std', 'median']) – The type of projection to perform. Accepted values are: ‘avg’, ‘max’, ‘min’, ‘std’, or ‘median’. The default is ‘max’.

  • axis (int) – The axis along which the projection will be calculated. This is generally set according to the stack structure. Default is 0.

Returns:

A NumPy array containing the result of the z-projection along the specified axis.

Raises:

ValueError – If the given project_type is not one of the accepted values.

Return type:

ndarray