DICOM is the international standard used to store, transfer and display medical images
in clinical institutions. It is a vast and complicated standard. The
NIfTI file format is widely used within medical imaging
research because it is a comparatively simple data format, generally stripped of identifiable patient data and with far
fewer metadata fields.
Researchers often convert DICOM files to NIfTI files using tools such as
dcm2niix. However, the reverse process is much harder.
nii2dcm is designed to convert a NIfTI file (.nii/.nii.gz) into a single-frame DICOM Series in one line, e.g.:
nii2dcm is designed to be pointed at a single .nii or .nii.gz from which it generates a single-frame DICOM dataset.
It is recommended to specify the output DICOM modality using the -d or --dicom-type flag (see examples below).
Without this, a generic DICOM is created without complete imaging modality metadata.
There are often situations where it can be useful to transfer information from an existing DICOM Study into a new DICOM
Series. For example, if you want to store your new DICOM dataset alongside your original DICOM Study.
The -r or --ref-dicom flag attempts to transfer common DICOM attributes from a reference DICOM file into the
output DICOM:
There are many things I would like to test and implement.
Raise an Issue if you have ideas or suggestions.
Developer Note
If you would like to create another class of DICOM within nii2dcm, you can use the base
DicomMRI
class or the DicomMRISVR class for inspiration. You
will also need to extend the command line interface to utilise your class, i.e. --dicom-type CT.
nii2dcm
NIfTI to DICOM file creation with Python
Explore the docs »
View Repo · Report Bug · Request Feature
Overview
DICOM is the international standard used to store, transfer and display medical images in clinical institutions. It is a vast and complicated standard. The NIfTI file format is widely used within medical imaging research because it is a comparatively simple data format, generally stripped of identifiable patient data and with far fewer metadata fields.
Researchers often convert DICOM files to NIfTI files using tools such as dcm2niix. However, the reverse process is much harder.
nii2dcm is designed to convert a NIfTI file (.nii/.nii.gz) into a single-frame DICOM Series in one line, e.g.:
(back to top)
Installation
To install and run nii2dcm locally, you have two options:
pip
Create a new Python virtual environment, then:
build from source
Clone this repo:
Setup a Python virtual environment (recommended):
Install dependencies and nii2dcm:
Verify installation by displaying nii2dcm help information
(back to top)
Usage
nii2dcm is designed to be pointed at a single
.niior.nii.gzfrom which it generates a single-frame DICOM dataset.It is recommended to specify the output DICOM modality using the
-dor--dicom-typeflag (see examples below). Without this, a generic DICOM is created without complete imaging modality metadata.DicomMRI
Create an MRI 2D multi-slice DICOM dataset:
DicomMRISVR
Create an MRI 3D SVR DICOM dataset:
Dicom
Create a generic DICOM dataset:
Other
Eventually, nii2dcm will be extended to cover other imaging modalities including CT, Ultrasound, X-Ray, etc.
(back to top)
Reference DICOM metadata transferral
There are often situations where it can be useful to transfer information from an existing DICOM Study into a new DICOM Series. For example, if you want to store your new DICOM dataset alongside your original DICOM Study.
The
-ror--ref-dicomflag attempts to transfer common DICOM attributes from a reference DICOM file into the output DICOM:Currently, attributes to transfer are listed here in the DicomMRI class.
(back to top)
Docker
nii2dcm is also available as a Docker container.
Pull the latest container with:
For ease of use, rename the container on your local machine:
Run the containerised nii2dcm:
(back to top)
Roadmap
This project is in its infancy! Expect bugs 🐛

There are many things I would like to test and implement. Raise an Issue if you have ideas or suggestions.
Developer Note
If you would like to create another class of DICOM within nii2dcm, you can use the base DicomMRI class or the DicomMRISVR class for inspiration. You will also need to extend the command line interface to utilise your class, i.e.
--dicom-type CT.Please raise an Issue if you need developer support.
(back to top)
Acknowledgments
(back to top)
Links
Some useful, free image viewing software:
(back to top)
Disclaimer
The Software has been developed for research purposes only and is not a clinical tool.
License
BSD 3-Clause License can be found here
(back to top)