Skip to content

Commit 9e69da2

Browse files
authored
Merge pull request #503 from nipreps/oesteban-patch-1
FIX: Merge/SplitSeries write to path of input image, instead of cwd
2 parents 17ed748 + af7aa27 commit 9e69da2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

niworkflows/interfaces/nibabel.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
"""Nibabel-based interfaces."""
4-
from pathlib import Path
54
import numpy as np
65
import nibabel as nb
76
from nipype import logging
@@ -124,9 +123,8 @@ def _run_interface(self, runtime):
124123

125124
self._results["out_files"] = []
126125
for i, img_3d in enumerate(nb.four_to_three(img)):
127-
out_file = str(
128-
Path(fname_presuffix(in_file, suffix=f"_idx-{i:03}")).absolute()
129-
)
126+
out_file = fname_presuffix(in_file, suffix=f"_idx-{i:03}",
127+
newpath=runtime.cwd)
130128
img_3d.to_filename(out_file)
131129
self._results["out_files"].append(out_file)
132130

@@ -169,7 +167,8 @@ def _run_interface(self, runtime):
169167
)
170168

171169
img_4d = nb.concat_images(nii_list)
172-
out_file = fname_presuffix(self.inputs.in_files[0], suffix="_merged")
170+
out_file = fname_presuffix(self.inputs.in_files[0], suffix="_merged",
171+
newpath=runtime.cwd)
173172
img_4d.to_filename(out_file)
174173

175174
self._results["out_file"] = out_file

0 commit comments

Comments
 (0)