Skip to content

Commit a204ce0

Browse files
committed
fix(interfaces): update 3dMEMA's sets input
1 parent 0ed0331 commit a204ce0

File tree

1 file changed

+38
-11
lines changed

1 file changed

+38
-11
lines changed

nipype/interfaces/afni/model.py

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -668,12 +668,17 @@ def _list_outputs(self):
668668

669669
class MemaInputSpec(AFNICommandInputSpec):
670670
# mandatory inputs
671-
subject_trait = traits.Tuple(
672-
Str, File(exists=True), File(exists=True), Str(''), Str('')
671+
_subject_trait = traits.Either(
672+
traits.Tuple(
673+
Str(minlen=1), File(exists=True), File(exists=True)
674+
),
675+
traits.Tuple(
676+
Str(minlen=1), File(exists=True), File(exists=True), Str(''), Str('')
677+
)
673678
)
674679

675680
sets = traits.List(
676-
traits.Tuple(Str(minlen=1), traits.List(subject_trait, minlen=2)),
681+
traits.Tuple(Str(minlen=1), traits.List(_subject_trait, minlen=2)),
677682
desc="""\
678683
Specify the data for one of two test variables (either group, contrast/GLTs) A & B.
679684
@@ -695,7 +700,7 @@ class MemaInputSpec(AFNICommandInputSpec):
695700
e.g: -set Placebo Jane pb05.Jane.Regression+tlrc'[face#0_Beta]'
696701
pb05.Jane.Regression+tlrc'[face#0_Tstat]'
697702
""",
698-
argstr='-set %s ...',
703+
argstr='-set %s...',
699704
mandatory=True,
700705
minlen=1,
701706
maxlen=2,
@@ -814,7 +819,7 @@ class MemaInputSpec(AFNICommandInputSpec):
814819
argstr='-mask %s'
815820
)
816821

817-
max_zeros = traits.Range( # Please revise all the other possible settings
822+
max_zeros = traits.Range( # Please revise all the other possible settings\
818823
desc="""\
819824
Do not compute statistics at any voxel that has \
820825
more than MM zero beta coefficients or GLTs. Voxels around \
@@ -829,8 +834,7 @@ class MemaInputSpec(AFNICommandInputSpec):
829834
less than the number of subjects, or a fraction \
830835
between 0 and 1. Alternatively option -missing_data \
831836
can be used to handle missing data.""",
832-
833-
min=0.0, max=1.0,
837+
low=0.0, high=1.0,
834838
argstr='-max_zeros %f',
835839
xor=['missing_data'],
836840
)
@@ -899,11 +903,12 @@ class MemaInputSpec(AFNICommandInputSpec):
899903
argstr='-rio')
900904

901905
verbosity = traits.Range(
902-
1,
906+
value=1,
903907
usedefault=True,
904-
min=0,
908+
low=0,
905909
desc='An integer specifying verbosity level. 0 is quiet, 1+ is talkative.',
906-
argstr='-verb %d')
910+
argstr='-verb %d'
911+
)
907912

908913

909914
class MemaOutputSpec(AFNICommandOutputSpec):
@@ -919,7 +924,7 @@ class Mema(AFNICommand):
919924
"""Description of 3dMEMA
920925
921926
For complete details, see the `3dMEMA Documentation.
922-
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dMEMA.html>
927+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dMEMA.html>`__
923928
924929
Examples
925930
========
@@ -935,6 +940,28 @@ class Mema(AFNICommand):
935940
input_spec = MemaInputSpec
936941
output_spec = MemaOutputSpec
937942

943+
def _format_arg(self, name, trait_spec, value):
944+
if name == "sets":
945+
self._n_sets = len(value)
946+
formatted_values = []
947+
for setname, setopts in value:
948+
formatted_subject = []
949+
for this_set in setopts:
950+
if len(this_set) == 4:
951+
subid, beta_file, ttst_file, beta_opts, ttst_opts = this_set
952+
if beta_opts:
953+
beta_file = "%s'%s'" % (beta_file, beta_opts)
954+
if ttst_opts:
955+
ttst_file = "%s'%s'" % (ttst_file, ttst_opts)
956+
else:
957+
subid, beta_file, ttst_file = this_set
958+
formatted_subject.append(' '.join((subid, beta_file, ttst_file)))
959+
formatted_values.append(' '.join([setname] + formatted_subject))
960+
value = formatted_values
961+
962+
return super(Mema, self)._format_arg(name, trait_spec, value)
963+
964+
938965
def _parse_inputs(self, skip=None):
939966
if skip is None:
940967
skip = []

0 commit comments

Comments
 (0)