Skip to content

Commit 0d582f6

Browse files
authored
Merge pull request #1346 from kasbohm/patch-1
[FIX] Missing report output - #1339
2 parents e706408 + 3de9874 commit 0d582f6

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

.zenodo.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878
"affiliation": "Department of Psychology, Florida International University",
7979
"orcid": "0000-0001-9813-3167"
8080
},
81+
{
82+
"name": "Amlien, Inge K.",
83+
"affiliation": "Department of Psychology, University of Oslo",
84+
"orcid": "0000-0002-8508-9088"
85+
},
8186
{
8287
"name": "Poldrack, Russell A.",
8388
"affiliation": "Department of Psychology, Stanford University",

fmriprep/interfaces/bids.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,35 @@ class DerivativesDataSink(SimpleInterface):
184184
Saves the `in_file` into a BIDS-Derivatives folder provided
185185
by `base_directory`, given the input reference `source_file`.
186186
187+
>>> from pathlib import Path
187188
>>> import tempfile
188189
>>> from fmriprep.utils.bids import collect_data
189-
>>> tmpdir = tempfile.mkdtemp()
190-
>>> tmpfile = os.path.join(tmpdir, 'a_temp_file.nii.gz')
191-
>>> open(tmpfile, 'w').close() # "touch" the file
192-
>>> dsink = DerivativesDataSink(base_directory=tmpdir)
193-
>>> dsink.inputs.in_file = tmpfile
190+
>>> tmpdir = Path(tempfile.mkdtemp())
191+
>>> tmpfile = tmpdir / 'a_temp_file.nii.gz'
192+
>>> tmpfile.open('w').close() # "touch" the file
193+
>>> dsink = DerivativesDataSink(base_directory=str(tmpdir))
194+
>>> dsink.inputs.in_file = str(tmpfile)
194195
>>> dsink.inputs.source_file = collect_data('ds114', '01')[0]['t1w'][0]
195196
>>> dsink.inputs.keep_dtype = True
196197
>>> dsink.inputs.suffix = 'target-mni'
197198
>>> res = dsink.run()
198199
>>> res.outputs.out_file # doctest: +ELLIPSIS
199200
'.../fmriprep/sub-01/ses-retest/anat/sub-01_ses-retest_target-mni_T1w.nii.gz'
200201
202+
>>> bids_dir = tmpdir / 'bidsroot' / 'sub-02' / 'ses-noanat' / 'func'
203+
>>> bids_dir.mkdir(parents=True, exist_ok=True)
204+
>>> tricky_source = bids_dir / 'sub-02_ses-noanat_task-rest_run-01_bold.nii.gz'
205+
>>> tricky_source.open('w').close()
206+
>>> dsink = DerivativesDataSink(base_directory=str(tmpdir))
207+
>>> dsink.inputs.in_file = str(tmpfile)
208+
>>> dsink.inputs.source_file = str(tricky_source)
209+
>>> dsink.inputs.keep_dtype = True
210+
>>> dsink.inputs.desc = 'preproc'
211+
>>> res = dsink.run()
212+
>>> res.outputs.out_file # doctest: +ELLIPSIS
213+
'.../fmriprep/sub-02/ses-noanat/func/sub-02_ses-noanat_task-rest_run-01_\
214+
desc-preproc_bold.nii.gz'
215+
201216
"""
202217
input_spec = DerivativesDataSinkInputSpec
203218
output_spec = DerivativesDataSinkOutputSpec
@@ -221,15 +236,7 @@ def _run_interface(self, runtime):
221236

222237
m = BIDS_NAME.search(src_fname)
223238

224-
# TODO this quick and dirty modality detection needs to be implemented
225-
# correctly
226-
mod = 'func'
227-
if 'anat' in op.dirname(self.inputs.source_file):
228-
mod = 'anat'
229-
elif 'dwi' in op.dirname(self.inputs.source_file):
230-
mod = 'dwi'
231-
elif 'fmap' in op.dirname(self.inputs.source_file):
232-
mod = 'fmap'
239+
mod = op.basename(op.dirname(self.inputs.source_file))
233240

234241
base_directory = runtime.cwd
235242
if isdefined(self.inputs.base_directory):

0 commit comments

Comments
 (0)