Skip to content

Commit

Permalink
Update outputs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Oct 14, 2023
1 parent 66be748 commit 305b990
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions xcp_d/workflows/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from xcp_d.interfaces.utils import FilterUndefined
from xcp_d.utils.bids import get_entity
from xcp_d.utils.doc import fill_doc
from xcp_d.utils.utils import _make_dictionary, _out_file_to_source
from xcp_d.utils.utils import _make_dictionary


@fill_doc
Expand Down Expand Up @@ -281,10 +281,14 @@ def init_postproc_derivatives_wf(
name="outputnode",
)

def _postproc_to_source(out_file):
def _postproc_to_source(out_file, output_dir):
from xcp_d.utils.utils import _out_file_to_source

return _out_file_to_source(out_file, "xcp_d", os.path.join(output_dir, "xcp_d"))

def _preproc_to_source(out_file):
def _preproc_to_source(out_file, fmri_dir):
from xcp_d.utils.utils import _out_file_to_source

return _out_file_to_source(out_file, "preprocessed", fmri_dir)

# Create dictionary of basic information
Expand Down Expand Up @@ -316,7 +320,7 @@ def _preproc_to_source(out_file):
# Determine cohort (if there is one) in the original data
cohort = get_entity(name_source, "cohort")

preproc_bold_src = _preproc_to_source(name_source)
preproc_bold_src = _preproc_to_source(name_source, fmri_dir)

preproc_confounds_src = pe.Node(
InferBIDSURIs(
Expand Down Expand Up @@ -409,7 +413,9 @@ def _preproc_to_source(out_file):
("temporal_mask_metadata", "meta_dict"),
("temporal_mask", "in_file"),
]),
(ds_filtered_motion, ds_temporal_mask, [(("out_file", _postproc_to_source), "Sources")]),
(ds_filtered_motion, ds_temporal_mask, [
(("out_file", _postproc_to_source, output_dir), "Sources"),
]),
(ds_temporal_mask, outputnode, [("out_file", "temporal_mask")]),
])
# fmt:on
Expand Down Expand Up @@ -485,7 +491,7 @@ def _preproc_to_source(out_file):
("interpolated_filtered_bold", "in_file"),
]),
(ds_denoised_bold, ds_interpolated_denoised_bold, [
(("out_file", _postproc_to_source), "Sources"),
(("out_file", _postproc_to_source, output_dir), "Sources"),
]),
(ds_interpolated_denoised_bold, outputnode, [
("out_file", "interpolated_filtered_bold"),
Expand Down Expand Up @@ -535,7 +541,7 @@ def _preproc_to_source(out_file):
workflow.connect([
(make_atlas_dict, add_denoised_to_src, [("metadata", "metadata")]),
(ds_denoised_bold, add_denoised_to_src, [
(("out_file", _postproc_to_source), "Sources"),
(("out_file", _postproc_to_source, output_dir), "Sources"),
]),
])
# fmt:on
Expand Down Expand Up @@ -563,7 +569,9 @@ def _preproc_to_source(out_file):
# fmt:off
workflow.connect([
(inputnode, ds_smoothed_bold, [("smoothed_denoised_bold", "in_file")]),
(ds_denoised_bold, ds_smoothed_bold, [(("out_file", _postproc_to_source), "Sources")]),
(ds_denoised_bold, ds_smoothed_bold, [
(("out_file", _postproc_to_source, output_dir), "Sources"),
]),
(ds_smoothed_bold, outputnode, [("out_file", "smoothed_denoised_bold")]),
])
# fmt:on
Expand Down Expand Up @@ -609,7 +617,7 @@ def _preproc_to_source(out_file):
workflow.connect([
(add_denoised_to_src, add_coverage_to_src, [("metadata", "metadata")]),
(ds_coverage, add_coverage_to_src, [
(("out_file", _postproc_to_source), "Sources"),
(("out_file", _postproc_to_source, output_dir), "Sources"),
]),
])
# fmt:on
Expand Down Expand Up @@ -718,7 +726,7 @@ def _preproc_to_source(out_file):
workflow.connect([
(add_denoised_to_src, add_ccoverage_to_src, [("metadata", "metadata")]),
(ds_coverage_ciftis, add_ccoverage_to_src, [
(("out_file", _postproc_to_source), "Sources"),
(("out_file", _postproc_to_source, output_dir), "Sources"),
]),
])
# fmt:on
Expand Down Expand Up @@ -851,7 +859,7 @@ def _preproc_to_source(out_file):
# fmt:off
workflow.connect([
(inputnode, ds_reho, [("reho", "in_file")]),
(ds_denoised_bold, ds_reho, [(("out_file", _postproc_to_source), "Sources")]),
(ds_denoised_bold, ds_reho, [(("out_file", _postproc_to_source, output_dir), "Sources")]),
])
# fmt:on

Expand All @@ -870,7 +878,7 @@ def _preproc_to_source(out_file):
# fmt:off
workflow.connect([
(make_atlas_dict, add_reho_to_src, [("metadata", "metadata")]),
(ds_reho, add_reho_to_src, [(("out_file", _postproc_to_source), "Sources")]),
(ds_reho, add_reho_to_src, [(("out_file", _postproc_to_source, output_dir), "Sources")]),
])
# fmt:on

Expand Down Expand Up @@ -922,7 +930,9 @@ def _preproc_to_source(out_file):
# fmt:off
workflow.connect([
(inputnode, ds_alff, [("alff", "in_file")]),
(ds_denoised_bold, ds_alff, [(("out_file", _postproc_to_source), "Sources")]),
(ds_denoised_bold, ds_alff, [
(("out_file", _postproc_to_source, output_dir), "Sources"),
]),
])
# fmt:on

Expand All @@ -949,7 +959,9 @@ def _preproc_to_source(out_file):
# fmt:off
workflow.connect([
(inputnode, ds_smoothed_alff, [("smoothed_alff", "in_file")]),
(ds_alff, ds_smoothed_alff, [(("out_file", _postproc_to_source), "Sources")]),
(ds_alff, ds_smoothed_alff, [
(("out_file", _postproc_to_source, output_dir), "Sources"),
]),
])
# fmt:on

Expand All @@ -967,7 +979,9 @@ def _preproc_to_source(out_file):
# fmt:off
workflow.connect([
(make_atlas_dict, add_alff_to_src, [("metadata", "metadata")]),
(ds_alff, add_alff_to_src, [(("out_file", _postproc_to_source), "Sources")]),
(ds_alff, add_alff_to_src, [
(("out_file", _postproc_to_source, output_dir), "Sources"),
]),
])
# fmt:on

Expand Down

0 comments on commit 305b990

Please sign in to comment.