Medical Image Structure in AMIGOpy¶
AMIGOpy supports multiple medical image formats and stores both images and metadata in a unified format.
Regardless of the original file type (DICOM, NIfTI, MHA, NRRD, etc.), all formats are automatically converted into this structure to ensure consistency across the software to ensure consistent behavior across modules (loading, visualization, segmentation, Monte Carlo simulation, and export).
โ Supported & Planned Formats¶
Core (supported / priority):
- ๐ DICOM (.dcm
) โ clinical standard, includes RTDose/RTStruct/RTPlan
- ๐งฉ NIfTI (.nii
, .nii.gz
) โ compact, common in AI and research
Planned:
- ๐งช MHA / MHD (.mha
, .mhd
+ raw) โ native to ITK/ANTs pipelines
- ๐งฑ NRRD / NRD (.nrrd
, .nrd
) โ efficient for volumetric data and masks
- ๐ HDF5 (.h5
) โ bundles volumes + masks + metadata for AI workflows
- โก NPZ / NPY (.npz
, .npy
) โ fast NumPy storage for preprocessed data
๐ All input formats are normalized into the same internal representation described below.
๐ Data Hierarchy¶
self.medical_image[patientID][studyID][modality][series_index]
Level | Type | Description |
---|---|---|
patientID |
dict |
Dictionary containing all studies for a given patient |
studyID |
dict |
Dictionary containing modalities available within the study |
modality |
dict |
Dictionary containing imaging modalities (e.g. CT, MR, RTDOSE) |
series_index |
int |
Index into a list of series dictionaries under this modality |
๐ฆ Series Index vs Series Dict¶
series_index
โ integer index into the list of series dictionaries- Each series_dict represents one imaging series and contains:
1. Metadata¶
- Voxel spacing (
PixelSpacing
) - Slice thickness
- Image orientation
- Modality type
- Study and series descriptions
- Original file path and format-specific tags
- ...
2. Voxel Data¶
3DMatrix
โ a NumPy 3D array storing the full volumetric dataset
3. Series Add-ons¶
structures
โ ROI masks and contours - Structures within image seriesdensity_maps
โ HU โ density conversions for dose calculationmaterial_maps
โ tissue/material assignments for Monte Carlo simulation
๐ก For implementation details, see the dedicated sections:
Structures ยท Density & Material Maps ยท Export
๐งญ Coordinate System & Orientation¶
To guarantee compatibility across modules:
1. Normalize orientation at load time¶
Reorient volume data into a single, agreed coordinate convention
(e.g. patient-based LPS/RAS or a fixed axis order).
2. Standardize voxel axis order¶
Choose a canonical NumPy layout, for example:
๐๏ธ Series Metadata Overview¶
The internal structure is a nested mapping down to a list of series:
"""
Build the internal AMIGOpy series dictionary.
Parameters
----------
series_number : str | int
spacing : tuple[float, float, float] # (dx, dy, dz)
origin : tuple[float, float, float] # DICOM-style origin
size : tuple[int, int, int] # (nx, ny, nz)
vol : np.ndarray # 3D numpy array (standardized orientation)
path : str
nifti_meta : dict | None
"""
return {
'SeriesNumber': series_number,
'metadata': {
'PixelSpacing': spacing[0:2],
'SliceThickness': spacing[2] if len(spacing) >= 3 else 1.0,
'ImagePositionPatient': origin,
'ImageOrientationPatient': "N/A",
'RescaleSlope': "N/A",
'RescaleIntercept': "N/A",
'WindowWidth': "N/A",
'WindowCenter': "N/A",
'SeriesDescription': series_number,
'StudyDescription': '',
'ImageComments': '',
'DoseGridScaling': "N/A",
'AcquisitionNumber': "N/A",
'Modality': "Medical",
'LUTLabel': "N/A",
'LUTExplanation': "N/A",
'size': size,
'DataType': 'Nifti',
'DCM_Info': None,
'Nifti_info': nifti_meta,
'OriginalFilePath': path,
},
'images': {},
'ImagePositionPatients': [],
'SliceImageComments': {},
'3DMatrix': vol,
'AM_name': None,
'US_name': None,
}