Skip to content

Commit 0df1b24

Browse files
committed
FIX: backport niworkflows utility function
1 parent 02a824e commit 0df1b24

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.2.4 (May 4, 2020)
2+
===================
3+
Bug-fix release to ensure backwards compatibility with previous fMRIPrep versions.
4+
15
1.2.3 (April 16, 2020)
26
======================
37
Bug-fix release enforcing BIDS-Derivatives labels on ``dseg`` file.

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ git+https://github.com/rwblair/sphinxcontrib-versioning.git@39b40b0b84bf872fc398
33
nbsphinx
44
niflow-nipype1-workflows ~= 0.0.1
55
nipype>=1.3.1
6-
niworkflows >=1.2.0rc4,<1.4
6+
niworkflows ~= 1.1.12
77
packaging
88
pydot>=1.2.3
99
pydotplus

sdcflows/interfaces/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Backports
2+
3+
4+
def dseg_label(in_seg, label, newpath=None):
5+
"""Extract a particular label from a discrete segmentation."""
6+
from pathlib import Path
7+
import nibabel as nb
8+
import numpy as np
9+
from nipype.utils.filemanip import fname_presuffix
10+
11+
newpath = Path(newpath or '.')
12+
13+
nii = nb.load(in_seg)
14+
data = np.int16(nii.dataobj) == label
15+
16+
out_file = fname_presuffix(in_seg, suffix='_mask',
17+
newpath=str(newpath.absolute()))
18+
new = nii.__class__(data, nii.affine, nii.header)
19+
new.set_data_dtype(np.uint8)
20+
new.to_filename(out_file)
21+
return out_file

sdcflows/workflows/outputs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def init_sdc_unwarp_report_wf(name='sdc_unwarp_report_wf', forcedsyn=False):
4141
Affine transform from T1 space to BOLD space (ITK format)
4242
4343
"""
44+
from ..interfaces import dseg_label as _dseg_label
4445
from niworkflows.interfaces import SimpleBeforeAfter
4546
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
46-
from niworkflows.utils.images import dseg_label as _dseg_label
4747

4848
DEFAULT_MEMORY_MIN_GB = 0.01
4949

@@ -58,7 +58,10 @@ def init_sdc_unwarp_report_wf(name='sdc_unwarp_report_wf', forcedsyn=False):
5858

5959
sel_wm = pe.Node(niu.Function(function=_dseg_label), name='sel_wm',
6060
mem_gb=DEFAULT_MEMORY_MIN_GB)
61-
sel_wm.inputs.label = 2
61+
# API CHANGE: sMRIPrep 0.6.x
62+
# https://github.com/poldracklab/smriprep/issues/176
63+
# https://github.com/poldracklab/smriprep/pull/177 changes this to 2
64+
sel_wm.inputs.label = 3
6265

6366
bold_rpt = pe.Node(SimpleBeforeAfter(), name='bold_rpt',
6467
mem_gb=0.1)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ install_requires =
2929
nibabel >=3.0.1
3030
niflow-nipype1-workflows ~= 0.0.1
3131
nipype >=1.3.1,<2.0
32-
niworkflows >=1.2.0rc4,<1.4
32+
niworkflows ~= 1.1.12
3333
numpy
3434
pybids >= 0.9.2
3535
templateflow >=0.4

0 commit comments

Comments
 (0)