diff --git a/xcp_d/workflows/outputs.py b/xcp_d/workflows/outputs.py index ac39367fc..96c51e2ff 100644 --- a/xcp_d/workflows/outputs.py +++ b/xcp_d/workflows/outputs.py @@ -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 @@ -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 @@ -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( @@ -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 @@ -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"), @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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