Skip to content

Commit 355159a

Browse files
committed
FIX: backport niworkflows utility function
1 parent 02a824e commit 355159a

File tree

5 files changed

+27
-3
lines changed

5 files changed

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

sdcflows/workflows/outputs.py

Lines changed: 1 addition & 1 deletion
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

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)