Zarr config
linc_convert.utils.zarr_config ¶
Configuration related to output Zarr Archive.
ZarrConfig
dataclass
¶
ZarrConfig(zarr_version=3, chunk=(128,), chunk_channels=False, chunk_time=True, shard=None, shard_channels=False, shard_time=False, dimension_separator='/', order='C', compressor='blosc', compressor_opt=dict(), no_time=False, no_pyramid_axis=None, levels=-1, ome_version='0.4', overwrite=False, driver='zarr-python')
Configuration related to output Zarr Archive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
tuple[int]
|
Output chunk size.
Behavior depends on the number of values provided:
* one: used for all spatial dimensions
* three: used for spatial dimensions ([z, y, x])
* four+: used for channels and spatial dimensions ([c, z, y, x])
If |
(128,)
|
zarr_version
|
Literal[2, 3]
|
Zarr version to use. If |
3
|
chunk_channels
|
bool
|
Put channels in different chunk. If False, combine all channels in a single chunk. |
False
|
chunk_time
|
bool
|
Put timepoints in different chunk. If False, combine all timepoints in a single chunk. |
True
|
shard
|
tuple[int] | Literal['auto'] | None
|
Output shard size.
Behavior same as chunk.
If |
None
|
shard_channels
|
bool
|
Put channels in different shards. If False, combine all channels in a single shard. |
False
|
shard_time
|
bool
|
Put timepoints in different shards. If False, combine all timepoints in a single shard. |
False
|
dimension_separator
|
Literal['.', '/']
|
The separator placed between the dimensions of a chunk. |
'/'
|
order
|
Literal['C', 'F']
|
Memory layout order for the data array. |
'C'
|
compressor
|
Literal['blosc', 'zlib', 'none']
|
Compression method |
'blosc'
|
compressor_opt
|
dict[str, float | str]
|
Compression options |
dict()
|
no_time
|
bool
|
If True, indicates that the dataset does not have a time dimension. In such cases, any fourth dimension is interpreted as the channel dimension. |
False
|
no_pyramid_axis
|
Literal['x', 'y', 'z'] | None
|
Spatial axis that should not be downsampled when generating pyramid levels. If None, downsampling is applied across all spatial axes. |
None
|
levels
|
int
|
Number of pyramid levels to generate. If set to -1, all possible levels are generated until the smallest level fits into one chunk. |
-1
|
ome_version
|
Literal['0.4', '0.5']
|
Version of the OME-Zarr specification to use |
'0.4'
|
overwrite
|
bool
|
when no name is supplied and using default output name, if overwrite is set, it won't ask if overwrite |
False
|
driver
|
(zarr - python, tensorstore, zarrita)
|
library used for Zarr IO Operation |
"zarr-python"
|
__post_init__ ¶
__post_init__()
Perform post-initialization checks and adjustments.
- Ensure that sharding options (shard, shard_channels, shard_time) are only used when zarr_version == 3; otherwise raise NotImplementedError.
GeneralConfig
dataclass
¶
GeneralConfig(out=None, max_load=1024, log_level='info', verbose=False)
General configuration for the conversion process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out
|
str | None
|
Output path for the converted data. |
None
|
max_load
|
int
|
Maximum number of items to load into memory at once. |
1024
|
log_level
|
(debug, info, warning, error, critical)
|
Logging level for the conversion process. |
"debug"
|
verbose
|
bool
|
If True, set log_level to "debug". |
False
|
__post_init__ ¶
__post_init__()
Perform post-initialization checks and adjustments.
- Ensure that max_load is a positive integer; otherwise raise ValueError.
- If verbose is True, set log_level to "debug".
set_default_name ¶
set_default_name(name, nii=True)
Assign a default output name if none was specified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Base filename (without extension) to use for the output archive. |
required |
nii
|
bool
|
If True, the output will be in NIfTI-Zarr format (with |
True
|
Returns:
| Type | Description |
|---|---|
None
|
|
--------
|
|
- If `self.out` is already set, does nothing.
|
|
- Otherwise sets `self.out` to `name + ".nii.zarr"` if NIfTI mode
|
is active, or |
- If the resulting path exists and `overwrite` is False, prompts
|
the user for confirmation and raises FileExistsError if not confirmed. |
NiftiConfig
dataclass
¶
NiftiConfig(nii=True, orientation='RAS', center=True, nifti_header=None)
Configuration related to output nifti-zarr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nii
|
bool
|
Convert the output to nifti-zarr format. This is automatically enabled if the output path ends with ".nii.zarr". |
True
|
orientation
|
str
|
Orientation of the slice |
'RAS'
|
center
|
bool
|
Set RAS[0, 0, 0] at FOV center |
True
|
nifti_header
|
PathLike[str] | str | None
|
Path to the nifti header file to use. Can be a .nii[.gz] file, a binary header file, or a .nii.zarr archive. |
None
|
Orientation
The anatomical orientation of the slice is given in terms of RAS axes.
It is a combination of two letters from the set
{"L", "R", "A", "P", "I", "S"}, where
- the first letter corresponds to the horizontal dimension and indicates the anatomical meaning of the right of the input image,
- the second letter corresponds to the vertical dimension and indicates the anatomical meaning of the bottom of the input image.
- the third letter corresponds to the slice dimension and indicates the anatomical meaning of the end of the volume.
We also provide the aliases
"coronal"=="LI""axial"=="LP""sagittal"=="PI"
When the aliases are used, the third dimension will be popped from "RAS"
autoconfig ¶
autoconfig(func)
Use as @autoconfig only. Infers config params from dataclass annotations.