def _load(self, fname, name, is_roi=False): try: extension = "" parts = fname.split(".", 1) if len(parts) > 1: extension = parts[1] self.debug("Loading: %s (%s)", fname, extension) if extension == 'mat': mat, _rows, _cols = load_matrix(fname) extra = MatrixExtra(name, mat) self.ivm.add_extra(name, extra) elif extension == 'csv': df = pd.read_csv(fname) extra = DataFrameExtra(name, df) self.ivm.add_extra(name, extra) elif extension in ('nii', 'nii.gz'): self.debug("Nifti data") qpdata = load(fname) # Remember this is from a temporary file so need to copy the actual data qpdata = NumpyData(qpdata.raw(), grid=qpdata.grid, name=self._output_prefix + name, roi=is_roi) self._output_data_items.append(name) self.ivm.add(qpdata) except: self.warn("Failed to load: %s", fname) traceback.print_exc()
def _load_file(self, filename): fvals, nrows, ncols = load_matrix(filename) if ncols <= 0: raise RuntimeError("No numeric data found in file") elif ncols == 1: self.value = [row[0] for row in fvals] elif nrows == 1: self.value = fvals[0] else: # Choose row or column you want row, col = self._choose_row_col(fvals) if row is not None: self.value = fvals[row] elif col is not None: self.value = [v[col] for v in fvals]
def _load_file(self, filename): fvals, _, ncols = load_matrix(filename) if ncols <= 0: raise RuntimeError("No numeric data found in file") else: self.setMatrix(fvals)