from itertools import product import re from typing import Optional from heudiconv.utils import SeqInfo # https://heudiconv.readthedocs.io/en/latest/heuristics.html#populate-intended-for-opts POPULATE_INTENDED_FOR_OPTS = { "matching_parameters": ["ImagingVolume", "Shims"], "criterion": "Closest", } def create_key( template: Optional[str], outtype: tuple[str, ...] = ("nii.gz",), annotation_classes: None = None, ) -> tuple[str, tuple[str, ...], None]: if template is None or not template: raise ValueError("Template must be a valid format string") return (template, outtype, annotation_classes) def infotodict( seqinfo: list[SeqInfo], ) -> dict[tuple[str, tuple[str, ...], None], list[str]]: """Heuristic evaluator for determining which runs belong where allowed template fields - follow python string module: item: index within category subject: participant id seqitem: run number during scanning subindex: sub index within group """ # regular expressions to match protocol names of each type (named groups capture detail) anat_regex = re.compile(r"anat(?!_acq-scout)(_acq-.*)?_(?PT[12]w)") func_regex = re.compile(r"task-(?Prest(vid[an])?)") fmap_regex = re.compile(r"fmap(_se_|_dir-)(?Pap|pa)(.*_run-(?P\d))?") dwi_regex = re.compile(r"dwi_(acq-)?(?P