def _run_interface(self, runtime): from niworkflows.viz.plots import fMRIPlot self._results["out_file"] = fname_presuffix( self.inputs.in_func, suffix="_fmriplot.svg", use_ext=False, newpath=runtime.cwd, ) dataframe = pd.read_csv( self.inputs.confounds_file, sep="\t", index_col=None, dtype="float32", na_filter=True, na_values="n/a", ) headers = [] units = {} names = {} for conf_el in self.inputs.confounds_list: if isinstance(conf_el, (list, tuple)): headers.append(conf_el[0]) if conf_el[1] is not None: units[conf_el[0]] = conf_el[1] if len(conf_el) > 2 and conf_el[2] is not None: names[conf_el[0]] = conf_el[2] else: headers.append(conf_el) if not headers: data = None units = None else: data = dataframe[headers] colnames = data.columns.ravel().tolist() for name, newname in list(names.items()): colnames[colnames.index(name)] = newname data.columns = colnames fig = fMRIPlot( self.inputs.in_func, mask_file=self.inputs.in_mask if isdefined(self.inputs.in_mask) else None, seg_file=(self.inputs.in_segm if isdefined(self.inputs.in_segm) else None), tr=self.inputs.tr, data=data, units=units, ).plot() fig.savefig(self._results["out_file"], bbox_inches="tight") return runtime
def _run_interface(self, runtime): self._results['out_file'] = fname_presuffix( self.inputs.in_func, suffix='_fmriplot.svg', use_ext=False, newpath=runtime.cwd) dataframe = pd.read_csv( self.inputs.confounds_file, sep="\t", index_col=None, dtype='float32', na_filter=True, na_values='n/a') headers = [] units = {} names = {} for conf_el in self.inputs.confounds_list: if isinstance(conf_el, (list, tuple)): headers.append(conf_el[0]) if conf_el[1] is not None: units[conf_el[0]] = conf_el[1] if len(conf_el) > 2 and conf_el[2] is not None: names[conf_el[0]] = conf_el[2] else: headers.append(conf_el) if not headers: data = None units = None else: data = dataframe[headers] colnames = data.columns.ravel().tolist() for name, newname in list(names.items()): colnames[colnames.index(name)] = newname data.columns = colnames fig = fMRIPlot( self.inputs.in_func, mask_file=self.inputs.in_mask, seg_file=(self.inputs.in_segm if isdefined(self.inputs.in_segm) else None), tr=self.inputs.tr, data=data, units=units, ).plot() fig.savefig(self._results['out_file'], bbox_inches='tight') return runtime