Skip to content

Commit 68bf998

Browse files
committed
enh: keep track of templateflow home / demote some log traces
1 parent 9b03c31 commit 68bf998

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

fmriprep/config.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
from time import strftime
124124
from niworkflows.utils.spaces import SpatialReferences as _SRs, Reference as _Ref
125125
from nipype import logging as nlogging, __version__ as _nipype_ver
126+
from templateflow import __version__ as _tf_ver
126127
from . import __version__
127128

128129

@@ -154,6 +155,11 @@ def redirect_warnings(message, category, filename, lineno, file=None, line=None)
154155
if _fs_license is None and os.getenv('FREESURFER_HOME'):
155156
_fs_license = os.path.join(os.getenv('FREESURFER_HOME'), 'license.txt')
156157

158+
_templateflow_home = Path(os.getenv(
159+
'TEMPLATEFLOW_HOME',
160+
os.path.join(os.getenv('HOME'), '.cache', 'templateflow'))
161+
)
162+
157163

158164
class _Config:
159165
"""An abstract class forbidding instantiation."""
@@ -279,6 +285,9 @@ class execution(_Config):
279285
"""List of participant identifiers that are to be preprocessed."""
280286
task_id = None
281287
"""Select a particular task from all available in the dataset."""
288+
templateflow_home = _templateflow_home
289+
"""The root folder of the TemplateFlow client."""
290+
templateflow_version = _tf_ver
282291
version = __version__
283292
"""*fMRIPrep*'s version."""
284293
work_dir = Path('work').absolute()
@@ -295,6 +304,7 @@ class execution(_Config):
295304
'layout',
296305
'log_dir',
297306
'output_dir',
307+
'templateflow_home',
298308
'work_dir',
299309
)
300310

@@ -303,6 +313,8 @@ class execution(_Config):
303313
del _fs_license
304314
del _exec_env
305315
del _nipype_ver
316+
del _templateflow_home
317+
del _tf_ver
306318

307319

308320
class workflow(_Config):

fmriprep/workflows/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ def init_single_subject_wf(subject_id):
295295
('outputnode.fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm')]),
296296
])
297297

298+
# Dump a copy of the config file into the log directory
299+
log_dir = config.execution.output_dir / 'fmriprep' / 'sub-{}'.format(subject_id) \
300+
/ 'log' / config.execution.run_uuid
301+
log_dir.mkdir(exist_ok=True, parents=True)
302+
config.to_filename(log_dir / 'fmriprep.toml')
298303
return workflow
299304

300305

fmriprep/workflows/bold/base.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ def init_func_preproc_wf(bold_file):
166166
bold_tlen, mem_gb = _create_mem_gb(ref_file)
167167

168168
wf_name = _get_wf_name(ref_file)
169-
config.loggers.workflow.log(
170-
25, ('Creating bold processing workflow for "%s" (%.2f GB / %d TRs). '
171-
'Memory resampled/largemem=%.2f/%.2f GB.'),
169+
config.loggers.workflow.debug(
170+
'Creating bold processing workflow for "%s" (%.2f GB / %d TRs). '
171+
'Memory resampled/largemem=%.2f/%.2f GB.',
172172
ref_file, mem_gb['filesize'], bold_tlen, mem_gb['resampled'], mem_gb['largemem'])
173173

174174
sbref_file = None
@@ -771,8 +771,7 @@ def init_func_preproc_wf(bold_file):
771771
# Freesurfer
772772
freesurfer_spaces = spaces.get_fs_spaces()
773773
if freesurfer and freesurfer_spaces:
774-
config.loggers.workflow.log(
775-
25, 'Creating BOLD surface-sampling workflow.')
774+
config.loggers.workflow.debug('Creating BOLD surface-sampling workflow.')
776775
bold_surf_wf = init_bold_surf_wf(
777776
mem_gb=mem_gb['resampled'],
778777
surface_spaces=freesurfer_spaces,

0 commit comments

Comments
 (0)