Skip to content

Commit 014d765

Browse files
committed
[skip ci] Merge remote-tracking branch 'upstream/master' into enh/keyselect-interface
2 parents ce02a55 + 076aed9 commit 014d765

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

niworkflows/interfaces/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ class GenerateSamplingReferenceInputSpec(BaseInterfaceInputSpec):
126126
desc='force xform code')
127127
fov_mask = traits.Either(None, File(exists=True), usedefault=True,
128128
desc='mask to clip field of view (in fixed_image space)')
129+
keep_native = traits.Bool(True, usedefault=True,
130+
desc='calculate a grid with native resolution covering '
131+
'the volume extent given by fixed_image, fast forward '
132+
'fixed_image otherwise.')
129133

130134

131135
class GenerateSamplingReferenceOutputSpec(TraitedSpec):
@@ -151,6 +155,9 @@ class GenerateSamplingReference(SimpleInterface):
151155
output_spec = GenerateSamplingReferenceOutputSpec
152156

153157
def _run_interface(self, runtime):
158+
if not self.inputs.keep_native:
159+
self._results['out_file'] = self.inputs.fixed_image
160+
return runtime
154161
self._results['out_file'] = _gen_reference(
155162
self.inputs.fixed_image,
156163
self.inputs.moving_image,

niworkflows/reports/core.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ class Report(object):
188188
.. doctest::
189189
190190
>>> robj = Report(testdir / 'work' / 'reportlets', testdir / 'out',
191-
... 'madeoutuuid', subject_id='01')
191+
... 'madeoutuuid', subject_id='01', packagename='fmriprep')
192192
>>> robj.layout.get(subject='01', desc='reconall')
193-
[<BIDSFile filename='fmriprep/sub-01/anat/sub-01_desc-reconall_T1w.svg'>]
193+
[<BIDSFile filename='anat/sub-01_desc-reconall_T1w.svg'>]
194194
195195
>>> robj.generate_report()
196196
0
197-
>>> len((testdir / 'out' / 'niworkflows' / 'sub-01.html').read_text())
197+
>>> len((testdir / 'out' / 'fmriprep' / 'sub-01.html').read_text())
198198
20862
199199
200200
"""
@@ -204,13 +204,12 @@ def __init__(self, reportlets_dir, out_dir, run_uuid, config=None,
204204
packagename=None):
205205
self.root = reportlets_dir
206206

207-
# Initialize a BIDS layout
207+
# Add a new figures spec
208208
try:
209209
add_config_paths(figures=pkgrf('niworkflows', 'reports/figures.json'))
210210
except ValueError as e:
211211
if "Configuration 'figures' already exists" != str(e):
212212
raise
213-
self.layout = BIDSLayout(self.root, config='figures', validate=False)
214213

215214
# Initialize structuring elements
216215
self.sections = []
@@ -232,7 +231,7 @@ def __init__(self, reportlets_dir, out_dir, run_uuid, config=None,
232231
self._load_config(Path(config))
233232

234233
def _load_config(self, config):
235-
from yaml import load
234+
from yaml import safe_load as load
236235
settings = load(config.read_text())
237236
self.packagename = self.packagename or settings.get('package', None)
238237

@@ -252,8 +251,11 @@ def _load_config(self, config):
252251
def index(self, config):
253252
"""
254253
Traverse the reports config definition and instantiate reportlets.
254+
255255
This method also places figures in their final location.
256256
"""
257+
# Initialize a BIDS layout
258+
self.layout = BIDSLayout(self.root, config='figures', validate=False)
257259
for subrep_cfg in config:
258260
# First determine whether we need to split by some ordering
259261
# (ie. sessions / tasks / runs), which are separated by commas.
@@ -297,9 +299,8 @@ def index(self, config):
297299
title=subrep_cfg.get('title'))
298300
self.sections.append(sub_report)
299301

300-
# Populate errors sections
301-
error_dir = self.out_dir / self.packagename / 'sub-{}'.format(self.subject_id) / \
302-
'log' / self.run_uuid
302+
# Populate errors section
303+
error_dir = self.out_dir / 'sub-{}'.format(self.subject_id) / 'log' / self.run_uuid
303304
if error_dir.is_dir():
304305
from ..utils.misc import read_crashfile
305306
self.errors = [read_crashfile(str(f)) for f in error_dir.glob('crash*.*')]
@@ -368,16 +369,16 @@ def run_reports(reportlets_dir, out_dir, subject_label, run_uuid, config=None,
368369
369370
.. doctest::
370371
371-
>>> run_reports(str(testdir / 'work' / 'reportlets'),
372-
... str(testdir / 'out'), '01', 'madeoutuuid')
372+
>>> run_reports(testdir / 'work' / 'reportlets', testdir / 'out',
373+
... '01', 'madeoutuuid', packagename='fmriprep')
373374
0
374375
375376
.. testcleanup::
376377
377378
>>> tmpdir.cleanup()
378379
379380
"""
380-
report = Report(Path(reportlets_dir), out_dir, run_uuid, config=config,
381+
report = Report(reportlets_dir, out_dir, run_uuid, config=config,
381382
subject_id=subject_label, packagename=packagename)
382383
return report.generate_report()
383384

@@ -387,9 +388,9 @@ def generate_reports(subject_list, output_dir, work_dir, run_uuid, config=None,
387388
"""
388389
A wrapper to run_reports on a given ``subject_list``
389390
"""
390-
reports_dir = str(Path(work_dir) / 'reportlets')
391+
reportlets_dir = Path(work_dir) / 'reportlets'
391392
report_errors = [
392-
run_reports(reports_dir, output_dir, subject_label, run_uuid,
393+
run_reports(reportlets_dir, output_dir, subject_label, run_uuid,
393394
config, packagename=packagename)
394395
for subject_label in subject_list
395396
]

niworkflows/reports/fmriprep.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ sections:
6464
desc: '[at]compcor'
6565
extensions: [.html]
6666
suffix: bold
67+
- bids: {datatype: func, desc: '[at]compcorvar', suffix: bold}
68+
caption: The cumulative variance explained by the first k components of the
69+
<em>t/aCompCor</em> decomposition, plotted for all values of <em>k</em>.
70+
The number of components that must be included in the model in order to
71+
explain some fraction of variance in the decomposition mask can be used
72+
as a feature selection criterion for confound regression.
73+
- bids: {datatype: func, desc: 'confoundcorr', suffix: bold}
74+
caption: |
75+
Left: Heatmap summarizing the correlation structure among confound variables.
76+
(Cosine bases and PCA-derived CompCor components are inherently orthogonal.)
77+
Right: magnitude of the correlation between each confound time series and the
78+
mean global signal. Strong correlations might be indicative of partial volume
79+
effects and can inform decisions about feature orthogonalization prior to
80+
confound regression.
81+
subtitle: Correlations among nuisance regressors
6782
- bids: {datatype: func, desc: flirtnobbr, suffix: bold}
6883
caption: FSL <code>flirt</code> was used to generate transformations from EPI
6984
space to T1 Space - BBR refinement rejected. Note that Nearest Neighbor interpolation

0 commit comments

Comments
 (0)