reconstruct DICOM files given one NIfTI and two DICOM files
- Python 3.x
- NumPy
NumPy is the fundamental package for scientific computing with Python.
pip3 install numpy - NiBabel
Read / write access to some common neuroimaging file formats.
pip3 install nibabel - Pydicom
Pydicom is a pure Python package for working with DICOM files such as medical images, reports, and radiotherapy objects.
pip3 install pydicom - (recommended) Unidecode
ASCII transliterations of Unicode text.
pip3 install unidecode
Split directory by series in case DICOM files belong to different series (files are copied).
Then, convert each set of DICOM files to a NIfTI file.
./dicom2nifti.py PATH [-o]
PATHdirectory of DICOM files
-o,--orientorient output NIFTI file
Each series must contain at least two DICOM files.
Convert each NIfTI file in a directory to a set of DICOM files.
./nifti2dicom.py PATH
PATHdirectory of NIfTI files or path of a NIfTI file
At least two DICOM files must be present in the directory of the NIfTI files.
In case path holds the path of a NIfTI file, only that NIfTI file will be taken into account.
./nifti2dicom2.py PATH
Convert NIfTI files to DICOM.
PATHdirectory of NIfTI files or path of a NIfTI file
A set of DICOM files is located in PATH.
Then, for each NIfTI file in PATH, a subdirectory is created with a copy of the DICOM.
Pixel Data (0x7fe0, 0x0010) in every copy of the original DICOM set is replaced by image data of the corresponding NIfTI file.
The Data Set Trailing Padding (0xfffc, 0xfffc) tag is ignored.
In case PATH holds the path of a NIfTI file, only that NIfTI file is taken under consideration, while the DICOM files set is located in the directory of the NIFTI file.
Output the dataset of a DICOM file.
./dicomtools.py dataset PATH
PATHpath to the NIfTI file
Pixel Data (0x7fe0, 0x0010) and Data Set Trailing Padding (0xfffc, 0xfffc) tags are ignored.
Place each DICOM file in a subdirectory according to Protocol Name and Series Number.
./dicomsplit.py PATH [-m] [-f] [-v]
PATHdirectory of mixed DICOM files
-m,--movemove files instead of copying-f,--forceoverwrite existing subdirectories-s,--singlerun even if all DICOM files belong to the same series-v,--verboseprint actions
Output a table with the variable fields of a DICOM set as a CSV.
./dicomtable.py PATH
PATHdirectory of DICOM files
Print the difference of the headers between two DICOM files.
./dicomdiff.py dcm1 dcm2
Compare data of all corresponding DICOM files in two directories.
./dicomcmp.py dir1 dir2 [-v]
-v,--verboseprint the result of each comparison
0on success1on failure
Output the header of a NIfTI file.
./niftitools.py header PATH
PATHpath to the NIfTI file
Output the affine of a NIfTI file.
./niftitools.py affine PATH
PATHpath to the NIfTI file
Orient a NIfTI file.
./niftitools.py orient INPATH [-o OUTPATH] [-d]
INPATHpath to the input NIfTI file
-o OUTPATH,--outpath OUTPATHpath to the output NIfTI file; default INPATH-oriented-d,--diagonalapply orientation only if resulting affine is close to diagonal
Print the difference of the headers between two NIfTI files.
./niftidiff.py nii1 nii2
Compare data of two NIfTI files.
./nifticmp.py nii1 nii2
0on success1on failure