DICOMS

heudiconv.dicoms.compress_dicoms(dicom_list, out_prefix, tempdirs, overwrite)

Archives DICOMs into a tarball

Also tries to do it reproducibly, so takes the date for files and target tarball based on the series time (within the first file)

dicom_list : list of str
list of dicom files
out_prefix : str
output path prefix, including the portion of the output file name before .dicom.tgz suffix
tempdirs : object
TempDirs object to handle multiple tmpdirs
overwrite : bool
Overwrite existing tarfiles
filename : str
Result tarball
heudiconv.dicoms.create_seqinfo(mw, series_files, series_id)

Generate sequence info

mw: MosaicWrapper series_files: list series_id: str

heudiconv.dicoms.embed_dicom_and_nifti_metadata(dcmfiles, niftifile, infofile, bids_info)

Embed metadata from nifti (affine etc) and dicoms into infofile (json)

niftifile should exist. Its affine’s orientation information is used while establishing new NiftiImage out of dicom stack and together with bids_info (if provided) is dumped into json infofile

dcmfiles niftifile infofile bids_info: dict

Additional metadata to be embedded. infofile is overwritten if exists, so here you could pass some metadata which would overload (at the first level of the dict structure, no recursive fancy updates) what is obtained from nifti and dicoms
heudiconv.dicoms.embed_metadata_from_dicoms(bids_options, item_dicoms, outname, outname_bids, prov_file, scaninfo, tempdirs, with_prov)

Enhance sidecar information file with more information from DICOMs

bids_options item_dicoms outname outname_bids prov_file scaninfo tempdirs with_prov

heudiconv.dicoms.get_dicom_series_time(dicom_list)

Get time in seconds since epoch from dicom series date and time Primarily to be used for reproducible time stamping

heudiconv.dicoms.group_dicoms_into_seqinfos(files, grouping, file_filter=None, dcmfilter=None, flatten=False, custom_grouping=None)

Process list of dicoms and return seqinfo and file group seqinfo contains per-sequence extract of fields from DICOMs which will be later provided into heuristics to decide on filenames

files : list of str
List of files to consider
grouping : {‘studyUID’, ‘accession_number’, ‘all’, ‘custom’}
How to group DICOMs for conversion. If ‘custom’, see custom_grouping parameter.
file_filter : callable, optional
Applied to each item of filenames. Should return True if file needs to be kept, False otherwise.
dcmfilter : callable, optional
If called on dcm_data and returns True, it is used to set series_id
flatten : bool, optional
Creates a flattened seqinfo with corresponding DICOM files. True when invoked with dicom_dir_template.
custom_grouping: str or callable, optional
grouping key defined within heuristic. Can be a string of a DICOM attribute, or a method that handles more complex groupings.
seqinfo : list of list
seqinfo is a list of info entries per each sequence (some entry there defines a key for filegrp)
filegrp : dict
filegrp is a dictionary with files groupped per each sequence
heudiconv.dicoms.parse_private_csa_header(dcm_data, public_attr, private_attr, default=None)

Parses CSA header in cases where value is not defined publicly

dcm_data : pydicom Dataset object
DICOM metadata
public_attr : string
non-private DICOM attribute
private_attr : string
private DICOM attribute
default (optional)
default value if private_attr not found
val (default: empty string)
private attribute value or default
heudiconv.dicoms.validate_dicom(fl, dcmfilter)

Parse DICOM attributes. Returns None if not valid.