Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, fields=None):
super(MergeAll, self).__init__()
if not fields:
raise ValueError("Fields must be a non-empty list")
self._fields = fields
add_traits(self.inputs, fields)
self._results["effect_maps"] = effect_maps
self._results["variance_maps"] = variance_maps
self._results["stat_maps"] = stat_maps
self._results["zscore_maps"] = zscore_maps
self._results["pvalue_maps"] = pvalue_maps
self._results["contrast_metadata"] = contrast_metadata
def get_stim_labels(self):
# Iterate through all weight specifications to get a list of stimulus
# column labels.
weights = _flatten([x["weights"] for x in self.inputs.contrast_info])
return list(set(_flatten([x.keys() for x in weights])))
class AFNIMergeAll(MergeAll):
def _list_outputs(self):
outputs = self._outputs().get()
for key in self._fields:
val = getattr(self.inputs, key)
outputs[key] = [elem for sublist in val for elem in sublist]
return outputs
def get_afni_design_matrix(design, contrasts, stim_labels, t_r):
"""Add appropriate metadata to the design matrix and write to file for
calling 3dREMLfit. For a description of the target format see
https://docs.google.com/document/d/1zpujpZYuleB7HuIFjb2vC4sYXG5M97hJ655ceAj4vE0/edit
Parameters
----------
niu.Select(index=ix),
name='select_{}_contrasts'.format(level),
run_without_submitting=True)
# Squash the results of MapNodes that may have generated multiple maps
# into single lists.
# Do the same with corresponding metadata - interface will complain if shapes mismatch
if estimator == "afni":
collate = pe.Node(
AFNIMergeAll(['effect_maps', 'variance_maps', 'stat_maps', 'zscore_maps',
'pvalue_maps', 'contrast_metadata']),
name='collate_{}'.format(level),
run_without_submitting=True)
else:
collate = pe.Node(
MergeAll(['effect_maps', 'variance_maps', 'stat_maps', 'zscore_maps',
'pvalue_maps', 'contrast_metadata']),
name='collate_{}'.format(level),
run_without_submitting=True)
#
# Plotting
#
plot_contrasts = pe.MapNode(
GlassBrainPlot(image_type='png'),
iterfield='data',
name='plot_{}_contrasts'.format(level))
#
# Derivatives
#