Skip to content

Commit

Permalink
ENH: Save surface derivatives
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Aug 28, 2023
1 parent 89439f1 commit 80abe3e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
1 change: 0 additions & 1 deletion fmriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def main():
"""Entry point."""
import gc
import sys
import warnings
from multiprocessing import Manager, Process
from os import EX_SOFTWARE
from pathlib import Path
Expand Down
41 changes: 32 additions & 9 deletions fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,8 @@ def init_single_subject_fit_wf(subject_id: str):
])
# fmt:on

# Overwrite ``out_path_base`` of smriprep's DataSinks
for node in workflow.list_node_names():
if node.split('.')[-1].startswith('ds_'):
workflow.get_node(node).interface.out_path_base = ""

if config.workflow.anat_only:
return workflow
return clean_datasinks(workflow)

Check warning on line 201 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L201

Added line #L201 was not covered by tests

fmap_estimators, estimator_map = map_fieldmap_estimation(

Check warning on line 203 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L203

Added line #L203 was not covered by tests
layout=config.execution.layout,
Expand Down Expand Up @@ -362,9 +357,10 @@ def init_single_subject_fit_wf(subject_id: str):
# fmt:on

if config.workflow.level == "minimal":
return workflow
return clean_datasinks(workflow)

Check warning on line 360 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L359-L360

Added lines #L359 - L360 were not covered by tests

if config.workflow.run_reconall:
from smriprep.workflows.outputs import init_ds_surfaces_wf
from smriprep.workflows.surfaces import (

Check warning on line 364 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L362-L364

Added lines #L362 - L364 were not covered by tests
init_anat_ribbon_wf,
init_fsLR_reg_wf,
Expand All @@ -378,6 +374,11 @@ def init_single_subject_fit_wf(subject_id: str):
surfaces=["sphere_reg"], to_scanner=False, name="gifti_spheres_wf"
)
fsLR_reg_wf = init_fsLR_reg_wf()
ds_surfaces_wf = init_ds_surfaces_wf(

Check warning on line 377 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L376-L377

Added lines #L376 - L377 were not covered by tests
bids_root=str(config.execution.bids_dir),
output_dir=str(config.execution.output_dir),
surfaces=["white", "pial", "midthickness", "sphere_reg", "sphere_reg_fsLR"],
)
anat_ribbon_wf = init_anat_ribbon_wf()

Check warning on line 382 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L382

Added line #L382 was not covered by tests

# fmt:off
Expand All @@ -402,13 +403,27 @@ def init_single_subject_fit_wf(subject_id: str):
("outputnode.white", "inputnode.white"),
("outputnode.pial", "inputnode.pial"),
]),
(anat_fit_wf, ds_surfaces_wf, [
("outputnode.t1w_valid_list", "inputnode.source_files"),
]),
(gifti_surfaces_wf, ds_surfaces_wf, [
("outputnode.white", "inputnode.white"),
("outputnode.pial", "inputnode.pial"),
("outputnode.midthickness", "inputnode.midthickness"),
]),
(gifti_spheres_wf, ds_surfaces_wf, [
("outputnode.sphere_reg", "inputnode.sphere_reg"),
]),
(fsLR_reg_wf, ds_surfaces_wf, [
("outputnode.sphere_reg_fsLR", "inputnode.sphere_reg_fsLR"),
]),
])
# fmt:on

if config.workflow.level == "resampling":
return workflow
return clean_datasinks(workflow)

Check warning on line 424 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L423-L424

Added lines #L423 - L424 were not covered by tests

return workflow
return clean_datasinks(workflow)

Check warning on line 426 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L426

Added line #L426 was not covered by tests


def init_single_subject_wf(subject_id: str):
Expand Down Expand Up @@ -968,3 +983,11 @@ def map_fieldmap_estimation(

def _prefix(subid):
return subid if subid.startswith('sub-') else f'sub-{subid}'


def clean_datasinks(workflow: pe.Workflow) -> pe.Workflow:
# Overwrite ``out_path_base`` of smriprep's DataSinks
for node in workflow.list_node_names():
if node.split('.')[-1].startswith('ds_'):
workflow.get_node(node).interface.out_path_base = ""
return workflow

Check warning on line 993 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L990-L993

Added lines #L990 - L993 were not covered by tests

0 comments on commit 80abe3e

Please sign in to comment.