webknossos.dataset.mag_view
A MagView
contains all information about the data of a single magnification of a webknossos.dataset.layer.Layer
.
MagView
inherits from webknossos.dataset.view.View
.
Therefore, the main difference between them is that a MagView
handles the whole magnification,
whereas the View
only handles a sub-region.
A MagView
can read/write outside the specified bounding box (unlike a normal View
).
If necessary, the properties are automatically updated (e.g. if the bounding box changed).
This is possible because a MagView
does have a reference to the webknossos.dataset.layer.Layer
.
The global_offset
of a MagView
is always (0, 0, 0)
and its size
is chosen so that the bounding box from the properties is fully inside this View.
Do not use this constructor manually. Instead use webknossos.dataset.layer.Layer.add_mag()
to create a MagView
.
Writes the data
at the specified offset
to disk (like webknossos.dataset.view.View.write()
).
The offset
refers to the absolute position, regardless of the offset in the properties (because the global_offset is set to (0, 0, 0)).
If the data exceeds the original bounding box, the properties are updated.
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.
Returns a view that is limited to the specified bounding box.
The offset
refers to the absolute position, regardless of the offset in the properties (because the global_offset is set to (0, 0, 0)).
The default value for offset
is the offset that is specified in the properties.
The default value for size
is calculated so that the bounding box ends where the bounding box from the
properties ends.
Therefore, if both (offset
and size
) are not specified, then the bounding box of the view is equal to the
bounding box specified in the properties.
The offset
and size
may only exceed the bounding box from the properties, if read_only
is set to True
.
If read_only
is True
, write operations are not allowed for the returned sub-view.
Example:
# ...
# Let 'mag1' be a `MagView` with offset (0, 0, 0) and size (100, 200, 300)
# Properties are used to determine the default parameter
view_with_bb_from_properties = mag1.get_view()
# Sub-view where the specified bounding box is completely in the bounding box of the MagView
sub_view1 = mag1.get_view(offset=(50, 60, 70), size=(10, 120, 230))
# Fails because the specified view is not completely in the bounding box from the properties.
sub_view2 = mag1.get_view(offset=(50, 60, 70), size=(999, 120, 230), read_only=True)
# Sub-view where the specified bounding box is NOT completely in the bounding box of the MagView.
# This still works because `read_only=True`.
sub_view2 = mag1.get_view(offset=(50, 60, 70), size=(999, 120, 230), read_only=True)
Returns a bounding box for each file on disk. A bounding box is represented as a tuple of the offset and the size.
This differs from the bounding box in the properties in two ways:
- the bounding box in the properties is always specified in mag 1
- the bounding box in the properties is an "overall" bounding box, which abstracts from the files on disk
Compresses the files on disk. This has consequences for writing data (see write
).
The data gets compressed inplace, if target_path is None. Otherwise it is written to target_path/layer_name/mag.