Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

5.1.1. sammba.io_conversions.dcm_to_nii

sammba.io_conversions.dcm_to_nii(dcmdump_path, dicom_filename, save_directory, siap_fix=True, id_in_filename=True, date_in_filename=True, time_in_filename=True, protocol_in_filename=True, paravision_folder_in_filename=True, siap_in_filename=True)

Converts Bruker Paravision enhanced multiframe DICOM files into NIfTI-1 format.

Assumes int16; this will be changed in the future. NIFTI files are named based on several tag values found in the DICOM. Also saved with the same name as the .nii.gz is a .txt file of extracted meta-data that could be useful to the processing of certain protocols such as perfusion, T1/T2 mapping and diffusion.

Thanks to common.py of dicom2nifiti by Arne Brys, icometrix, which saved me when it comes to specifying the affine for nibabel.

Parameters

dcmdump_path : str

Path to the compiled dcmdump (see Note).

dicom_filename : str

Path to the DICOM file (typically named EnIm1.dcm).

save_directory : str

Path to the directory to save the extracteed NIFTI image.

siap_fix : bool, optional

If True, swaps the superior-inferior and anterior-posterior axes to be how I think they should be. In rodents, Paravision sets dorsal-ventral as AP and rostral-caudal as SI. I think they should be the other way round https://en.wikipedia.org/wiki/Anatomical_terms_of_location#Main_terms

id_in_filename : bool, optional

If True, animal ID is included in the filename of the generated NIFTI.

date_in_filename : bool, optional

If True, acquisition date is included in the filename of the generated NIFTI.

time_in_filename : bool, optional

If True, acquisition time included in the filename of the generated NIFTI.

protocol_in_filename : bool, optional

If True, the protocl acronym is included in the filename of the generated NIFTI.

paravision_folder_in_filename : bool, optional

If True, Paravision folder number is included in the filename of the generated NIFTI.

siap_in_filename : bool, optional

If True, ‘fixedSIAP’ or ‘origSIAP’ is included in the filename of the generated NIFTI, to tell whether or not axes were swapped.

Returns

nii_filename : str

Path to the created NIFTI image.

Notes

This is effectively a python wrapper to dcmdump, processing and passing its output to nibabel and a text file. Depends on access to a compiled version of dcmdump (part of OFFIS dcmtk; http://dcmtk.org/dcmtk.php.en and http://support.dcmtk.org/docs/dcmdump.html) which does the initial parsing: extraction of the header/metadata as text and the image data as a raw vector.

Useful documents include DICOM spec C.7.6.2.1.1 and 10.7.1.3 common.py of dicom2nifiti by Arne Brys, icometrix saved me when it comes to specifying the affine for nibabel! see http://dicom2nifti.readthedocs.io. he effectively did the hard part, interpreting nibabel’s DICOM tutorial for me.

Only tested on PV6 .dcm files and a limited number of sequences. Little or no error-checking. There are a lot of circumstances where this converter will fail or be sub-optimal.