NRRD
NRRD (Nearly Raw Raster Data)
- 의료 영상(CT, MRI) 분야에서 널리 사용되는 파일 형식
- Raster Data(3D Volume) + Metadata
- Metadata Examples
- Essential:
- Type: Specifies the data type, such as int, float, double, etc.
- Dimension: Specifies the number of dimensions of the data (e.g., 1D, 2D, 3D).
- Sizes: Specifies the size of each dimension in the data.
- Core:
- Encoding: Specifies the encoding method for the data, e.g., raw, gzip, etc.
- Space origin: Provides spatial information about the data, such as the location of the origin in physical space.
- Space directions: Describes the physical spacing and orientation of the data.
- User defined:
- Custom_label: A label created by the user to identify the specific dataset.
- Subject_name: The name or ID of the subject associated with the data.
- Experimental_condition: Additional information about the experimental condition when the data was acquired.
- Essential:
- See source, Nrrd.py
```python
pip install pynrrd
import numpy as np import nrrd
Data creation (this example creates a simple 3D array)
data = np.zeros((100, 100, 100), dtype=np.float32) data[30:70, 30:70, 30:70] = 1.0 # Set some arbitrary data values
Metadata creation for the data
header = {‘spacings’: [1.0, 1.0, 1.0], # Spacing for each axis ‘units’: [‘mm’, ‘mm’, ‘mm’], # Units for each axis ‘type’: ‘float’, # Data type ‘encoding’: ‘gzip’, # Compression method ‘space directions’: np.eye(3) # Adding the space directions for each axis }
Save as NRRD file
output_path = ‘example.nrrd’ nrrd.write(output_path, data, header)
print(f”NRRD file has been saved to {output_path}.”) ```
- NRRD viewer: 3D slicer