Home · Quickstart · User Guide and Examples · Interfaces Index · Developers · About · Nipy

# 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'

> source_dira pathlike object or string representing an existing directory

>   Maps to a command-line argument: `%s` (position: -1). Mutually exclusive with inputs: `source_names`.

> source_namesa 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`.

> anonymizea boolean

>   Remove identifying information. Maps to a command-line argument: `-a`. (Nipype default value: `True`)

> argsa unicode string

>   Additional parameters to the command. Maps to a command-line argument: `%s`.

> collapse_foldersa boolean

>   Collapse input folders. Maps to a command-line argument: `-c`. (Nipype default value: `True`)

> config_filea pathlike object or string representing an existing file

>   Load settings from specified inifile. Maps to a command-line argument: `-b %s`.

> convert_all_parsa boolean

>   Convert every image in directory. Maps to a command-line argument: `-v`. (Nipype default value: `True`)

> date_in_filenamea boolean

>   Date in filename. Maps to a command-line argument: `-d`. (Nipype default value: `True`)

> environa 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_filenamea boolean

>   Events (series/acq) in filename. Maps to a command-line argument: `-e`. (Nipype default value: `True`)

> gzip_outputa boolean

>   Gzip output (.gz). Maps to a command-line argument: `-g`. (Nipype default value: `False`)

> id_in_filenamea boolean

>   ID in filename. Maps to a command-line argument: `-i`. (Nipype default value: `False`)

> nii_outputa boolean

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

> output_dira 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_filenamea boolean

>   Protocol in filename. Maps to a command-line argument: `-p`. (Nipype default value: `True`)

> reorienta boolean

>   Reorient image to nearest orthogonal. Maps to a command-line argument: `-r`.

> reorient_and_cropa boolean

>   Reorient and crop 3D images. Maps to a command-line argument: `-x`. (Nipype default value: `False`)

> source_in_filenamea boolean

>   Source filename. Maps to a command-line argument: `-f`. (Nipype default value: `False`)

> spm_analyzea boolean

>   SPM2/Analyze not SPM5/NIfTI. Maps to a command-line argument: `-s`. Mutually exclusive with inputs: `nii_output`.

> 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 n -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 n -o ds005 -s n -v n .'
>     >>> converter.run()

> source_dira 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_namesa 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`.

> anon_bidsa boolean

>   Anonymize BIDS. Maps to a command-line argument: `-ba`. Requires inputs: `bids_format`.

> argsa unicode string

>   Additional parameters to the command. Maps to a command-line argument: `%s`.

> bids_formata boolean

>   Create a BIDS sidecar file. Maps to a command-line argument: `-b`. (Nipype default value: `True`)

> commenta unicode 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`)

> compression1 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`.

> cropa boolean

>   Crop 3D T1 acquisitions. Maps to a command-line argument: `-x`. (Nipype default value: `False`)

> environa 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_privatea boolean

>   Text notes including private patient details. Maps to a command-line argument: `-t`. (Nipype default value: `False`)

> ignore_deriva boolean

>   Ignore derived, localizer and 2D images. Maps to a command-line argument: `-i`.

> merge_imgsa boolean

>   Merge 2D slices from same series. Maps to a command-line argument: `-m`. (Nipype default value: `False`)

> out_filenamea unicode 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_dira pathlike object or string representing an existing directory

>   Output directory. Maps to a command-line argument: `-o %s`. (Nipype default value: `.`)

> philips_floata boolean

>   Philips precise float (not display) scaling. Maps to a command-line argument: `-p`.

> series_numbersa list of items which are a unicode string

>   Selectively convert by series number - can be used up to 16 times. Maps to a command-line argument: `-n %s...`.

> single_filea boolean

>   Single file mode. Maps to a command-line argument: `-s`. (Nipype default value: `False`)

> to_nrrda boolean

>   Export as NRRD instead of NIfTI. Maps to a command-line argument: `-e`.

> verbosea boolean

>   Verbose output. Maps to a command-line argument: `-v`. (Nipype default value: `False`)

> 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

> 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)