@@ -83,6 +83,58 @@ DataTree('multiscales', parent=None)
8383 image (y, x) uint8 dask.array<chunksize=(16, 16), meta=np.ndarray>
8484```
8585
86+ Map a function over datasets while skipping nodes that do not contain dimensions
87+
88+ ``` python
89+ import numpy as np
90+ from spatial_image import to_spatial_image
91+ from multiscale_spatial_image import skip_non_dimension_nodes, to_multiscale
92+
93+ data = np.zeros((2 , 200 , 200 ))
94+ dims = (" c" , " y" , " x" )
95+ scale_factors = [2 , 2 ]
96+ image = to_spatial_image(array_like = data, dims = dims)
97+ multiscale = to_multiscale(image, scale_factors = scale_factors)
98+
99+ @skip_non_dimension_nodes
100+ def transpose (ds , * args , ** kwargs ):
101+ return ds.transpose(* args, ** kwargs)
102+
103+ multiscale = multiscale.map_over_datasets(transpose, " y" , " x" , " c" )
104+ print (multiscale)
105+ ```
106+
107+ A transposed MultiscaleSpatialImage.
108+
109+ ```
110+ <xarray.DataTree>
111+ Group: /
112+ ├── Group: /scale0
113+ │ Dimensions: (c: 2, y: 200, x: 200)
114+ │ Coordinates:
115+ │ * c (c) int32 8B 0 1
116+ │ * y (y) float64 2kB 0.0 1.0 2.0 3.0 4.0 ... 196.0 197.0 198.0 199.0
117+ │ * x (x) float64 2kB 0.0 1.0 2.0 3.0 4.0 ... 196.0 197.0 198.0 199.0
118+ │ Data variables:
119+ │ image (y, x, c) float64 640kB dask.array<chunksize=(200, 200, 2), meta=np.ndarray>
120+ ├── Group: /scale1
121+ │ Dimensions: (c: 2, y: 100, x: 100)
122+ │ Coordinates:
123+ │ * c (c) int32 8B 0 1
124+ │ * y (y) float64 800B 0.5 2.5 4.5 6.5 8.5 ... 192.5 194.5 196.5 198.5
125+ │ * x (x) float64 800B 0.5 2.5 4.5 6.5 8.5 ... 192.5 194.5 196.5 198.5
126+ │ Data variables:
127+ │ image (y, x, c) float64 160kB dask.array<chunksize=(100, 100, 2), meta=np.ndarray>
128+ └── Group: /scale2
129+ Dimensions: (c: 2, y: 50, x: 50)
130+ Coordinates:
131+ * c (c) int32 8B 0 1
132+ * y (y) float64 400B 1.5 5.5 9.5 13.5 17.5 ... 185.5 189.5 193.5 197.5
133+ * x (x) float64 400B 1.5 5.5 9.5 13.5 17.5 ... 185.5 189.5 193.5 197.5
134+ Data variables:
135+ image (y, x, c) float64 40kB dask.array<chunksize=(50, 50, 2), meta=np.ndarray>
136+ ```
137+
86138Store as an Open Microscopy Environment-Next Generation File Format ([ OME-NGFF] )
87139/ [ netCDF] [ Zarr] store.
88140
0 commit comments