Skip to content

Commit 4aa93fc

Browse files
authored
Merge pull request #360 from effigies/fix/synthetic_intendedfor
FIX: Ensure IntendedFor metadata is a subject-relative path
2 parents b40d23a + c4ebb64 commit 4aa93fc

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

sdcflows/utils/tests/test_wrangler.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,43 @@
9595
}
9696
}
9797
]
98+
},
99+
{
100+
"session": "04",
101+
"anat": [{"suffix": "T1w", "metadata": {"EchoTime": 1}}],
102+
"fmap": [
103+
{"suffix": "epi", "dir": "AP", "metadata": {
104+
"EchoTime": 1.2,
105+
"PhaseEncodingDirection": "j-",
106+
"TotalReadoutTime": 0.8,
107+
"IntendedFor": [
108+
"ses-04/func/sub-01_ses-04_task-rest_run-1_bold.nii.gz",
109+
"ses-04/func/sub-01_ses-04_task-rest_run-2_bold.nii.gz",
110+
],
111+
}},
112+
],
113+
"func": [
114+
{
115+
"task": "rest",
116+
"run": 1,
117+
"suffix": "bold",
118+
"metadata": {
119+
"RepetitionTime": 0.8,
120+
"TotalReadoutTime": 0.5,
121+
"PhaseEncodingDirection": "j"
122+
}
123+
},
124+
{
125+
"task": "rest",
126+
"run": 2,
127+
"suffix": "bold",
128+
"metadata": {
129+
"RepetitionTime": 0.8,
130+
"TotalReadoutTime": 0.5,
131+
"PhaseEncodingDirection": "j"
132+
}
133+
},
134+
]
98135
}
99136
]
100137
}
@@ -216,3 +253,20 @@ def test_wrangler_filter(tmpdir, name, skeleton, estimations):
216253
est = find_estimators(layout=layout, subject='01', bids_filters=filters['fmap'])
217254
assert len(est) == estimations
218255
clear_registry()
256+
257+
258+
def test_single_reverse_pedir(tmp_path):
259+
bids_dir = tmp_path / "bids"
260+
generate_bids_skeleton(bids_dir, pepolar)
261+
layout = gen_layout(bids_dir)
262+
est = find_estimators(layout=layout, subject='01', bids_filters={'session': '04'})
263+
assert len(est) == 2
264+
subject_root = bids_dir / 'sub-01'
265+
for estimator in est:
266+
assert len(estimator.sources) == 2
267+
epi, bold = estimator.sources
268+
# Just checking order
269+
assert epi.entities['fmap'] == 'epi'
270+
# IntendedFor is a list of strings
271+
# REGRESSION: The result was a PyBIDS BIDSFile (fmriprep#3020)
272+
assert epi.metadata['IntendedFor'] == [str(bold.path.relative_to(subject_root))]

sdcflows/utils/wrangler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,10 @@ def find_estimators(
459459
# The new estimator is IntendedFor the individual targets,
460460
# even if the EPI file is IntendedFor multiple
461461
estimator_md = epi_base_md.copy()
462-
estimator_md["IntendedFor"] = intent
462+
estimator_md["IntendedFor"] = [
463+
str(Path(pathlike).relative_to(subject_root))
464+
for pathlike in intent
465+
]
463466
try:
464467
e = fm.FieldmapEstimation(
465468
[

0 commit comments

Comments
 (0)