Usage
Vicom can parse MRI data stored in three different formats into volumes:
- DICOM files (
.dcmtypically) - Nifti files (
.nii,.nii.gztypically) - "Volume" files (
.nii.gz + .json): our representation of a volume, which contains the entire image data and metadata
Note that storing a volume to a Nifti alone will result in a loss of metadata, as the nifti standard is not equipped to store all the metadata that is present in a DICOM/Volume.
Moreover, vicom can transform SITK images to Volumes and vice versa.
Vicom provides a central function to load these medical images:
from vicom.data_management import load_volumes
volumes = load_volumes(path="/path/to/volume/folder", file_type="VOLUME")
The following table provides an overview over what functions to use for what load/write/convert scenario:
| Volume | Nifti | DICOM | SITK | |
|---|---|---|---|---|
| Read file/dir | load_volumes(path=..., file_type="VOLUME") | load_volumes(path=..., file_type="NIFTI") | load_volumes(path=..., file_type="DICOM") | -- |
| Write volume to file/dir | store_volumes_to_file(path=..., file_type="VOLUME") | store_volumes_to_file(path=..., file_type="NIFTI") | store_volumes_to_file(path=..., file_type="DICOM") | -- |
| Write to file in original format | -- | nibabel.load | pydicom.dcmwrite | sitk.WriteImage |
| Convert to Volume | -- | load_volume_from_nifti | load_volumes_from_dicoms | -- (convert to nifti, then sitk) |
| Convert from Volume | -- | convert_volume_to_nifti | convert_volume_to_dicom | convert_volume_to_sitk |
!!! warning
Vicom used to provide functionality for loading data from the Orthanc instances.
This functionality has been moved to the virdx_client package.
To explore volumes in a notebook, consider using the methods volume.plot() and volume.print_summary().
For documentation on the core vicom functions, see Reading/Writing. For many helpful functions to work with volumes, see Processing Volumes and Pytest fixtures.