navigate.model.data_sources.tiff_data_source.TiffDataSource
- class navigate.model.data_sources.tiff_data_source.TiffDataSource(file_name: str = '', mode: str = 'w', is_bigtiff: bool = False)
Bases:
DataSourceData source for TIFF files.
- __init__(file_name: str = '', mode: str = 'w', is_bigtiff: bool = False) → None
Initialize a TIFF data source.
- Parameters:
file_name (str) – Path to file.
mode (str) – File mode. “r” for read, “w” for write.
is_bigtiff (bool) – Is this a bigtiff file?
Methods
__init__([file_name, mode, is_bigtiff])Initialize a TIFF data source.
close([internal])Close the file.
generate_image_name(current_channel, ...)Generates a string for the filename, e.g., CH00_000000.tif
get_data([timepoint, position, channel, z, ...])Get data according to timepoint, position, channel and z-axis id
Get the shape of the data source from the metadata.
read()Read a tiff file.
set_bigtiff(is_bigtiff)Set whether this is a bigtiff file.
set_image_format(image_format)Set the confirmed acquisition format before writing the first frame.
set_metadata(metadata_config)Sets the metadata
Sets the metadata from according to the microscope configuration.
setup()Additional steps for establishing the initial file setup.
write(data, **kw)Writes 2D image to the data source.
Attributes
- close(internal=False) → None
Close the file.
- Parameters:
internal (bool) – Internal flag. Do not close if True.
- generate_image_name(current_channel, current_time_point)
Generates a string for the filename, e.g., CH00_000000.tif
- Parameters:
current_channel (int) – Current channel index.
current_time_point (int) – Current time point index.
- Returns:
Image name.
- Return type:
str
- get_data(timepoint: int = 0, position: int = 0, channel: int = 0, z: int = -1, resolution: int = 1) → Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], complex, bytes, str, _NestedSequence[complex | bytes | str]]
Get data according to timepoint, position, channel and z-axis id
- Parameters:
timepoint (int) – The timepoint value
position (int) – The position id in multi-position table
channel (int) – The channel id
z (int) – The index of Z in a Z-stack. Return all z if -1.
resolution (int) – values from 1, 2, 4, 8 Not supported for now.
- Returns:
data – Image data
- Return type:
npt.ArrayLike
- get_shape_from_metadata()
Get the shape of the data source from the metadata.
- read() → None
Read a tiff file.
- set_bigtiff(is_bigtiff: bool) → None
Set whether this is a bigtiff file.
- Parameters:
is_bigtiff (bool) – Is this a bigtiff file?
- set_image_format(image_format: CameraImageFormat) → None
Set the confirmed acquisition format before writing the first frame.
- Parameters:
image_format (CameraImageFormat) – Normalized array dtype and meaningful camera precision.
- set_metadata(metadata_config: dict) → None
Sets the metadata
- Parameters:
metadata_config (dict) – shape configuration: “c”, “z”, “t”, “p”, “is_dynamic”, “per_stack”
- set_metadata_from_configuration_experiment(configuration: Dict[str, Any], microscope_name: str = None) → None
Sets the metadata from according to the microscope configuration.
- Parameters:
configuration (Dict[str, Any]) – Configuration experiment.
microscope_name (str) – The microscope name
- setup()
Additional steps for establishing the initial file setup.
- write(data: Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], complex, bytes, str, _NestedSequence[complex | bytes | str]], **kw) → None
Writes 2D image to the data source.
One channel, all z-position, one timepoint = one stack. N channels are opened simultaneously for writing. At each time point, a new file is opened for each channel.
- Parameters:
data (npt.ArrayLike) – Data to write to file.
kw (dict) – Keyword arguments to pass to tifffile.imwrite.
- bits
Number of bits per pixel.
- Type:
int
- property data: Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], complex, bytes, str, _NestedSequence[complex | bytes | str]]
Return the image data as a numpy array.
- Returns:
Image data.
- Return type:
npt.ArrayLike
- dc
Step size between channels (always 1)
- Type:
float
- dt
The time interval between frames (seconds).
- Type:
float
- dx
Pixel size in x dimension (microns). float: Pixel size in y dimension (microns). float: Pixel size in z dimension (microns).
- Type:
float
- dy
Pixel size in x dimension (microns). float: Pixel size in y dimension (microns). float: Pixel size in z dimension (microns).
- Type:
float
- dz
Pixel size in x dimension (microns). float: Pixel size in y dimension (microns). float: Pixel size in z dimension (microns).
- Type:
float
- file_name
Name of the file to read/write from.
- Type:
str
- image
Image data
- Type:
np.ndarray
- property is_bigtiff: bool
Is this a bigtiff file?
- Returns:
Is this a bigtiff file?
- Return type:
bool
- property is_ome: bool
Is this an OME-TIFF file?
- Returns:
Is this an OME-TIFF file?
- Return type:
bool
- logger
Logger for this class.
- Type:
logging.Logger
- property mode: str
Getter for the mode of the data source.
- Returns:
Mode of the data source.
- Return type:
str
- property nbytes: int
Getter for the size of this data source in bytes.
Does not account for pyramidal data sources. That process is handled by the bdv_data_source class, which is a child of this class.
- Returns:
total_bytes – Size of this data source in bytes.
- Return type:
int
- positions
Number of positions in the data source.
- Type:
int
- save_directory
Directory to save the data to.
- Type:
str
- property shape: tuple
Getter for the shape as XYCZT.
- Returns:
Shape of the data source in XYCZT format.
- Return type:
tuple
- shape_c
Size of the data source in c dimension.
- Type:
int
- shape_t
Size of the data source in t dimension.
- Type:
int
- shape_x
Size of the data source in x dimension.
- Type:
int
- shape_y
Size of the data source in y dimension.
- Type:
int
- shape_z
Size of the data source in z dimension.
- Type:
int
- significant_bits
Confirmed camera precision, separate from storage width.
- Type:
int or None
- property voxel_size: tuple
Getter for the voxel size
- Returns:
Voxel size in x, y, z dimensions.
- Return type:
tuple