Skip to content

Commit 1e45712

Browse files
authored
Add templateflow to DatasetLinks (#3267)
References #3261. ## Changes proposed in this pull request - Add the TemplateFlow base directory to the DatasetLinks. - Add the template used for normalization to the Sources for standard-space volumetric outputs.
1 parent 123c3f8 commit 1e45712

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

fmriprep/config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
import os
9292
from multiprocessing import set_start_method
9393

94+
from templateflow.conf import TF_LAYOUT
95+
9496
# Disable NiPype etelemetry always
9597
_disable_et = bool(os.getenv('NO_ET') is not None or os.getenv('NIPYPE_NO_ET') is not None)
9698
os.environ['NIPYPE_NO_ET'] = '1'
@@ -525,7 +527,10 @@ def _process_value(value):
525527
for k, v in filters.items():
526528
cls.bids_filters[acq][k] = _process_value(v)
527529

528-
dataset_links = {'raw': cls.bids_dir}
530+
dataset_links = {
531+
'raw': cls.bids_dir,
532+
'templateflow': Path(TF_LAYOUT.root),
533+
}
529534
for deriv_name, deriv_path in cls.derivatives.items():
530535
dataset_links[deriv_name] = deriv_path
531536
cls.dataset_links = dataset_links

fmriprep/utils/bids.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ def write_derivative_description(bids_dir, deriv_dir, dataset_links=None):
148148
# Add DatasetLinks
149149
if dataset_links:
150150
desc['DatasetLinks'] = {k: str(v) for k, v in dataset_links.items()}
151+
if 'templateflow' in dataset_links:
152+
desc['DatasetLinks']['templateflow'] = 'https://github.com/templateflow/templateflow'
151153

152154
Path.write_text(deriv_dir / 'dataset_description.json', json.dumps(desc, indent=4))
153155

fmriprep/workflows/bold/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ def init_bold_wf(
424424
('outputnode.bold_mask', 'inputnode.bold_mask'),
425425
('outputnode.coreg_boldref', 'inputnode.bold_ref'),
426426
('outputnode.boldref2anat_xfm', 'inputnode.boldref2anat_xfm'),
427+
('outputnode.motion_xfm', 'inputnode.motion_xfm'),
428+
('outputnode.boldref2fmap_xfm', 'inputnode.boldref2fmap_xfm'),
427429
]),
428430
(bold_native_wf, ds_bold_t1_wf, [('outputnode.t2star_map', 'inputnode.t2star')]),
429431
(bold_anat_wf, ds_bold_t1_wf, [
@@ -474,6 +476,7 @@ def init_bold_wf(
474476
]),
475477
(inputnode, ds_bold_std_wf, [
476478
('anat2std_xfm', 'inputnode.anat2std_xfm'),
479+
('std_t1w', 'inputnode.template'),
477480
('std_space', 'inputnode.space'),
478481
('std_resolution', 'inputnode.resolution'),
479482
('std_cohort', 'inputnode.cohort'),
@@ -482,6 +485,8 @@ def init_bold_wf(
482485
('outputnode.bold_mask', 'inputnode.bold_mask'),
483486
('outputnode.coreg_boldref', 'inputnode.bold_ref'),
484487
('outputnode.boldref2anat_xfm', 'inputnode.boldref2anat_xfm'),
488+
('outputnode.motion_xfm', 'inputnode.motion_xfm'),
489+
('outputnode.boldref2fmap_xfm', 'inputnode.boldref2fmap_xfm'),
485490
]),
486491
(bold_native_wf, ds_bold_std_wf, [('outputnode.t2star_map', 'inputnode.t2star')]),
487492
(bold_std_wf, ds_bold_std_wf, [

fmriprep/workflows/bold/outputs.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ def init_ds_bold_native_wf(
659659
('source_files', 'source_file'),
660660
('bold', 'in_file'),
661661
]),
662+
(sources, ds_bold, [('out', 'Sources')]),
662663
]) # fmt:skip
663664

664665
if bold_output and multiecho:
@@ -734,6 +735,7 @@ def init_ds_volumes_wf(
734735
'bold_mask', # boldref space
735736
'bold_ref', # boldref space
736737
't2star', # boldref space
738+
'template', # target reference image from original transform
737739
# Anatomical
738740
'boldref2anat_xfm',
739741
# Template
@@ -742,14 +744,17 @@ def init_ds_volumes_wf(
742744
'space',
743745
'cohort',
744746
'resolution',
747+
# Transforms previously used to generate the outputs
748+
'motion_xfm',
749+
'boldref2fmap_xfm',
745750
]
746751
),
747752
name='inputnode',
748753
)
749754

750755
sources = pe.Node(
751756
BIDSURI(
752-
numinputs=3,
757+
numinputs=6,
753758
dataset_links=config.execution.dataset_links,
754759
out_dir=str(config.execution.fmriprep_dir.absolute()),
755760
),
@@ -774,8 +779,11 @@ def init_ds_volumes_wf(
774779
workflow.connect([
775780
(inputnode, sources, [
776781
('source_files', 'in1'),
777-
('boldref2anat_xfm', 'in2'),
778-
('anat2std_xfm', 'in3'),
782+
('motion_xfm', 'in2'),
783+
('boldref2fmap_xfm', 'in3'),
784+
('boldref2anat_xfm', 'in4'),
785+
('anat2std_xfm', 'in5'),
786+
('template', 'in6'),
779787
]),
780788
(inputnode, boldref2target, [
781789
# Note that ANTs expects transforms in target-to-source order

0 commit comments

Comments
 (0)