Commit 10389fb
ENH: Support 5D files in NRRD IO
Several modern imaging devices and processing algorithms now creates 5D data sets, including:
- time sequence of 3D displacement fields (result of deformable registration of 4D images)
- time sequence of 3D velocity fields (acquired by 4D MRI flow images)
- time sequence of 3D color (RGB or RGBA) images (result of colorized volumes provided by AI segmentation)
NRRD IO can now read and write all these data types, and in general any 5D arrays (2 or 3 spatial dimensions + scalar/vector pixel type + optional list axis).
1. Writing
Previously the NRRD writer handled one component axis, and all the other dimensions were space.
This commit allows specifying one of the axes as list (by setting "NRRD_kinds[i]=list" metadata key).
Example:
File header before this commit:
dimension: 5
space dimension: 4
sizes: 4 320 320 1 5
space directions: none (1,0,0,0) (0,1,0,0) (0,0,1,0) (0,0,0,1)
kinds: RGBA-color domain domain domain domain
encoding: gzip
space origin: (0,0,0,1)
File header after this commit:
dimension: 5
space: left-posterior-superior
sizes: 4 320 320 1 5
space directions: none (-1,0,0) (0,-1,0) (0,0,1) none
kinds: vector domain domain domain list
encoding: gzip
space origin: (0,0,0)
2. Reading
NRRD IO now allows having more than one non-spatial axis.
The non-spatial axes of the NRRD file can be used in the ITK image as pixel components or as additional image dimensions.
The default strategy (UseAnyRangeAxisAsPixel) implements the same behavior as before (first non-spatial NRRD axis always becomes pixel component).
The new UseNonListRangeAxisAsPixel option allows "list" dimension (e.g., time points) to always mapped to additional image dimension.
This new option simplifies application implementation, as time sequences are loaded the same way for scalar and vector volumes.
3. Add support for axis unit in NRRD IO; Save label and unit for range axis
NRRD IO did not support the "units" metadata for axes, now it is added both for reading and writing.
Per-axis metadata (kinds, labels, units) was only saved for spatial axes, now it is added for all axes.
For pixel components, "pixel" is used instead of axis ("NRRD_labels[pixel]" and "NRRD_units[pixel]" fields).
Added many tests for reading/writing 3D, 4D, 5D images in NRRD format.
Co-authored-by: Andras Lasso <[email protected]>1 parent a0cf385 commit 10389fb
File tree
8 files changed
+1355
-239
lines changed- Modules/IO/NRRD
- include
- src
- test
- wrapping
- Testing/Data/Input
8 files changed
+1355
-239
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
30 | 53 | | |
31 | 54 | | |
32 | 55 | | |
| |||
109 | 132 | | |
110 | 133 | | |
111 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
112 | 202 | | |
113 | 203 | | |
114 | 204 | | |
| |||
127 | 217 | | |
128 | 218 | | |
129 | 219 | | |
| 220 | + | |
| 221 | + | |
130 | 222 | | |
131 | 223 | | |
132 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
0 commit comments