Conversion¶
-
heudiconv.convert.
add_taskname_to_infofile
(infofiles: str | list[str]) → None¶ 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: str) → bool¶ 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: list[tuple[str, tuple[str, ...], list[str]]], converter: str, scaninfo_suffix: str, custom_callable: Optional[Callable[[str, tuple[str, ...], list[str]], Any]], with_prov: bool, bids_options: Optional[str], outdir: str, min_meta: bool, overwrite: bool, symlink: bool = True, prov_file: Optional[str] = None, dcmconfig: Optional[str] = None, populate_intended_for_opts: Optional[PopulateIntendedForOpts] = None) → None¶ Perform actual conversion (calls to converter etc) given info from heuristic’s infotodict
-
heudiconv.convert.
convert_dicom
(item_dicoms: list, bids_options: Optional[str], prefix: str, outdir: str, tempdirs: heudiconv.utils.TempDirs, _symlink: bool, overwrite: bool) → None¶ Save DICOMs as output (default is by symbolic link)
Parameters: - item_dicoms (list of filenames) – DICOMs to save
- bids_options (str or None) – If not None then save to BIDS format. String 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: list, prefix: str, with_prov: bool, bids_options: Optional[str], tmpdir: str, dcmconfig: Optional[str] = None) → tuple¶ 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 (str or None) – If not None then output BIDS sidecar JSONs String 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: nipype.pipeline.engine.nodes.Node, item_dicoms: list, bids_options: Optional[str], outtype: str, prefix: str, outname_bids: str, overwrite: bool) → list¶ 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: dict, filename: str) → str¶ 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: dict, filename: str, echo_times: list) → str¶ 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: dict, filename: str, channel_names: list) → str¶ 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