Skip to content

Commit 74b880a

Browse files
committed
Fixed bug
When the tpm files came from different folders, but with the same basename, the output was iteratively overwritten, and the output array pointed three times to the same filename, and thus it did not crash. Now, when using automatic name generation for outputs, the index is always added to prevent this undesired situation.
1 parent cd6dc4f commit 74b880a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

nipype/algorithms/misc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,8 @@ def _list_outputs(self):
12521252

12531253

12541254
def normalize_tpms( in_files, in_mask=None, out_files=[] ):
1255-
""" Returns the input tissue probability maps (tpms, aka volume fractions)
1255+
"""
1256+
Returns the input tissue probability maps (tpms, aka volume fractions)
12561257
normalized to sum up 1.0 at each voxel within the mask.
12571258
"""
12581259
import nibabel as nib
@@ -1261,17 +1262,17 @@ def normalize_tpms( in_files, in_mask=None, out_files=[] ):
12611262

12621263
in_files = np.atleast_1d( in_files ).tolist()
12631264

1264-
if len( out_files )!=len(in_files):
1265+
if len(out_files)!=len(in_files):
12651266
for i,finname in enumerate( in_files ):
12661267
fname,fext = op.splitext( op.basename( finname ) )
12671268
if fext == '.gz':
12681269
fname,fext2 = op.splitext( fname )
12691270
fext = fext2 + fext
12701271

1271-
out_file = op.abspath( fname+'_norm'+fext )
1272-
out_files+= [ out_file ]
1272+
out_file = op.abspath(fname+'_norm'+('_%02d' % i)+fext)
1273+
out_files+= [out_file]
12731274

1274-
imgs = [ nib.load(fim) for fim in in_files ]
1275+
imgs = [nib.load(fim) for fim in in_files]
12751276

12761277
if len(in_files)==1:
12771278
img_data = imgs[0].get_data()

0 commit comments

Comments
 (0)