From 1fc518bcafe432bbe278e866d454b08ff4ece216 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Wed, 22 Apr 2020 07:50:52 -0700 Subject: [PATCH 1/2] FIX: Merge/SplitSeries write to path of input image, instead of cwd Addresses an oversight in #489 . --- niworkflows/interfaces/nibabel.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/niworkflows/interfaces/nibabel.py b/niworkflows/interfaces/nibabel.py index 9c660d1d4c5..184f888bb70 100644 --- a/niworkflows/interfaces/nibabel.py +++ b/niworkflows/interfaces/nibabel.py @@ -125,7 +125,8 @@ def _run_interface(self, runtime): self._results["out_files"] = [] for i, img_3d in enumerate(nb.four_to_three(img)): out_file = str( - Path(fname_presuffix(in_file, suffix=f"_idx-{i:03}")).absolute() + Path(fname_presuffix(in_file, suffix=f"_idx-{i:03}", + newpath=runtime.cwd)).absolute() ) img_3d.to_filename(out_file) self._results["out_files"].append(out_file) @@ -169,7 +170,8 @@ def _run_interface(self, runtime): ) img_4d = nb.concat_images(nii_list) - out_file = fname_presuffix(self.inputs.in_files[0], suffix="_merged") + out_file = fname_presuffix(self.inputs.in_files[0], suffix="_merged", + newpath=runtime.cwd) img_4d.to_filename(out_file) self._results["out_file"] = out_file From af7aa277eb500a14bbd1d1dcd570a08d69e88255 Mon Sep 17 00:00:00 2001 From: oesteban Date: Wed, 22 Apr 2020 14:20:47 -0700 Subject: [PATCH 2/2] enh: address review comment by @mgxd --- niworkflows/interfaces/nibabel.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/niworkflows/interfaces/nibabel.py b/niworkflows/interfaces/nibabel.py index 184f888bb70..14fc10af4de 100644 --- a/niworkflows/interfaces/nibabel.py +++ b/niworkflows/interfaces/nibabel.py @@ -1,7 +1,6 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: """Nibabel-based interfaces.""" -from pathlib import Path import numpy as np import nibabel as nb from nipype import logging @@ -124,10 +123,8 @@ def _run_interface(self, runtime): self._results["out_files"] = [] for i, img_3d in enumerate(nb.four_to_three(img)): - out_file = str( - Path(fname_presuffix(in_file, suffix=f"_idx-{i:03}", - newpath=runtime.cwd)).absolute() - ) + out_file = fname_presuffix(in_file, suffix=f"_idx-{i:03}", + newpath=runtime.cwd) img_3d.to_filename(out_file) self._results["out_files"].append(out_file)