Skip to content

Commit

Permalink
Require derivatives.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Sep 1, 2024
1 parent 83675df commit 79e02f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 43 deletions.
1 change: 1 addition & 0 deletions src/fmripost_phase/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def _bids_filter(value, parser):
action=ToDict,
metavar='PACKAGE=PATH',
nargs='+',
required=True,
help=(
'Search PATH(s) for pre-computed derivatives. '
'These may be provided as named folders '
Expand Down
67 changes: 24 additions & 43 deletions src/fmripost_phase/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,54 +305,39 @@ def init_single_run_wf(bold_file):
entities = extract_entities(bold_file)

functional_cache = defaultdict(list, {})
if config.execution.derivatives:
# Collect native-space derivatives and transforms
functional_cache = collect_derivatives(
raw_dataset=config.execution.layout,
derivatives_dataset=None,
entities=entities,
fieldmap_id=None,
allow_multiple=False,
spaces=None,
)
for deriv_dir in config.execution.derivatives.values():
functional_cache = update_dict(
functional_cache,
collect_derivatives(
raw_dataset=None,
derivatives_dataset=deriv_dir,
entities=entities,
fieldmap_id=None,
allow_multiple=False,
spaces=spaces,
),
)

if not functional_cache['confounds']:
if config.workflow.dummy_scans is None:
raise ValueError(
'No confounds detected. '
'Automatical dummy scan detection cannot be performed. '
'Please set the `--dummy-scans` flag explicitly.'
)

# TODO: Calculate motion parameters from motion correction transform
raise ValueError('Motion parameters cannot be extracted from transforms yet.')

else:
# Collect MNI152NLin6Asym:res-2 derivatives
# Only derivatives dataset was passed in, so we expected standard-space derivatives
functional_cache.update(
# Collect native-space derivatives and transforms
functional_cache = collect_derivatives(
raw_dataset=config.execution.layout,
derivatives_dataset=None,
entities=entities,
fieldmap_id=None,
allow_multiple=False,
spaces=None,
)
for deriv_dir in config.execution.derivatives.values():
functional_cache = update_dict(
functional_cache,
collect_derivatives(
raw_dataset=None,
derivatives_dataset=config.execution.layout,
derivatives_dataset=deriv_dir,
entities=entities,
fieldmap_id=None,
allow_multiple=False,
spaces=spaces,
),
)

if not functional_cache['confounds']:
if config.workflow.dummy_scans is None:
raise ValueError(
'No confounds detected. '
'Automatical dummy scan detection cannot be performed. '
'Please set the `--dummy-scans` flag explicitly.'
)

# TODO: Calculate motion parameters from motion correction transform
raise ValueError('Motion parameters cannot be extracted from transforms yet.')

config.loggers.workflow.info(
(
f'Collected run data for {os.path.basename(bold_file)}:\n'
Expand All @@ -371,10 +356,6 @@ def init_single_run_wf(bold_file):
)
skip_vols = get_nss(functional_cache['confounds'])

workflow.__desc__ += """\
Raw BOLD series were resampled to MNI152NLin6Asym:res-2, for ICA-Phase classification.
"""

validate_bold = pe.Node(
ValidateImage(in_file=functional_cache['bold_raw']),
name='validate_bold',
Expand Down

0 comments on commit 79e02f0

Please sign in to comment.