Conversion¶
-
heudiconv.convert.
add_taskname_to_infofile
(infofiles)¶ Add the “TaskName” field to json files with _task- entity in the name.
Note: _task- entity could be present not only in functional data but in many other modalities now.
Parameters: infofiles (list or str) – json filenames or a single filename.
-
heudiconv.convert.
bvals_are_zero
(bval_file)¶ Checks if all entries in a bvals file are zero (or 5, for Siemens files).
Parameters: bval_file (str) – file with the bvals Returns: Return type: True if all are all 0 or 5; 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, populate_intended_for_opts={})¶ Perform actual conversion (calls to converter etc) given info from heuristic’s infotodict
-
heudiconv.convert.
convert_dicom
(item_dicoms, bids_options, prefix, outdir, tempdirs, symlink, overwrite)¶ Save DICOMs as output (default is by symbolic link)
Parameters: - 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
-
heudiconv.convert.
nipype_convert
(item_dicoms, prefix, with_prov, bids_options, tmpdir, dcmconfig=None)¶ Converts DICOMs grouped from heuristic using Nipype’s Dcm2niix interface.
Parameters: - item_dicoms (list) – DICOM files to convert
- prefix (str) – 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 (str) – Conversion working directory
- dcmconfig (str, 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.
Parameters: - res (Node) – Nipype conversion Node with results
- item_dicoms (list) – Filenames of converted DICOMs
- bids (list or None) – If not list save to BIDS List may contain bids specific options
- prefix (str) –
Returns: Converted BIDS files
Return type: bids_outfiles
-
heudiconv.convert.
update_complex_name
(metadata, filename)¶ Insert _part-<mag|phase> entity into filename if data are from a sequence with magnitude/phase part.
Parameters: - metadata (dict) – Scan metadata dictionary from BIDS sidecar file.
- filename (str) – Incoming filename
Returns: filename – Updated filename with part entity added in appropriate position.
Return type: str
-
heudiconv.convert.
update_multiecho_name
(metadata, filename, echo_times)¶ Insert _echo-<num> entity into filename if data are from a multi-echo sequence.
Parameters: - 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.
Returns: filename – Updated filename with echo entity added, if appropriate.
Return type: str
-
heudiconv.convert.
update_uncombined_name
(metadata, filename, channel_names)¶ Insert _ch-<num> entity into filename if data are from a sequence with “save uncombined”.
Parameters: - 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.
Returns: filename – Updated filename with ch entity added, if appropriate.
Return type: str