nipype.interfaces.dcm2nii module

dcm2nii converts images from the proprietary scanner DICOM format to NIfTI.

Dcm2nii

Link to code

Bases: CommandLine

Wrapped executable: dcm2nii.

Uses MRIcron’s dcm2nii to convert dicom files

Examples

>>> from nipype.interfaces.dcm2nii import Dcm2nii
>>> converter = Dcm2nii()
>>> converter.inputs.source_names = ['functional_1.dcm', 'functional_2.dcm']
>>> converter.inputs.gzip_output = True
>>> converter.inputs.output_dir = '.'
>>> converter.cmdline  
'dcm2nii -a y -c y -b config.ini -v y -d y -e y -g y -i n -n y -o . -p y -x n -f n functional_1.dcm'
Mandatory Inputs:
  • source_dir (a pathlike object or string representing an existing directory) – Maps to a command-line argument: %s (position: -1). Mutually exclusive with inputs: source_names.

  • source_names (a list of items which are a pathlike object or string representing an existing file) – Maps to a command-line argument: %s (position: -1). Mutually exclusive with inputs: source_dir.

Optional Inputs:
  • anonymize (a boolean) – Remove identifying information. Maps to a command-line argument: -a. (Nipype default value: True)

  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • collapse_folders (a boolean) – Collapse input folders. Maps to a command-line argument: -c. (Nipype default value: True)

  • config_file (a pathlike object or string representing an existing file) – Load settings from specified inifile. Maps to a command-line argument: -b %s.

  • convert_all_pars (a boolean) – Convert every image in directory. Maps to a command-line argument: -v. (Nipype default value: True)

  • date_in_filename (a boolean) – Date in filename. Maps to a command-line argument: -d. (Nipype default value: True)

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • events_in_filename (a boolean) – Events (series/acq) in filename. Maps to a command-line argument: -e. (Nipype default value: True)

  • gzip_output (a boolean) – Gzip output (.gz). Maps to a command-line argument: -g. (Nipype default value: False)

  • id_in_filename (a boolean) – ID in filename. Maps to a command-line argument: -i. (Nipype default value: False)

  • nii_output (a boolean) – Save as .nii - if no, create .hdr/.img pair. Maps to a command-line argument: -n. (Nipype default value: True)

  • output_dir (a pathlike object or string representing an existing directory) – Output dir - if unspecified, source directory is used. Maps to a command-line argument: -o %s.

  • protocol_in_filename (a boolean) – Protocol in filename. Maps to a command-line argument: -p. (Nipype default value: True)

  • reorient (a boolean) – Reorient image to nearest orthogonal. Maps to a command-line argument: -r.

  • reorient_and_crop (a boolean) – Reorient and crop 3D images. Maps to a command-line argument: -x. (Nipype default value: False)

  • source_in_filename (a boolean) – Source filename. Maps to a command-line argument: -f. (Nipype default value: False)

  • spm_analyze (a boolean) – SPM2/Analyze not SPM5/NIfTI. Maps to a command-line argument: -s. Mutually exclusive with inputs: nii_output.

Outputs:
  • bvals (a list of items which are a pathlike object or string representing an existing file)

  • bvecs (a list of items which are a pathlike object or string representing an existing file)

  • converted_files (a list of items which are a pathlike object or string representing an existing file)

  • reoriented_and_cropped_files (a list of items which are a pathlike object or string representing an existing file)

  • reoriented_files (a list of items which are a pathlike object or string representing an existing file)

Dcm2niix

Link to code

Bases: CommandLine

Wrapped executable: dcm2niix.

Uses Chris Rorden’s dcm2niix to convert dicom files

Examples

>>> from nipype.interfaces.dcm2nii import Dcm2niix
>>> converter = Dcm2niix()
>>> converter.inputs.source_dir = 'dicomdir'
>>> converter.inputs.compression = 5
>>> converter.inputs.output_dir = 'ds005'
>>> converter.cmdline
'dcm2niix -b y -z y -5 -x n -t n -m 0 -o ds005 -s n -v n dicomdir'
>>> converter.run() 

In the example below, we note that the current version of dcm2niix converts any files in the directory containing the files in the list. We also do not support nested filenames with this option. Thus all files must have a common root directory.

>>> converter = Dcm2niix()
>>> converter.inputs.source_names = ['functional_1.dcm', 'functional_2.dcm']
>>> converter.inputs.compression = 5
>>> converter.inputs.output_dir = 'ds005'
>>> converter.cmdline
'dcm2niix -b y -z y -5 -x n -t n -m 0 -o ds005 -s n -v n .'
>>> converter.run() 
Mandatory Inputs:
  • source_dir (a pathlike object or string representing an existing directory) – A directory containing dicom files to be converted. Maps to a command-line argument: %s (position: -1). Mutually exclusive with inputs: source_names.

  • source_names (a list of items which are a pathlike object or string representing an existing file) – A set of filenames to be converted. Note that the current version (1.0.20180328) of dcm2niix converts any files in the directory. To only convert specific files they should be in an isolated directory. Maps to a command-line argument: %s (position: -1). Mutually exclusive with inputs: source_dir.

Optional Inputs:
  • anon_bids (a boolean) – Anonymize BIDS. Maps to a command-line argument: -ba. Requires inputs: bids_format.

  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • bids_format (a boolean) – Create a BIDS sidecar file. Maps to a command-line argument: -b. (Nipype default value: True)

  • comment (a string) – Comment stored as NIfTI aux_file. Maps to a command-line argument: -c %s.

  • compress (‘y’ or ‘i’ or ‘n’ or ‘3’) – Gzip compress images - [y=pigz, i=internal, n=no, 3=no,3D]. Maps to a command-line argument: -z %s. (Nipype default value: y)

  • compression (1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9) – Gz compression level (1=fastest, 9=smallest). Maps to a command-line argument: -%d.

  • crop (a boolean) – Crop 3D T1 acquisitions. Maps to a command-line argument: -x. (Nipype default value: False)

  • environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})

  • has_private (a boolean) – Text notes including private patient details. Maps to a command-line argument: -t. (Nipype default value: False)

  • ignore_deriv (a boolean) – Ignore derived, localizer and 2D images. Maps to a command-line argument: -i.

  • merge_imgs (0 or 1 or 2) – Merge 2D slices from same series regardless of echo, exposure, etc. - [0=no, 1=yes, 2=auto]. Maps to a command-line argument: -m %d. (Nipype default value: 0)

  • out_filename (a string) – Output filename template (%a=antenna (coil) number, %c=comments, %d=description, %e=echo number, %f=folder name, %i=ID of patient, %j=seriesInstanceUID, %k=studyInstanceUID, %m=manufacturer, %n=name of patient, %p=protocol, %s=series number, %t=time, %u=acquisition number, %v=vendor, %x=study ID; %z=sequence name). Maps to a command-line argument: -f %s.

  • output_dir (a pathlike object or string representing an existing directory) – Output directory. Maps to a command-line argument: -o %s. (Nipype default value: .)

  • philips_float (a boolean) – Philips precise float (not display) scaling. Maps to a command-line argument: -p.

  • series_numbers (a list of items which are a string) – Selectively convert by series number - can be used up to 16 times. Maps to a command-line argument: -n %s....

  • single_file (a boolean) – Single file mode. Maps to a command-line argument: -s. (Nipype default value: False)

  • to_nrrd (a boolean) – Export as NRRD instead of NIfTI. Maps to a command-line argument: -e.

  • verbose (a boolean) – Verbose output. Maps to a command-line argument: -v. (Nipype default value: False)

Outputs:
  • bids (a list of items which are a pathlike object or string representing an existing file)

  • bvals (a list of items which are a pathlike object or string representing an existing file)

  • bvecs (a list of items which are a pathlike object or string representing an existing file)

  • converted_files (a list of items which are a pathlike object or string representing an existing file)

  • mvecs (a list of items which are a pathlike object or string representing an existing file)

property Dcm2niix.version

interfaces should implement a version property

class nipype.interfaces.dcm2nii.Info

Bases: nipype.interfaces.base.core.PackageInfo

Handle dcm2niix version information

static parse_version(raw_info)
version_cmd = 'dcm2niix'
nipype.interfaces.dcm2nii.search_files(prefix, outtypes, search_crop)