-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Started debuging for reading nd datasets. * Implementation of VecNInt and NDBoundingBox. * Rename VecInt and fix some issues. * Work on import of existing zarr dataset. * Add nd_bounding_box to properties of Layer. * Update hooks in properties.py to make import of 4d zarr datasets possible. * Add axis_order and index of additional axes to nd_bounding box creation. * Working on reading nd data with pims images. * Modify pims images to support more _iter_dims. * Add method for expected bounding box instead of expected shape in pims images. * Adding functions for editing ndboundingbox in 3d and update import from_images. * Propagade nd-bounding box to different methods that take care of writing the dataset. * Update object unstructuring for json and start implementing nd array access. * Adapt array classes and add axes information to ArrayInfo. * Updated zarr writing for nd arrays. Axes order still get mixed up between old BoundingBoxes and new NDBoundingBoxes. * Adapted buffered_slice_reader and test behaviour with different tif images. * Adding testdata and fix bugs with axes operation for writing zarr array. * Fixing issues with axis order. * Rewrite buffered_slice_writer and fix bugs to get old tests working. * Fix chunking in buffered slice writer. * Fix issues with old tests. * Working on fixing all tests. * Fixing issues with alignment, writing with offsets and different mags. * Fix reading without parameters for nd datasets and addint test. * Fix issue with empty additionalAxes in json and some minor issues. * Move script reading_nd_data to examples in docs and implement some feedback. * Do some formatting and implement requested changes. * Update naming for accessing attributes of nd bounding boxes. * Fix buffered_slice_writer for different axis and typechecking. * Fix issue with ensure_size in initialization. * Adapt pims_images to support xyz images with channels and timepoint. * run formatter * Fix issues with failed tests and add comments. * Fix statement with wrong VecInt initialization. * Insert previously deleted assertions. * Add docstrings and use bounding box for read in nd case instead of VecInts. * Implement requested changes. * Changes init of NDBoundingBoxes. * Add converter for VecInt attributes of nd bounding box to pass typechecks. * Enhance documentation. * Update Changelog.md
- Loading branch information
Showing
25 changed files
with
2,070 additions
and
668 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Convert 4D Tiff | ||
|
||
This example demonstrates the basic interactions with Datasets that have more than three dimensions. | ||
|
||
In order to manipulate 4D data in WEBKNOSSOS, we first convert the 4D Tiff dataset into a Zarr3 dataset. This conversion is achieved using the [from_images method](../../api/webknossos/dataset/dataset.md#Dataset.from_images). | ||
|
||
Once the dataset is converted, we can access specific layers and views, [read data](../../api/webknossos/dataset/mag_view.md#MagView.read) from a defined bounding box, and [write data](../../api/webknossos/dataset/mag_view.md#MagView.write) to a different position within the dataset. The [NDBoundingBox](../../api/webknossos/geometry/nd_bounding_box.md#NDBoundingBox) is utilized to select a 4D region of the dataset. | ||
|
||
```python | ||
--8<-- | ||
webknossos/examples/convert_4d_tiff.py | ||
--8<-- | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from pathlib import Path | ||
|
||
import webknossos as wk | ||
|
||
|
||
def main() -> None: | ||
# Create a WEBKNOSSOS dataset from a 4D tiff image | ||
dataset = wk.Dataset.from_images( | ||
Path(__file__).parent.parent / "testdata" / "4D" / "4D_series", | ||
"testoutput/4D_series", | ||
voxel_size=(10, 10, 10), | ||
data_format="zarr3", | ||
use_bioformats=True, | ||
) | ||
|
||
# Access the first color layer and the Mag 1 view of this layer | ||
layer = dataset.get_color_layers()[0] | ||
mag_view = layer.get_finest_mag() | ||
|
||
# To get the bounding box of the dataset use layer.bounding_box | ||
# -> NDBoundingBox(topleft=(0, 0, 0, 0), size=(7, 5, 167, 439), axes=('t', 'z', 'y', 'x')) | ||
|
||
# Read all data of the dataset | ||
data = mag_view.read() | ||
# data.shape -> (1, 7, 5, 167, 439) # first value is the channel dimension | ||
|
||
# Read data for a specific time point (t=3) of the dataset | ||
data = mag_view.read( | ||
absolute_bounding_box=layer.bounding_box.with_bounds("t", 3, 1) | ||
) | ||
# data.shape -> (1, 1, 5, 167, 439) | ||
|
||
# Create a NDBoundingBox to read data from a specific region of the dataset | ||
read_bbox = wk.NDBoundingBox( | ||
topleft=(2, 0, 67, 39), | ||
size=(2, 5, 100, 400), | ||
axes=("t", "z", "y", "x"), | ||
index=(1, 2, 3, 4), | ||
) | ||
data = mag_view.read(absolute_bounding_box=read_bbox) | ||
# data.shape -> (1, 2, 5, 100, 400) # first value is the channel dimension | ||
|
||
# Write some data to a given position | ||
mag_view.write(data, absolute_bounding_box=read_bbox.offset((2, 0, 0, 0))) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.