Conversion

heudiconv.convert.add_taskname_to_infofile(infofiles)

Add the “TaskName” field to json files corresponding to func images.

infofiles : list with json filenames or single filename

heudiconv.convert.bvals_are_zero(bval_file)

Checks if all entries in a bvals file are zero (or 5, for Siemens files). Returns True if that is the case, otherwise returns False

bval_file : file with the bvals

True if all are zero; False otherwise.

heudiconv.convert.convert(items, converter, scaninfo_suffix, custom_callable, with_prov, bids_options, outdir, min_meta, overwrite, symlink=True, prov_file=None, dcmconfig=None)

Perform actual conversion (calls to converter etc) given info from heuristic’s infotodict

items symlink converter scaninfo_suffix custom_callable with_prov is_bids sourcedir outdir min_meta

None

heudiconv.convert.convert_dicom(item_dicoms, bids_options, prefix, outdir, tempdirs, symlink, overwrite)

Save DICOMs as output (default is by symbolic link)

item_dicoms : list of filenames
DICOMs to save
bids_options : list or None
If not None then save to BIDS format. List may be empty or contain bids specific options
prefix : string
Conversion outname
outdir : string
Output directory
tempdirs : TempDirs instance
Object to handle temporary directories created TODO: remove
symlink : bool
Create softlink to DICOMs - if False, create hardlink instead.
overwrite : bool
If True, allows overwriting of previous conversion

None

heudiconv.convert.nipype_convert(item_dicoms, prefix, with_prov, bids_options, tmpdir, dcmconfig=None)

Converts DICOMs grouped from heuristic using Nipype’s Dcm2niix interface.

item_dicoms : List
DICOM files to convert
prefix : String
Heuristic output path
with_prov : Bool
Store provenance information
bids_options : List or None
If not None then output BIDS sidecar JSONs List may contain bids specific options
tmpdir : Directory
Conversion working directory
dcmconfig : File (optional)
JSON file used for additional Dcm2niix configuration
heudiconv.convert.save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outname_bids, overwrite)

Copy converted files from tempdir to output directory. Will rename files if necessary.

res : Node
Nipype conversion Node with results
item_dicoms: list of filenames
DICOMs converted
bids : list or None
If not list save to BIDS List may contain bids specific options

prefix : string

bids_outfiles
Converted BIDS files
heudiconv.convert.update_complex_name(metadata, filename, suffix)

Insert _part-<mag|phase> entity into filename if data are from a sequence with magnitude/phase part.

metadata : dict
Scan metadata dictionary from BIDS sidecar file.
filename : str
Incoming filename
suffix : str
An index used for cases where a single scan produces multiple files, but the differences between those files are unknown.
filename : str
Updated filename with rec entity added in appropriate position.
heudiconv.convert.update_multiecho_name(metadata, filename, echo_times)

Insert _echo-<num> entity into filename if data are from a multi-echo sequence.

metadata : dict
Scan metadata dictionary from BIDS sidecar file.
filename : str
Incoming filename
echo_times : list
List of all echo times from scan. Used to determine the echo number (i.e., index) if field is missing from metadata.
filename : str
Updated filename with echo entity added, if appropriate.
heudiconv.convert.update_uncombined_name(metadata, filename, channel_names)

Insert _ch-<num> entity into filename if data are from a sequence with “save uncombined”.

metadata : dict
Scan metadata dictionary from BIDS sidecar file.
filename : str
Incoming filename
channel_names : list
List of all channel names from scan. Used to determine the channel number (i.e., index) if field is missing from metadata.
filename : str
Updated filename with ch entity added, if appropriate.