Skip to content

Commit d6bcef9

Browse files
committed
FIX: AntsJointFusion unicode command line formatting
When strings are formatted in unicode, then the format of the AntsJointFusion -g, -t flags is not the same as the python string representations of lists. These flags need to be unpacked one-by-one and a new string representation needs to be provided on the command line.
1 parent 10b9675 commit d6bcef9

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

nipype/interfaces/ants/segmentation.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,11 +1129,28 @@ def _format_arg(self, opt, spec, val):
11291129
retval = ''
11301130
if not isdefined(self.inputs.out_label_fusion):
11311131
retval = '-o {0}'.format(self.inputs.out_intensity_fusion_name_format)
1132+
elif opt == 'atlas_image':
1133+
atlas_image_cmd=" ".join(
1134+
[ '-g [{0}]'.format(",".join(
1135+
fn for fn in ai) ) for ai in self.inputs.atlas_image]
1136+
)
1137+
retval = atlas_image_cmd
1138+
elif opt == 'target_image':
1139+
target_image_cmd=" ".join(
1140+
[ '-t [{0}]'.format(",".join(
1141+
fn for fn in ai) ) for ai in self.inputs.target_image]
1142+
)
1143+
retval = target_image_cmd
1144+
elif opt == 'atlas_segmentation_image':
1145+
assert len(val) == len(self.inputs.atlas_image), "Number of specified " \
1146+
"segmentations should be identical to the number of atlas image " \
1147+
"sets {0}!={1}".format(len(val), len(self.inputs.atlas_image))
1148+
atlas_segmentation_image_cmd=" ".join(
1149+
[ '-t [{0}]'.format( fn ) for fn in self.inputs.atlas_segmentation_image ]
1150+
)
1151+
retval = atlas_segmentation_image_cmd
11321152
else:
1133-
if opt == 'atlas_segmentation_image':
1134-
assert len(val) == len(self.inputs.atlas_image), "Number of specified " \
1135-
"segmentations should be identical to the number of atlas image " \
1136-
"sets {0}!={1}".format(len(val), len(self.inputs.atlas_image))
1153+
11371154
return super(ANTSCommand, self)._format_arg(opt, spec, val)
11381155
return retval
11391156

0 commit comments

Comments
 (0)