Skip to content

Commit

Permalink
More stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Sep 1, 2024
1 parent e33414a commit 8f5c011
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/fmripost_phase/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def clean_datasinks(workflow: pe.Workflow) -> pe.Workflow:
for node in workflow.list_node_names():
if node.split('.')[-1].startswith('ds_'):
workflow.get_node(node).interface.out_path_base = ''

if node.split('.')[-1].startswith('ds_report_'):
workflow.get_node(node).interface.datatype = 'figures'

return workflow


Expand Down
27 changes: 26 additions & 1 deletion src/fmripost_phase/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def init_single_subject_wf(subject_id: str):

def init_single_run_wf(bold_file):
"""Set up a single-run workflow for fMRIPost-Phase."""
from fmriprep.utils.bids import dismiss_echo
from fmriprep.utils.misc import estimate_bold_mem_usage
from fmriprep.workflows.bold.apply import init_bold_volumetric_resample_wf
from fmriprep.workflows.bold.stc import init_bold_stc_wf
Expand All @@ -291,6 +292,7 @@ def init_single_run_wf(bold_file):
from fmripost_phase.interfaces.bids import DerivativesDataSink
from fmripost_phase.interfaces.laynii import LayNiiPhaseJolt
from fmripost_phase.utils.bids import collect_derivatives, extract_entities
from fmripost_phase.workflows.confounds import init_bold_confs_wf
from fmripost_phase.workflows.regression import init_phase_regression_wf

spaces = config.workflow.spaces
Expand Down Expand Up @@ -481,7 +483,30 @@ def init_single_run_wf(bold_file):
pass

# Compute confounds, including HighCor
pass
bold_confounds_wf = init_bold_confs_wf(
mem_gb=mem_gb['largemem'],
metadata=bold_metadata,
regressors_all_comps=config.workflow.regressors_all_comps,
name='bold_confounds_wf',
)
# TODO: Set 'phase', 'bold_mask', and 'skip_vols'

ds_confounds = pe.Node(
DerivativesDataSink(
desc='confounds',
suffix='timeseries',
dismiss_entities=dismiss_echo(),
),
name='ds_confounds',
run_without_submitting=True,
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
)
workflow.connect([
(bold_confounds_wf, ds_confounds, [
('outputnode.confounds_file', 'in_file'),
('outputnode.confounds_metadata', 'meta_dict'),
]),
]) # fmt:skip

# Fill-in datasinks seen so far
for node in workflow.list_node_names():
Expand Down
17 changes: 4 additions & 13 deletions src/fmripost_phase/workflows/confounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ def init_bold_confs_wf(
mem_gb: float,
metadata: dict,
regressors_all_comps: bool,
regressors_dvars_th: float,
regressors_fd_th: float,
freesurfer: bool = False,
name: str = 'bold_confs_wf',
):
"""Build a workflow to generate and write out confounding signals.
Expand All @@ -23,6 +20,8 @@ def init_bold_confs_wf(
censored and high-pass filtered using a :abbr:`DCT (discrete cosine transform)` basis.
The cosine basis, as well as one regressor per censored volume, are included
for convenience.
XXX: What about tissue time series from the jolt and/or jump files?
"""
from fmriprep.interfaces.confounds import FilterDropped
from fmriprep.utils.bids import dismiss_echo
Expand All @@ -45,15 +44,9 @@ def init_bold_confs_wf(
inputnode = pe.Node(
niu.IdentityInterface(
fields=[
'bold',
'phase',
'bold_mask',
'movpar_file',
'rmsd_file',
'skip_vols',
't1w_mask',
't1w_tpms',
'boldref2anat_xfm',
],
),
name='inputnode',
Expand All @@ -63,9 +56,7 @@ def init_bold_confs_wf(
fields=[
'confounds_file',
'confounds_metadata',
'acompcor_masks',
'tcompcor_mask',
'crown_mask',
'highcor_mask',
],
),
name='outputnode',
Expand Down Expand Up @@ -160,7 +151,7 @@ def init_bold_confs_wf(
(highcor, hcc_metadata_filter, [('metadata_file', 'in_file')]),
(hcc_metadata_filter, hcc_metadata_fmt, [('out_file', 'in_file')]),
(hcc_metadata_fmt, outputnode, [('output', 'confounds_metadata')]),
(highcor, outputnode, [('high_variance_masks', 'tcompcor_mask')]),
(highcor, outputnode, [('high_variance_masks', 'highcor_mask')]),
(highcor, rois_plot, [('high_variance_masks', 'in_rois')]),
(rois_plot, ds_report_bold_rois, [('out_report', 'in_file')]),
(highcor, compcor_plot, [('metadata_file', 'in1')]),
Expand Down

0 comments on commit 8f5c011

Please sign in to comment.