webknossos.dataset.layer
Getter for dictionary containing all mags.
Returns the MagView
called mag
of this layer. The return type is webknossos.dataset.mag_view.MagView
.
This function raises an IndexError
if the specified mag
does not exist.
Deprecated, please use get_finest_mag
.
Creates a new mag called and adds it to the layer.
The parameter chunk_shape
, chunks_per_shard
and compress
can be
specified to adjust how the data is stored on disk.
Note that writing compressed data which is not aligned with the blocks on disk may result in
diminished performance, as full blocks will automatically be read to pad the write actions. Alternatively,
you can call mag.compress() after all the data was written
The return type is webknossos.dataset.mag_view.MagView
.
Raises an IndexError if the specified mag
already exists.
Creates a new mag based on already existing files.
Raises an IndexError if the specified mag
does not exists.
Creates a new mag called and adds it to the dataset, in case it did not exist before. Then, returns the mag.
See add_mag
for more information.
Deletes the MagView from the datasource-properties.json
and the data from disk.
This function raises an IndexError
if the specified mag
does not exist.
Copies the data at foreign_mag_view_or_path
which can belong to another dataset
to the current dataset. Additionally, the relevant information from the
datasource-properties.json
of the other dataset are copied, too.
Creates a symlink to the data at foreign_mag_view_or_path
which belongs to another dataset.
The relevant information from the datasource-properties.json
of the other dataset is copied to this dataset.
Note: If the other dataset modifies its bounding box afterwards, the change does not affect this properties
(or vice versa).
If make_relative is True, the symlink is made relative to the current dataset path.
Symlinked mags can only be added to layers on local file systems.
Copies the data at foreign_mag_view_or_path
which belongs to another dataset to the current dataset via the filesystem.
Additionally, the relevant information from the datasource-properties.json
of the other dataset are copied, too.
Downsamples the data starting from from_mag
until a magnification is >= max(coarsest_mag)
.
There are three different sampling_modes
:
- 'anisotropic' - The next magnification is chosen so that the width, height and depth of a downsampled voxel assimilate. For example, if the z resolution is worse than the x/y resolution, z won't be downsampled in the first downsampling step(s). As a basis for this method, the voxel_size from the datasource-properties.json is used.
- 'isotropic' - Each dimension is downsampled equally.
- 'constant_z' - The x and y dimensions are downsampled equally, but the z dimension remains the same.
See downsample_mag
for more information.
Example:
from webknossos import SamplingModes
# ...
# let 'layer' be a [`Layer`](../../webknossos/dataset/layer.html#Layer) with only `Mag(1)`
assert "1" in self.mags.keys()
layer.downsample(
coarsest_mag=Mag(4),
sampling_mode=SamplingModes.ISOTROPIC
)
assert "2" in self.mags.keys()
assert "4" in self.mags.keys()
Performs a single downsampling step from from_mag
to target_mag
.
The supported interpolation_modes
are:
- "median"
- "mode"
- "nearest"
- "bilinear"
- "bicubic"
If allow_overwrite is True, an existing Mag may be overwritten.
If only_setup_mag is True, the magnification is created, but left empty. This parameter can be used to prepare for parallel downsampling of multiple layers while avoiding parallel writes with outdated updates to the datasource-properties.json file.
executor
can be passed to allow distrubuted computation, parallelizing
across chunks. args
is deprecated.
Use this method to recompute downsampled magnifications after mutating data in the base magnification.
Downsamples the data starting at from_mag
to each magnification in target_mags
iteratively.
See downsample_mag
for more information.
Upsamples the data starting from from_mag
as long as the magnification is >= finest_mag
.
There are three different sampling_modes
:
- 'anisotropic' - The next magnification is chosen so that the width, height and depth of a downsampled voxel assimilate. For example, if the z resolution is worse than the x/y resolution, z won't be downsampled in the first downsampling step(s). As a basis for this method, the voxel_size from the datasource-properties.json is used.
- 'isotropic' - Each dimension is downsampled equally.
- 'constant_z' - The x and y dimensions are downsampled equally, but the z dimension remains the same.
min_mag
is deprecated, please use finest_mag
instead.
Inherited Members
- Layer
- Layer
- path
- name
- dataset
- bounding_box
- dtype_per_layer
- dtype_per_channel
- num_channels
- data_format
- default_view_configuration
- read_only
- mags
- get_mag
- get_finest_mag
- get_best_mag
- add_mag
- add_mag_for_existing_files
- get_or_add_mag
- delete_mag
- add_copy_mag
- add_symlink_mag
- add_fs_copy_mag
- downsample
- downsample_mag
- redownsample
- downsample_mag_list
- upsample