def _run_interface(self, runtime): self.out_files = [] self.save_subject_list() self.plot_mask() self.plot_full_zstat() self.plot_thresh_zstat() self.reformat_cluster_table() self.peaks = peaks = self._load_peaks() if len(peaks): self.plot_watershed(peaks) self.plot_peaks(peaks) self.plot_boxes(peaks) else: fnames = [ nii_to_png(self.inputs.seg_file), nii_to_png(self.inputs.zstat_thresh_file, "_peaks"), op.realpath("peak_boxplot.png") ] self.out_files.extend(fnames) for name in fnames: with open(name, "wb"): pass return runtime
def _run_interface(self, runtime): self.out_files = [] self.save_subject_list() self.plot_mask() self.plot_full_zstat() self.plot_thresh_zstat() self.reformat_cluster_table() self.peaks = peaks = self._load_peaks() if len(peaks): self.plot_watershed(peaks) self.plot_peaks(peaks) self.plot_boxes(peaks) else: fnames = [nii_to_png(self.inputs.seg_file), nii_to_png(self.inputs.zstat_thresh_file, "_peaks"), op.realpath("peak_boxplot.png")] self.out_files.extend(fnames) for name in fnames: with open(name, "wb"): pass return runtime
def plot_mask(self): """Plot the analysis mask.""" m = Mosaic(stat=self.inputs.mask_file) m.plot_mask() out_fname = nii_to_png(self.inputs.mask_file) self.out_files.append(out_fname) m.savefig(out_fname) m.close()
def plot_full_zstat(self): """Plot the unthresholded zstat.""" m = Mosaic(stat=self.inputs.zstat_file, mask=self.inputs.mask_file) m.plot_overlay(cmap="coolwarm", center=True, alpha=.9) out_fname = nii_to_png(self.inputs.zstat_file) self.out_files.append(out_fname) m.savefig(out_fname) m.close()
def plot_tsnr(self): tsnr = self.inputs.tsnr_file m = Mosaic(self.mean, tsnr, self.mask, step=1) m.plot_overlay("cube:1.9:.5", 0, alpha=1, fmt="%d") png_name = nii_to_png(tsnr) m.savefig(png_name) m.close() self.out_files.append(png_name)
def plot_residuals(self): """Plot the variance of the model residuals across time.""" ss = self.inputs.sigmasquareds_file m = Mosaic(self.mean, ss, self.mask, step=1) m.plot_overlay("cube:.8:.2", 0, alpha=.6, fmt="%d") png_name = nii_to_png(ss) m.savefig(png_name) m.close() self.out_files.append(png_name)
def plot_thresh_zstat(self): """Plot the thresholded zstat.""" m = Mosaic(stat=self.inputs.zstat_thresh_file, mask=self.inputs.mask_file) m.plot_activation(pos_cmap="OrRd_r", vfloor=3.3, alpha=.9) out_fname = nii_to_png(self.inputs.zstat_thresh_file) self.out_files.append(out_fname) m.savefig(out_fname) m.close()
def plot_rsquareds(self): """Plot the full, main, and confound R squared maps.""" cmaps = ["cube:2:0", "cube:2.6:0", "cube:1.5:0"] for r2_file, cmap in zip(self.inputs.r2_files, cmaps): m = Mosaic(self.mean, r2_file, self.mask, step=1) m.plot_overlay(cmap, 0, alpha=.6) png_name = nii_to_png(r2_file) m.savefig(png_name) m.close() self.out_files.append(png_name)
def plot_zstats(self): """Plot the positive and negative z stats with a low threshold.""" for z_file in self.inputs.zstat_files: m = Mosaic(self.mean, z_file, self.mask, step=1) m.plot_activation(pos_cmap="Reds_r", neg_cmap="Blues", thresh=1.7, alpha=.85) png_name = nii_to_png(z_file) m.savefig(png_name) m.close() self.out_files.append(png_name)
def write_r2_images(self): """Show the fixed effects model fit.""" cmaps = ["cube:2:0", "cube:2.6:0"] for fname, cmap in zip(self.inputs.r2_files, cmaps): m = Mosaic(self.inputs.anatomy, fname, self.every_mask, step=self.step) m.plot_overlay(cmap, 0, alpha=.85) out_fname = op.abspath(nii_to_png(fname)) self.summary_files.append(out_fname) m.savefig(out_fname) m.close()
def plot_watershed(self, peaks): """Plot the watershed segmentation.""" palette = sns.husl_palette(len(peaks)) cmap = mpl.colors.ListedColormap(palette) m = Mosaic(stat=self.inputs.seg_file, mask=self.inputs.mask_file) m.plot_overlay(thresh=.5, cmap=cmap, vmin=1, vmax=len(peaks)) out_fname = nii_to_png(self.inputs.seg_file) self.out_files.append(out_fname) m.savefig(out_fname) m.close()
def plot_peaks(self, peaks): """Plot the peaks.""" palette = sns.husl_palette(len(peaks)) cmap = mpl.colors.ListedColormap(palette) disk_img = self._peaks_to_disks(peaks) m = Mosaic(stat=disk_img, mask=self.inputs.mask_file) m.plot_overlay(thresh=.5, cmap=cmap, vmin=1, vmax=len(peaks)) out_fname = nii_to_png(self.inputs.zstat_thresh_file, "_peaks") self.out_files.append(out_fname) m.savefig(out_fname) m.close()