acia.segm.local#

Local segmentation functionality dealing with files from HDD.

acia.segm.local.list_sequence_sources(folder, pattern='*.tif', storage_options=None, recursive=False, **kwargs)[source]#

Discover image stacks in a folder and return one source per file.

Works for a local directory or any fsspec URL (e.g. an smb:// share), using the same credential resolution as the sources themselves: credentials for the listing are looked up by host in the acia config (see acia.config) and can be overridden via storage_options.

Parameters:
  • folder (str) – directory to scan. A plain local path or an fsspec URL, e.g. "/data/experiments" or "smb://fileserver.lab/data/exp".

  • pattern (str) – glob pattern for the file names. Defaults to "*.tif".

  • storage_options (dict, optional) – extra fsspec options (e.g. credentials) merged on top of the config entry for the folder’s host.

  • recursive (bool) – if True, search sub-folders too (** glob).

  • **kwargs – forwarded to each LocalSequenceSource (e.g. normalize_image, luts, channel_index).

Returns:

list[LocalSequenceSource] – one source per matching file, sorted by path.

Return type:

list[LocalSequenceSource]

acia.segm.local.prepare_image(image, normalize_image=True)[source]#

Normalize and convert image to RGB, or preserve it as raw data.

Parameters:
  • image ([type]) – [description]

  • normalize_image (bool, optional) – Whether to normalize the image into uint8 domain (0-255) and (for a 2D frame) artificially triplicate it to 3 channels for display. Defaults to True. When False, the original dtype/intensity is preserved; a genuinely 2D frame only gains a trailing singleton channel axis (matching the raw-frame convention used by ND2SequenceSource/CZISequenceSource), no triplication.

Returns:

[np.array]

RGB image (Width, height, 3 color channels) if normalize_image,

otherwise the original data with a channel axis.

class acia.segm.local.LocalImage[source]#

Bases: BaseImage

Class for a single image

__init__(content, frame=None)[source]#
property raw#
property num_channels#
get_channel(channel)[source]#
Parameters:

channel (int)

class acia.segm.local.LocalImageSource[source]#

Bases: ImageSequenceSource, JupyterVisualizationMixin

Source for a single image only

__init__(image)[source]#
Parameters:

image (LocalImage)

get_frame(frame)[source]#

Get frame at given index.

Parameters:

frame (int)

property num_channels: int#
property num_frames: int#
property size_t: int#
static from_file(file_path, normalize_image=True)[source]#
Parameters:

file_path (str)

static from_array(array)[source]#
class acia.segm.local.InMemorySequenceSource[source]#

Bases: ImageSequenceSource, JupyterVisualizationMixin

Image sequence for an in memory image stack

__init__(image_stack, frame_interval=None, timepoints=None, pixel_size=None)[source]#
get_frame(frame)[source]#

Get frame at given index.

Parameters:

frame (int)

Return type:

BaseImage

property size_t: int#
property num_channels: int#
class acia.segm.local.THWCSequenceSource[source]#

Bases: ImageSequenceSource, JupyterVisualizationMixin

Image sequence for an in memory image stack [TxHxWxC]

__init__(image_stack, frame_interval=None, timepoints=None, pixel_size=None)[source]#
Parameters:

image_stack (ndarray)

get_frame(frame)[source]#

Get frame at given index.

Parameters:

frame (int)

Return type:

BaseImage

property num_channels: int#
property size_c: int#

Returns: int: size of the C dimension

property size_t: int#

Returns: int: size of the T dimension

property size_h: int#

Returns: int: size of the C dimension

property size_w: int#

Returns: int: size of the T dimension

to_channel(c)[source]#

Converts multi-channel source into single-channel source

Parameters:

c (int) – the channel to use

Returns:

THWCSequenceSource – sequence with the single channel

Return type:

THWCSequenceSource

class acia.segm.local.LocalSequenceSource[source]#

Bases: ImageSequenceSource, JupyterVisualizationMixin

Image sequence source for files in the local file system (e.g. a tif).

__init__(tif_file, normalize_image=True, luts=None, channel_index=0, storage_options=None, frame_interval=None, timepoints=None, pixel_size=None)[source]#

Create a new local image source

Parameters:
  • tif_file (str) – path to the image file. May be a plain local path or any fsspec-supported URL (e.g. smb://, s3://, http://).

  • normalize_image (bool, optional) – Normalizes the image pixels t0 [0, 255]. Defaults to True.

  • luts – (List, optional): List of lut functions applied to the channels

  • channel_index (int, optional) – index in image of the channel. For example, for H,W,C dims where C is channel we should have a 2.

  • storage_options (dict, optional) – extra fsspec storage options (e.g. credentials) for remote URLs. Merged on top of any matching entry in the acia credentials config (see acia.config).

  • frame_interval – scalar time between frames (pint Quantity or str like "15 minute"); overrides any value read from the file’s own OME-XML/ImageJ metadata. None (default) resolves it from the file lazily, on first access to a calibration property.

  • timepoints – explicit per-frame timepoints (pint Quantity array); same override-vs-auto-detect behavior as frame_interval.

  • pixel_size – physical pixel size (pint length per pixel) for spatial calibration; same override-vs-auto-detect behavior.

property pixel_size#

user override, else auto-read, else None.

Type:

Pint length per pixel

property timepoints#

user override, else auto-read, else None.

Type:

Per-frame pint timepoints

property calibration_source: str | None#

"ome", "imagej", or None (either nothing was auto-detected, or every field was user-supplied so no file read happened).

Type:

Where auto-detected calibration came from

close()[source]#

Release the cached decoded stack (the source stays usable).

Return type:

None

get_frame(frame)[source]#

Get frame at given index.

Parameters:

frame (int)

Return type:

BaseImage

property size_t#
property num_channels: int#
slice(start, end)[source]#

Return a view over frames [start:end).

Kept for backward compatibility; equivalent to self[start:end].

class acia.segm.local.SambaSequenceSource[source]#

Bases: LocalSequenceSource

Image sequence source for TIFFs on an SMB/SAMBA share (via fsspec).

This is a thin convenience wrapper around LocalSequenceSource: it builds the smb:// URL and forwards credentials as fsspec storage options. All reading, iteration and visualization logic is inherited.

Credentials are optional. If username/password (etc.) are omitted, they are looked up in the acia credentials config by host (see acia.config), so regular usage needs no secrets in code. Any value passed explicitly here overrides the config.

__init__(host, share, path, username=None, password=None, domain=None, port=None, **kwargs)[source]#

Create a new SAMBA/SMB image source.

Parameters:
  • host (str) – SMB server host name or IP.

  • share (str) – name of the share.

  • path (str) – path to the image file within the share.

  • username (str, optional) – SMB username. Defaults to config lookup.

  • password (str, optional) – SMB password. Defaults to config lookup.

  • domain (str, optional) – SMB/Windows domain. Defaults to config lookup.

  • port (int, optional) – SMB port. Defaults to the backend default.

  • **kwargs – forwarded to LocalSequenceSource (e.g. normalize_image, luts, channel_index).

classmethod from_url(url, username=None, password=None, domain=None, port=None, **kwargs)[source]#

Create a SambaSequenceSource from a full smb:// URL.

The URL is split into host / share / path, e.g. smb://fileserver.lab/data/exp/img.tif -> host fileserver.lab, share data, path exp/img.tif. Credentials may be embedded in the URL (smb://user:pass@host/share/...) or passed as keyword arguments; anything omitted is resolved from the acia credentials config.

Parameters:
  • url (str) – an smb:// URL pointing at the image file.

  • username/password/domain/port – optional credential overrides.

  • **kwargs – forwarded to LocalSequenceSource.

  • username (str | None)

  • password (str | None)

  • domain (str | None)

  • port (int | None)

Return type:

SambaSequenceSource

class acia.segm.local.ImageJRoISource[source]#

Bases: RoISource

Source fro ImageJ RoI file format

__init__(filename, range=None)[source]#
class acia.segm.local.RoiStorer[source]#

Bases: object

Stores and loads overlay results in the roi format (readable by ImageJ)

static store(overlay, filename, append=False)[source]#

Stores overlay results in the roi format (readable by fiji)

overlay: the overlay to store filename: filename of the roi collection (e.g. rois.zip) append: appends the rois if the file already exists

Parameters:
static load(filename)[source]#
Parameters:

filename (str)