delta.utilities.xpreader

class delta.utilities.xpreader(filename=None, channelnames: Optional[Tuple[str]] = None, use_bioformats: bool = False, prototype: Optional[str] = None, fileorder: str = 'pct', filenamesindexing: int = 1, watchfiles: bool = False)

Class to read experiment files from bioformats-compatible files or from file sequences in folders

__init__(filename=None, channelnames: Optional[Tuple[str]] = None, use_bioformats: bool = False, prototype: Optional[str] = None, fileorder: str = 'pct', filenamesindexing: int = 1, watchfiles: bool = False)

Initialize experiment reader

Parameters
filenameString or None

Path to experiment file or directory. If the path leads to a directory, the experiment folder is expected to contain exclusively single-page tif images. If None, an interactive selection dialog will be used. If no prototype is provided, the filenames are expected to be of the following C-style format: %s%d%s%d%s%d.tif, with the 3 %d digit strings being zero-padded decimal representation of the position, channel and frame/timepoint number of each image file. Valid examples:

Pos01_Cha3_Fra0005.tif p3c1t034.tif xy 145 - fluo 029 - timepoint 005935 .TIFF

channelnamesList/tuple of strings or None, optional

Names of the acquisition channels (‘trans’, ‘gfp’, …). The default is None.

use_bioformatsbool, optional

Flag to use the bioformats reader. The default is False.

prototype: string, optional

Filename prototype to use when reading single-page tif images from a sequence folder, in C-style formatting. Folder separators can be used. If None, the prototype will be estimated from the first tif file in the folder. For example, an experiment from micromanager can be processed with prototype = ‘Pos%01d/img_channel%03d_position%03d_time%09d_z000.tif’ and fileorder = ‘pcpt’ and filenamesindexing = 0 The default is None.

fileorder: string, optional

Order of the numbers in the prototype, with ‘p’ for positions/ series, ‘c’ for imaging channels, and ‘t’ for timepoints/frames. For example ‘pct’ indicates that the first number is going to be positions, then channels, then timepoints. You can use the same letter multiple times, like ‘pcpt’. The default is ‘pct’

filenamesindexing = int

Selects between 0-based or 1-based indexing in the filename. If 1, position 0 will be referenced as position 1 in the filename. The default is 1

Returns
None.
Raises
ValueError

If the filenames in the experimental directory do not follow the correct format, a ValueError will be raised.

Attributes

filename

File or folder name for the experiment

use_bioformats

Flag to use the Bio-Formats library to read file

fileorder

File ordering (if image files sequence)

filenamesindexing

File indexing start (if image files sequence)

prototype

File name prototype (if image files sequence)

filetype

Type / extension of filehandle

filehandle

Handle to file reader or base directory

positions

Number of positions in experiment

channels

Number of imaging channels

x

Size of images along X axis

y

Size of images along Y axis

dtype

Datatype of images

channelnames

Names of the imaging channels (optional)

Methods

__init__([filename, channelnames, ...])

Initialize experiment reader

close()

getfilenamefromprototype(position, channel, ...)

Generate full filename for specific frame based on file path, prototype, fileorder, and filenamesindexing

getframes([positions, channels, frames, ...])

Get frames from experiment.