Skip to content

Commit d08bc13

Browse files
oestebaneffigies
andauthored
Apply suggestions from code review
Co-Authored-By: Chris Markiewicz <[email protected]>
1 parent b7a7006 commit d08bc13

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

niworkflows/utils/images.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,14 @@ def dseg_label(in_seg, label, newpath=None):
116116
import numpy as np
117117
from nipype.utils.filemanip import fname_presuffix
118118

119-
if newpath is None:
120-
newpath = Path()
121-
newpath = Path(newpath)
119+
newpath = Path(newpath or '.')
122120

123121
nii = nb.load(in_seg)
124-
data = np.asanyarray(nii.dataobj, dtype='int16') == label
122+
data = np.int16(nii.dataobj) == label
125123

126124
out_file = fname_presuffix(in_seg, suffix='_mask',
127125
newpath=str(newpath.absolute()))
128-
new = nb.Nifti1Image(data, nii.affine, nii.header)
126+
new = nii.__class__(data, nii.affine, nii.header)
129127
new.set_data_dtype(np.uint8)
130128
new.to_filename(out_file)
131129
return out_file

0 commit comments

Comments
 (0)