Skip to content

Commit 1d77247

Browse files
committed
Merge branch 'fix/osf-templates' into enh/3dvolreg
2 parents c0db97f + 9b67991 commit 1d77247

File tree

8 files changed

+68
-38
lines changed

8 files changed

+68
-38
lines changed

.circleci/config.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ jobs:
165165
steps:
166166
- restore_cache:
167167
keys:
168-
- regression-v0-{{ epoch }}
169-
- regression-v0-
168+
- regression-v2-{{ epoch }}
169+
- regression-v2-
170170
- run:
171171
name: Get truncated BOLD series
172172
command: |
@@ -193,7 +193,7 @@ jobs:
193193
paths:
194194
- data
195195
- save_cache:
196-
key: regression-v0-{{ epoch }}
196+
key: regression-v2-{{ epoch }}
197197
paths:
198198
- /tmp/data
199199

@@ -227,10 +227,6 @@ jobs:
227227
fi
228228
- attach_workspace:
229229
at: /tmp
230-
- restore_cache:
231-
keys:
232-
- regression-v0-{{ epoch }}
233-
- regression-v0-
234230
- run:
235231
name: Check PyPi preconditions
236232
command: |
@@ -260,7 +256,13 @@ jobs:
260256
-e FMRIPREP_REGRESSION_REPORTS=/tmp/data/reports \
261257
--entrypoint="py.test" poldracklab/fmriprep:latest \
262258
/root/src/fmriprep/ \
263-
--doctest-modules --ignore=/root/src/fmriprep/docs --ignore=setup.py
259+
-svx --doctest-modules --ignore=/root/src/fmriprep/docs --ignore=setup.py
260+
- run:
261+
name: Package new masks
262+
no_output_timeout: 10m
263+
working_directory: /tmp/data/reports
264+
command: |
265+
tar cfz fmriprep_bold_mask.tar.gz fmriprep_bold_mask/*/*.nii.gz
264266
- run:
265267
name: Test fmriprep-wrapper (Python 2)
266268
command: |
@@ -719,7 +721,9 @@ workflows:
719721
- get_data:
720722
filters:
721723
branches:
722-
ignore: /docs?\/.*/
724+
ignore:
725+
- /docs?\/.*/
726+
- /tests?\/.*/
723727
tags:
724728
only: /.*/
725729

@@ -732,6 +736,8 @@ workflows:
732736
requires:
733737
- build
734738
filters:
739+
branches:
740+
ignore: /tests?\/.*/
735741
tags:
736742
only: /.*/
737743

@@ -740,7 +746,9 @@ workflows:
740746
- build
741747
filters:
742748
branches:
743-
ignore: /docs?\/.*/
749+
ignore:
750+
- /docs?\/.*/
751+
- /tests?\/.*/
744752
tags:
745753
only: /.*/
746754

@@ -760,7 +768,9 @@ workflows:
760768
- build
761769
filters:
762770
branches:
763-
ignore: /docs?\/.*/
771+
ignore:
772+
- /docs?\/.*/
773+
- /tests?\/.*/
764774
tags:
765775
only: /.*/
766776

@@ -770,7 +780,9 @@ workflows:
770780
- build
771781
filters:
772782
branches:
773-
ignore: /docs?\/.*/
783+
ignore:
784+
- /docs?\/.*/
785+
- /tests?\/.*/
774786
tags:
775787
only: /.*/
776788

@@ -781,7 +793,9 @@ workflows:
781793
filters:
782794
branches:
783795
# only: /meepi.*/
784-
ignore: /docs?\/.*/
796+
ignore:
797+
- /docs?\/.*/
798+
- /tests?\/.*/
785799
tags:
786800
only: /.*/
787801

fmriprep/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
'pybids==0.6.5',
9999
'nitime',
100100
'nipype>=1.1.3',
101-
'niworkflows>=0.4.3',
101+
'niworkflows>=0.4.4',
102102
'statsmodels',
103103
'seaborn',
104104
'indexed_gzip>=0.8.2',

fmriprep/interfaces/cifti.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,9 @@ def _fetch_data(self):
130130
raise IOError("Freesurfer annotations for %s not found in %s" % (
131131
self.inputs.surface_target, self.inputs.subjects_dir))
132132

133-
label_space = 'tpl-OASISTRT20'
134-
label_dir = getters.get_oasis_dkt31_mni152()
135-
label_file = os.path.join(label_dir,
136-
'tpl-OASISTRT20_variant-DKT31_space-MNI152NLin2009cAsym.nii.gz')
133+
label_space = 'OASISTRT20'
134+
label_file = str(getters.get_template(label_space) /
135+
'tpl-OASISTRT20_variant-DKT31_space-MNI152NLin2009cAsym.nii.gz')
137136

138137
download_link = getters.OSF_PROJECT_URL + getters.OSF_RESOURCES[label_space][0]
139138
return annotation_files, label_file, download_link

fmriprep/viz/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
},
101101
{
102102
"name": "epi_mean_t1_registration/flirt",
103-
"file_pattern": "func/.*_flirt",
103+
"file_pattern": "func/.*_flirtnobbr",
104104
"title": "EPI to T1 registration",
105105
"description": "FSL <code>flirt</code> was used to generate transformations from EPI space to T1 Space - BBR refinement rejected"
106106
},

fmriprep/viz/reports.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _read_pkl(path):
145145

146146
@staticmethod
147147
def _read_txt(path):
148-
lines = path.read_text().splitlines()
148+
lines = path.read_text(encoding='UTF-8').splitlines()
149149
data = {'file': str(path)}
150150
traceback_start = 0
151151
if lines[0].startswith('Node'):
@@ -170,27 +170,27 @@ def generate_report(self):
170170
boiler_idx = 0
171171

172172
if (logs_path / 'CITATION.html').exists():
173-
text = (logs_path / 'CITATION.html').read_text()
173+
text = (logs_path / 'CITATION.html').read_text(encoding='UTF-8')
174174
text = '<div class="boiler-html">%s</div>' % re.compile(
175175
'<body>(.*?)</body>',
176176
re.DOTALL | re.IGNORECASE).findall(text)[0].strip()
177177
boilerplate.append((boiler_idx, 'HTML', text))
178178
boiler_idx += 1
179179

180180
if (logs_path / 'CITATION.md').exists():
181-
text = '<pre>%s</pre>\n' % (logs_path / 'CITATION.md').read_text()
181+
text = '<pre>%s</pre>\n' % (logs_path / 'CITATION.md').read_text(encoding='UTF-8')
182182
boilerplate.append((boiler_idx, 'Markdown', text))
183183
boiler_idx += 1
184184

185185
if (logs_path / 'CITATION.tex').exists():
186-
text = (logs_path / 'CITATION.tex').read_text()
186+
text = (logs_path / 'CITATION.tex').read_text(encoding='UTF-8')
187187
text = re.compile(
188188
r'\\begin{document}(.*?)\\end{document}',
189189
re.DOTALL | re.IGNORECASE).findall(text)[0].strip()
190190
text = '<pre>%s</pre>\n' % text
191191
text += '<h3>Bibliography</h3>\n'
192192
text += '<pre>%s</pre>\n' % Path(
193-
pkgrf('fmriprep', 'data/boilerplate.bib')).read_text()
193+
pkgrf('fmriprep', 'data/boilerplate.bib')).read_text(encoding='UTF-8')
194194
boilerplate.append((boiler_idx, 'LaTeX', text))
195195
boiler_idx += 1
196196

@@ -204,7 +204,7 @@ def generate_report(self):
204204
boilerplate=boilerplate)
205205

206206
# Write out report
207-
(self.out_dir / 'fmriprep' / self.out_filename).write_text(report_render)
207+
(self.out_dir / 'fmriprep' / self.out_filename).write_text(report_render, encoding='UTF-8')
208208
return len(self.errors)
209209

210210

fmriprep/workflows/bold/registration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def init_bold_reg_wf(freesurfer, use_bbr, bold2t1w_dof, mem_gb, omp_nthreads,
157157

158158
def _bold_reg_suffix(fallback, freesurfer):
159159
if fallback:
160-
return 'coreg' if freesurfer else 'flirt'
160+
return 'coreg' if freesurfer else 'flirtnobbr'
161161
return 'bbregister' if freesurfer else 'flirtbbr'
162162

163163
workflow.connect([

fmriprep/workflows/bold/tests/test_util.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
''' Testing module for fmriprep.workflows.bold.util '''
22
import pytest
33
import os
4+
from pathlib import Path
45

56
import numpy as np
67
from nipype.pipeline import engine as pe
7-
from nipype.utils.filemanip import fname_presuffix
8+
from nipype.utils.filemanip import fname_presuffix, copyfile
89
from nilearn.image import load_img
910

1011
from niworkflows.interfaces.masks import ROIsPlot
@@ -46,33 +47,49 @@ def symmetric_overlap(img1, img2):
4647
'ds000216/sub-03_task-rest_echo-4_bold.nii.gz',
4748
'ds000237/sub-03_task-MemorySpan_acq-multiband_run-01_bold.nii.gz',
4849
'ds000237/sub-06_task-MemorySpan_acq-multiband_run-01_bold.nii.gz',
49-
)
50-
])
50+
'ds001240/sub-26_task-localizerimagination_bold.nii.gz',
51+
'ds001240/sub-26_task-localizerviewing_bold.nii.gz',
52+
'ds001240/sub-26_task-molencoding_run-01_bold.nii.gz',
53+
'ds001240/sub-26_task-molencoding_run-02_bold.nii.gz',
54+
'ds001240/sub-26_task-molretrieval_run-01_bold.nii.gz',
55+
'ds001240/sub-26_task-molretrieval_run-02_bold.nii.gz',
56+
'ds001240/sub-26_task-rest_bold.nii.gz',
57+
'ds001362/sub-01_task-taskname_run-01_bold.nii.gz',
58+
)
59+
])
5160
def test_masking(input_fname, expected_fname):
5261
bold_reference_wf = init_bold_reference_wf(omp_nthreads=1, enhance_t2=True)
5362
bold_reference_wf.inputs.inputnode.bold_file = input_fname
5463

5564
# Reconstruct base_fname from above
5665
dirname, basename = os.path.split(input_fname)
57-
newpath = os.path.join(os.getenv('FMRIPREP_REGRESSION_REPORTS', '.'),
58-
os.path.basename(dirname))
66+
dsname = os.path.basename(dirname)
67+
reports_dir = Path(os.getenv('FMRIPREP_REGRESSION_REPORTS', ''))
68+
newpath = reports_dir / dsname
5969
out_fname = fname_presuffix(basename, suffix='_masks.svg', use_ext=False,
60-
newpath=newpath)
61-
os.makedirs(newpath, exist_ok=True)
70+
newpath=str(newpath))
71+
newpath.mkdir(parents=True, exist_ok=True)
6272

6373
mask_diff_plot = pe.Node(ROIsPlot(), name='mask_diff_plot')
6474
mask_diff_plot.inputs.in_mask = expected_fname
6575
mask_diff_plot.inputs.out_report = out_fname
6676

77+
outputnode = bold_reference_wf.get_node('outputnode')
6778
bold_reference_wf.connect([
68-
(bold_reference_wf.get_node('outputnode'), mask_diff_plot, [
69-
('ref_image', 'in_file'),
70-
('bold_mask', 'in_rois'),
71-
])])
79+
(outputnode, mask_diff_plot, [('ref_image', 'in_file'),
80+
('bold_mask', 'in_rois')])
81+
])
7282
res = bold_reference_wf.run(plugin='MultiProc')
7383

7484
combine_masks = [node for node in res.nodes if node.name.endswith('combine_masks')][0]
7585
overlap = symmetric_overlap(expected_fname,
7686
combine_masks.result.outputs.out_file)
7787

88+
mask_dir = reports_dir / 'fmriprep_bold_mask' / dsname
89+
mask_dir.mkdir(parents=True, exist_ok=True)
90+
copyfile(combine_masks.result.outputs.out_file,
91+
fname_presuffix(basename, suffix='_mask',
92+
use_ext=True, newpath=str(mask_dir)),
93+
copy=True)
94+
7895
assert overlap > 0.95, input_fname

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
niworkflows>=0.4.3
1+
niworkflows>=0.4.4
22
grabbit==0.2.3
33
pybids==0.6.5
44
versioneer

0 commit comments

Comments
 (0)