Skip to content

Commit 77b1cb9

Browse files
committed
Merge pull request #1424 from akeshavan/dcm2nii
Dcm2nii
2 parents f6ae4e4 + 9f2e498 commit 77b1cb9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

nipype/interfaces/dcm2nii.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ def _parse_stdout(self, stdout):
139139
else:
140140
output_dir = self._gen_filename('output_dir')
141141
val = os.path.join(output_dir, val)
142-
out_file = val
142+
if os.path.exists(val):
143+
out_file = val
143144

144145
if out_file:
145-
files.append(out_file)
146-
last_added_file = out_file
146+
if not out_file in files:
147+
files.append(out_file)
148+
last_added_file = out_file
147149
continue
148150

149151
if line.startswith("Reorienting as "):
@@ -153,9 +155,12 @@ def _parse_stdout(self, stdout):
153155
elif line.startswith("Cropping NIfTI/Analyze image "):
154156
base, filename = os.path.split(line[len("Cropping NIfTI/Analyze image "):])
155157
filename = "c" + filename
156-
reoriented_and_cropped_files.append(os.path.join(base, filename))
157-
skip = True
158-
continue
158+
if os.path.exists(os.path.join(base, filename)) or self.inputs.reorient_and_crop:
159+
# if reorient&crop is true but the file doesn't exist, this errors when setting outputs
160+
reoriented_and_cropped_files.append(os.path.join(base, filename))
161+
skip = True
162+
continue
163+
159164
skip = False
160165
return files, reoriented_files, reoriented_and_cropped_files, bvecs, bvals
161166

0 commit comments

Comments
 (0)