From 24788628028bd30a50fbeddbaa5a468d7a0ffc5c Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Sun, 19 Apr 2020 16:59:22 -0700 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: Chris Markiewicz --- smriprep/workflows/anatomical.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/smriprep/workflows/anatomical.py b/smriprep/workflows/anatomical.py index 95fa8ac52f..ec1d8c7604 100644 --- a/smriprep/workflows/anatomical.py +++ b/smriprep/workflows/anatomical.py @@ -431,7 +431,7 @@ def _check_img(img): return workflow # Map FS' aseg labels onto three-tissue segmentation - lut_t1w_dseg.inputs.lut = _aseg_two_three() + lut_t1w_dseg.inputs.lut = _aseg_to_three() split_seg = pe.Node(niu.Function(function=_split_segments), name='split_seg') @@ -633,7 +633,7 @@ def _pop(inlist): return inlist -def _aseg_two_three(): +def _aseg_to_three(): import numpy as np # Base struct aseg_lut = np.zeros((256,), dtype="int") @@ -676,10 +676,9 @@ def _split_segments(in_file): hdr.set_data_dtype('uint8') out_files = [] - for i, label in enumerate(("CSF", "WM", "GM")): - out_fname = str((Path() / f"aseg_label-{label}_mask.nii.gz").absolute()) - segment = (data == i + 1).astype('uint8') - segimg.__class__(segment, segimg.affine, hdr).to_filename(out_fname) + for i, label in enumerate(("CSF", "WM", "GM"), 1): + out_fname = str(Path.cwd() / f"aseg_label-{label}_mask.nii.gz") + segimg.__class__(data == i, segimg.affine, hdr).to_filename(out_fname) out_files.append(out_fname) return out_files