def _format_labels(row): """format participant labels""" crow = [] for col_id, prefix in list(BIDS_COMP.items()): if pd.notnull(row[[col_id]])[0]: crow.append('%s-%s' % (prefix, row[[col_id]].values[0])) return '_'.join(crow)
def _gen_outfile(self): out_dir = getcwd() if isdefined(self.inputs.out_dir): out_dir = self.inputs.out_dir fname_comps = [] for comp, cpre in list(BIDS_COMP.items()): comp_val = None if isdefined(getattr(self.inputs, comp)): comp_val = getattr(self.inputs, comp) if comp_val == "None": comp_val = None comp_fmt = '{}-{}'.format if comp_val is not None: if isinstance( comp_val, (bytes, str)) and comp_val.startswith(cpre + '-'): comp_val = comp_val.split('-', 1)[-1] fname_comps.append(comp_fmt(cpre, comp_val)) fname_comps.append('%s.json' % self.inputs.modality) self._results['out_file'] = op.join(out_dir, '_'.join(fname_comps)) return self._results['out_file']