def plot_oxy(ax): ax.set(title='$O_2$') imshow_cb(ax, oxy, ld, matplotlib.cm.Reds, (0., oxy.max()), 1.) contour(ax, oxy, ld, levels=[param_oxy_death, param_oxy_prol], colors=('r', 'b'), worldscaling=1.e-3)
def plot_vesselvolume(ax): data = resultfile.obtain_data('fieldvariable', 'phi_vessels', groupname, 'imslice') ax.set(title=ur'$\phi_v$') imshow_cb(ax, data, ld, matplotlib.cm.coolwarm, (0., 1.), 1.) contour(ax, oxy, ld, levels=[param_oxy_death], colors='r', worldscaling=1.e-3)
def plot_phi_cells(ax): data = resultfile.obtain_data('fieldvariable', 'phi_viabletumor', groupname, 'imslice') ax.set(title=ur'$\phi$') imshow_cb(ax, data, ld, matplotlib.cm.coolwarm, (0.4, 0.5), 1.) contour(ax, oxy, ld, levels=[param_oxy_death, param_oxy_prol], colors=('r', 'b'), worldscaling=1.e-3)
def plot_sources(ax): data = resultfile.obtain_data('fieldvariable', 'sources', groupname, 'imslice') ax.set(title=ur'$\Gamma_\phi$') imshow_cb(ax, data, ld, matplotlib.cm.coolwarm, 'zero-centered', 1.e3) contour(ax, oxy, ld, levels=[param_oxy_death, param_oxy_prol], colors=('r', 'b'), worldscaling=1.e-3)
def plotSnapshotMatrix(resultfile_matrix, pdfpages, xlabels=[], ylabels=[]): nrows, ncols = resultfile_matrix.shape fig, axes = pyplot.subplots(nrows, ncols, sharex=True, sharey=True, figsize=(ncols * 3. + 2., nrows * 3 + 2.)) for ax, resultfile in zip(axes.ravel(), resultfile_matrix.ravel()): ld = resultfile.obtain_data('ld') data = resultfile.obtain_data('fieldvariable', 'dist_tumor', resultfile.groupnames[-1], 'imslice') #imshow_(ax, data, ld, matplotlib.cm.coolwarm, None, 1.) contour(ax, data, ld, levels=[0.], colors='k') ax.set(xticklabels=[], yticklabels=[]) for xlabel, ax in zip(xlabels, axes[-1, :]): ax.set(xlabel=xlabel) for ylabel, ax in zip(ylabels, axes[:, 0]): ax.set(ylabel=ylabel) pdfpages.savefig(fig)
def analyzeO2_with_tumor(f): dataman = myutils.DataManager(100, [plotBulkTissue2d.DataTumorTissueSingle()]) resultfile = plotBulkTissue2d.ResultFile(f, dataman) group = resultfile.groupnames[-1] ld = resultfile.obtain_data('ld') print group arterial_reference = 12. theta_tumor = resultfile.obtain_data('fieldvariable', 'theta_tumor', group) o2 = arterial_reference * resultfile.obtain_data('fieldvariable', 'oxy', group) dist_tumor = resultfile.obtain_data('fieldvariable', 'dist_tumor', group) def tumorAndTissueAverages(field): tumor = field[theta_tumor > 0.5] normal = field[theta_tumor < 0.5] tissueavg = (np.average(normal), np.std(normal)) tumoravg = (np.average(tumor), np.std(tumor)) return tissueavg, tumoravg cons_rate_normal = float(f['parameters'].attrs['o2_cons_coeff_normal']) cons_rate_tumor = float(f['parameters'].attrs['o2_cons_coeff_tumor']) consumption = (theta_tumor * cons_rate_tumor + (1. - theta_tumor) * cons_rate_normal) * o2 solubility = 0.00021 # ml O2 / ml Tissue / kPa consfactors = 2000. * 60 * solubility * 1.e2 # 2000. from diff koff, 60 from s to min conversion. consumption *= consfactors avgStr = lambda t: r'$%s \pm %s$' % tuple(f2l(q) for q in t) outfn = 'oxycheck-' + splitext(basename(str(f.filename)))[0] + '.pdf' with mpl_utils.PdfWriter(outfn) as pdfwriter: fig = pyplot.figure(figsize=(5, 5)) ax = fig.add_axes([0.05, 0.05, 4.2 / 5, 4.2 / 5]) img = plotBulkTissue.imshow(ax, plotBulkTissue.imslice(o2), ld, vmin=0., vmax=9., cmap=matplotlib.cm.Reds, worldscaling=1.e-3) plotBulkTissue.colorbar(ax.get_figure(), ax, img) plotBulkTissue.contour(ax, plotBulkTissue.imslice(dist_tumor), ld, levels=[0.], colors=['k'], worldscaling=1.e-3) tissueavg, tumoravg = tumorAndTissueAverages(o2) print 'normal po2: %f +/- %f' % tissueavg print 'tumor po2: %f +/- %f' % tumoravg fig.suptitle(r'O2 [kPa] (arterial $P_{O_2} = 12 kPa$)') fig.text( 0.1, 0.90, '<tissue> ' + avgStr(tissueavg) + '\n' + '<tumor> ' + avgStr(tumoravg)) pdfwriter.savefig(fig) fig = pyplot.figure(figsize=(5, 5)) ax = fig.add_axes([0.05, 0.05, 4.2 / 5, 4.2 / 5]) img = plotBulkTissue.imshow(ax, plotBulkTissue.imslice(consumption), ld, vmin=consumption.min(), vmax=consumption.max(), cmap=matplotlib.cm.Reds, worldscaling=1.e-3) plotBulkTissue.colorbar(ax.get_figure(), ax, img) plotBulkTissue.contour(ax, plotBulkTissue.imslice(dist_tumor), ld, levels=[0.], colors=['k'], worldscaling=1.e-3) tissueavg, tumoravg = tumorAndTissueAverages(consumption) print 'mro2 normal o2: %f +/- %f' % tissueavg print 'mro2 tumor o2: %f +/- %f' % tumoravg fig.suptitle(r'$MRO_2$ [ml $O_2$ / 100 ml Tissue min]') fig.text( 0.1, 0.90, '<tissue> ' + avgStr(tissueavg) + '\n' + '<tumor> ' + avgStr(tumoravg)) pdfwriter.savefig(fig)