Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .circle/data/ds005_outputs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ ds005/out/fmriprep/sub-01/anat/sub-01_T1w_space-MNI152NLin2009cAsym_target-T1w_w
ds005/out/fmriprep/sub-01/anat/sub-01_T1w_space-orig_target-T1w_affine.txt
ds005/out/fmriprep/sub-01/anat/sub-01_T1w_target-fsnative_affine.txt
ds005/out/fmriprep/sub-01/anat/sub-01_T1w_target-MNI152NLin2009cAsym_warp.h5
ds005/out/fmriprep/sub-01/figures
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_anat_sub-01_T1w_reconall.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_anat_sub-01_T1w_t1_2_mni.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_anat_sub-01_T1w_t1_seg.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_anat_sub-01_T1w_t1_skull_strip.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-01_bold_acompcor.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-01_bold_bbr.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-01_bold_bold_mask.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-01_bold_ica_aroma.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-01_bold_syn_sdc.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-01_bold_tcompcor.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-02_bold_acompcor.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-02_bold_bbr.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-02_bold_bold_mask.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-02_bold_ica_aroma.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-02_bold_syn_sdc.svg
ds005/out/fmriprep/sub-01/figures/_scratch_reportlets_fmriprep_sub-01_func_sub-01_task-mixedgamblestask_run-02_bold_tcompcor.svg
ds005/out/fmriprep/sub-01/func
ds005/out/fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_bold_AROMAnoiseICs.csv
ds005/out/fmriprep/sub-01/func/sub-01_task-mixedgamblestask_run-01_bold_confounds.tsv
Expand Down
21 changes: 21 additions & 0 deletions .circle/data/ds054_outputs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ ds054/out/fmriprep/sub-100185/anat/sub-100185_T1w_space-MNI152NLin2009cAsym_prep
ds054/out/fmriprep/sub-100185/anat/sub-100185_T1w_space-MNI152NLin2009cAsym_target-T1w_warp.h5
ds054/out/fmriprep/sub-100185/anat/sub-100185_T1w_space-orig_target-T1w_affine.txt
ds054/out/fmriprep/sub-100185/anat/sub-100185_T1w_target-MNI152NLin2009cAsym_warp.h5
ds054/out/fmriprep/sub-100185/figures
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_anat_sub-100185_T1w_t1_2_mni.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_anat_sub-100185_T1w_t1_seg.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_anat_sub-100185_T1w_t1_skull_strip.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_fmap_sub-100185_phasediff_fmap_mask.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-01_bold_acompcor.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-01_bold_bold_mask.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-01_bold_flt_bbr.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-01_bold_fmap_reg.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-01_bold_fmap_reg_vsm.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-01_bold_syn_sdc.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-01_bold_tcompcor.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-01_bold_variant-hmcsdc_preproc.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-02_bold_acompcor.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-02_bold_bold_mask.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-02_bold_flt_bbr.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-02_bold_fmap_reg.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-02_bold_fmap_reg_vsm.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-02_bold_syn_sdc.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-02_bold_tcompcor.svg
ds054/out/fmriprep/sub-100185/figures/_scratch_reportlets_fmriprep_sub-100185_func_sub-100185_task-machinegame_run-02_bold_variant-hmcsdc_preproc.svg
ds054/out/fmriprep/sub-100185/func
ds054/out/fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_bold_confounds.tsv
ds054/out/fmriprep/sub-100185/func/sub-100185_task-machinegame_run-01_bold_space-MNI152NLin2009cAsym_brainmask.nii.gz
Expand Down
2 changes: 1 addition & 1 deletion docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ dependencies:
- svgutils
- nitime
- nilearn
- niworkflows>=0.1.11
- niworkflows>=0.2.0
28 changes: 17 additions & 11 deletions fmriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,14 @@ def main():
work_dir = retval['work_dir']
subject_list = retval['subject_list']
run_uuid = retval['run_uuid']
retcode = retval['return_code']

if opts.write_graph:
fmriprep_wf.write_graph(graph2use="colored", format='svg', simple_form=True)

if opts.reports_only:
sys.exit(int(retcode > 0))

# Clean up master process before running workflow, which may create forks
gc.collect()
try:
Expand Down Expand Up @@ -359,14 +363,21 @@ def build_workflow(opts, retval):
},
})

retval['return_code'] = 0
retval['plugin_settings'] = plugin_settings
retval['output_dir'] = output_dir
retval['work_dir'] = work_dir
retval['subject_list'] = subject_list
retval['run_uuid'] = run_uuid

# Called with reports only
if opts.reports_only:
logger.log(25, 'Running --reports-only on participants %s', ', '.join(subject_list))
if opts.run_uuid is not None:
run_uuid = opts.run_uuid

reports_code = generate_reports(subject_list, output_dir, work_dir, run_uuid)
sys.exit(int(reports_code > 0))
retval['return_code'] = generate_reports(subject_list, output_dir, work_dir, run_uuid)
retval['workflow'] = None
return retval

# Build main workflow
logger.log(25, INIT_MSG(
Expand All @@ -376,7 +387,7 @@ def build_workflow(opts, retval):
uuid=run_uuid)
)

fmriprep_wf = init_fmriprep_wf(
retval['workflow'] = init_fmriprep_wf(
subject_list=subject_list,
task_id=opts.task_id,
run_uuid=run_uuid,
Expand Down Expand Up @@ -405,13 +416,8 @@ def build_workflow(opts, retval):
use_aroma=opts.use_aroma,
ignore_aroma_err=opts.ignore_aroma_denoising_errors,
)

retval['workflow'] = fmriprep_wf
retval['plugin_settings'] = plugin_settings
retval['output_dir'] = output_dir
retval['work_dir'] = work_dir
retval['subject_list'] = subject_list
retval['run_uuid'] = run_uuid
retval['return_code'] = 0
return retval


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
'grabbit',
'pybids>=0.4.2',
'nitime',
'niworkflows>=0.1.11',
'niworkflows>=0.2.0',
'statsmodels',
'nipype',
'seaborn',
Expand Down
25 changes: 19 additions & 6 deletions fmriprep/viz/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import re
import os
import html
import shutil

import jinja2
from niworkflows.nipype.utils.filemanip import loadcrash
Expand Down Expand Up @@ -111,21 +112,33 @@ def _load_config(self, config):
self.index()

def index(self):
fig_dir = 'figures'
subject_dir = self.root.split('/')[-1]
subject = re.search('^(?P<subject_id>sub-[a-zA-Z0-9]+)$', subject_dir).group()
svg_dir = os.path.join(self.out_dir, 'fmriprep', subject, fig_dir)
os.makedirs(svg_dir, exist_ok=True)

for root, directories, filenames in os.walk(self.root):
for f in filenames:
f = os.path.join(root, f)
for sub_report in self.sub_reports:
for element in sub_report.elements:
ext = f.split('.')[-1]
if element.file_pattern.search(f) and (ext == 'svg' or ext == 'html'):
with open(f) as fp:
content = fp.read()
element.files_contents.append((f, content))
if element.file_pattern.search(f) and ext in ('svg', 'html'):
if ext == 'html':
with open(f) as fp:
content = fp.read()
else:
fbase = f.replace('/', '_')
newf = os.path.join(svg_dir, fbase)
shutil.copy(f, newf)
content = """\
<object type="image/svg+xml" data="./{0}" class="reportlet">filename:{0}</object>\
""".format(os.path.join(subject, fig_dir, fbase))
element.files_contents.append((f, content))
for sub_report in self.sub_reports:
sub_report.order_by_run()

subject_dir = self.root.split('/')[-1]
subject = re.search('^(?P<subject_id>sub-[a-zA-Z0-9]+)$', subject_dir).group()
error_dir = os.path.join(self.out_dir, "fmriprep", subject, 'log', self.run_uuid)
if os.path.isdir(error_dir):
self.index_error_dir(error_dir)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
niworkflows>=0.1.11
niworkflows>=0.2.0