def plotStdSaturationDecayLength(self, **kwargs): decayLength = 1e6 * np.asarray([ pp.stdSaturationDecayLength() for pp in self.post_processor.post_processors ]) self.plot_variable_single_parameter(decayLength, **kwargs) labels.setYLabel(r'L_{RI}', 'um')
def plot_histogram_tissue_radii(self, **kwargs): style_scheme = styles.StyleSchemeCOSH() x_range = (0, 40) bin_width = 2 bar_fraction = 0.7 bar_width = 0.5 * bin_width * bar_fraction bins = np.array( np.linspace(x_range[0], x_range[1], (x_range[1] - x_range[0]) / bin_width + 1)) ax = plt.gca() func_radii = 1e6 * np.array(self.results.functional_tissue_radii()) topol_radii = 1e6 * np.array(self.results.topological_tissue_radii()) functional_count, _ = np.histogram(func_radii, bins=bins) topological_count, _ = np.histogram(topol_radii, bins=bins) x1 = 0.5 * (bins[:-1] + bins[1:]) - 0.5 * bar_width x2 = 0.5 * (bins[:-1] + bins[1:]) + 0.5 * bar_width plt.bar(x1, functional_count, bar_width, edgecolor=style_scheme['int_func_radii_edge_color'], facecolor=style_scheme['int_func_radii_face_color'], linewidth=0.4, label='functional') plt.bar(x2, topological_count, bar_width, edgecolor=style_scheme['int_topol_radii_edge_color'], facecolor=style_scheme['int_topol_radii_face_color'], linewidth=0.4, label='geometric') # plot mean and standard deviation y_max = np.max(np.hstack((functional_count, topological_count))) ax.errorbar(np.mean(func_radii), 1.1 * y_max, xerr=np.std(func_radii), fmt='o', markersize=2, linewidth=1, elinewidth=0.5, capsize=2, capthick=0.5, color=style_scheme['int_func_radii_face_color']) ax.errorbar(np.mean(topol_radii), 1.05 * y_max, xerr=np.std(topol_radii), fmt='o', markersize=2, linewidth=1, elinewidth=0.5, capsize=2, capthick=0.5, color=style_scheme['int_topol_radii_edge_color']) ax.set_xlim(x_range) majorFormatter = FormatStrFormatter('%d') ax.yaxis.set_major_formatter(majorFormatter) styles.create_COSH_legend(ax, bbox_to_anchor=(1, 0.90)) setXLabel('\mathrm{tissue\;radius}\;r_t', 'um') setYLabel('\mathrm{frequency}', '')
def plotPO2YProfile(simParams, x=150e-6, **kwargs): kroghSol = KroghSolution2DCone(simParams) kroghSol.intravascularResistanceLDHalf = kwargs.get( 'K0', kroghSol.intravascularResistanceLDHalf) kroghSol.convO2Transport = kwargs.get('convO2Transport', True) if 'K0' in kwargs: print "plotPO2Profile: Using K0 = %g" % kwargs['K0'] style = kwargs.get('style', {'color': 'k'}) PO2AnalyticalStyle = { 'color': 'k', 'linestyle': '-', 'linewidth': 1, 'dashes': (1.2, 1.5) } # 'dashes': (5,2.5,1,2.5)} nr = 300 rMax = kroghSol.geometry.tissueRadius(x) rAnalytical = np.linspace(0, rMax, nr) rTissue = np.linspace(kroghSol.geometry['radiusWall'], rMax, nr) PO2Analytical = [kroghSol.PO2Analytical(x, r) for r in rAnalytical] PO2Tissue = [kroghSol.PO2Tissue(x, r) for r in rTissue] PO2RBCMean = kroghSol.PO2RBCMeanAtX(x) plt.plot(1e6 * rAnalytical, PO2Analytical, **PO2AnalyticalStyle) plt.plot(1e6 * rTissue, PO2Tissue, linewidth=1, **style) plt.plot(1e6 * kroghSol.Rrbc / 2, PO2RBCMean, '.', color='k', markersize=4) plt.xlim(0, 1e6 * rMax) plt.ylim(rounded_bounds(PO2Analytical, 10)) labels.setXLabel('r', 'um') labels.setYLabel('PO2', 'mmHg')
def plotStdSaturationDecayTime(self, **kwargs): decayTime = 1e3 * np.asarray([ pp.stdSaturationDecayTime() for pp in self.post_processor.post_processors ]) self.plot_variable_single_parameter(decayTime, **kwargs) labels.setYLabel(r'\tau_{RI}', 'ms')
def plot_decay_time(diff_interaction_coeffs, manual_labels=False): """ Plot the decay time for diffusive interaction as a function of linear density and hemoglobin saturation Args: diff_interaction_coeffs (DiffusiveInteractionResistanceAnalytical) """ ld_vals = np.linspace(0.1, 0.9, 81) hb_vals = np.linspace(0.1, 0.9, 81) xx, yy = np.meshgrid(ld_vals, hb_vals) decay_times = diff_interaction_coeffs.decay_time(xx, yy) t_levels = contourLevels(decay_times, 0.03, 0.03) manual_locations = [(0.221, 0.813), (0.370, 0.700), (0.506, 0.601), (0.648, 0.508), (0.796, 0.397)] c_plot = plt.contour(xx, yy, decay_times, t_levels, colors=None, cmap=plt.cm.jet) if manual_labels: plt.clabel(c_plot, inline=True, inline_spacing=40, fontsize=8, fmt='%g', manual=manual_locations) else: plt.clabel(c_plot, inline=1, fontsize=7, fmt='%g') # print [(text._x, text._y) for text in c_plot.cl] # display label positions setXLabel('LD', '') setYLabel('S', '')
def plotPO2ProfileInterstitialSpace(simParams, radius=17.6e-6, **kwargs): kroghSol = KroghSolution2DCone(simParams) kroghSol.intravascularResistanceLDHalf = kwargs.get( 'K0', kroghSol.intravascularResistanceLDHalf) if 'K0' in kwargs: print "plotPO2Profile: Using K0 = %g" % kwargs['K0'] style = kwargs.get('style', {'color': 'k'}) L = simParams['domainLength'] nx = 100 xValues = np.linspace(0, L, nx) PO2 = [kroghSol.PO2Tissue(x, radius) for x in xValues] plt.plot(1e6 * xValues, PO2, linewidth=1, **style) plt.ylim(rounded_bounds(PO2, 10)) interstitialLayerWidth = 0.35e-6 kroghSol.geometry['radiusWall'] += interstitialLayerWidth kroghSol.intravascularResistanceLDHalf *= 1.1 PO2WithInterstitial = [kroghSol.PO2Tissue(x, radius) for x in xValues] plt.plot(1e6 * xValues, PO2WithInterstitial, '--') labels.setXLabel('x', 'um') labels.setYLabel('PO2', 'mmHg') print 'Difference: ', np.array(PO2) - np.array(PO2WithInterstitial)
def plotIntegralOscillationRadius(self): oscillRads = 1e6 * np.asarray([ pp.integralOscillationRadius() for pp in self.post_processor.post_processors ]) self.plot_variable_single_parameter(oscillRads) labels.setYLabel('\mathrm{int.\;oscill.\;radius}', 'um')
def plotIntegralOscillationDistance(self): oscillDistance = 1e6 * np.asarray([ pp.integralOscillationPenetrationDistance() for pp in self.post_processor.post_processors ]) self.plot_variable_single_parameter(oscillDistance) labels.setYLabel('\mathrm{int.\;oscill.\;length}', 'um')
def plotKRI(self): KRI = np.asarray( [pp.KRI for pp in self.post_processor.post_processors]) self.plot_variable_single_parameter(1e-6 * KRI) labels.setYLabel('K_{RI}', 'IVR') self.fig_options.saveFig('plotKRI') plt.clf()
def plotKOS(self): KOS = np.asarray( [pp.KOS for pp in self.post_processor.post_processors]) self.plot_variable_single_parameter(1e-6 * KOS) labels.setYLabel('K_{OS}', 'IVR') self.fig_options.saveFig('plotKOS') plt.clf()
def plot_tissue_radius_difference_vs_hb_mean(self, **kwargs): self.plot(self.results.hb_mean_on_edge, self.results.functional_minus_topological_tissue_radii, y_factor=1e6, **dict(self.volume_type_symbols['difference'], **kwargs)) setXLabel(r'\mathrm{average\;saturation}\;S', '') setYLabel('r_{t,\mathrm{func}} - r_{t,\mathrm{topol}}', 'um')
def plot_functional_vs_topological_tissue_radii(self, **kwargs): self.plot(self.results.topological_tissue_radii, self.results.functional_tissue_radii, x_factor=1e6, y_factor=1e6, **dict(self.volume_type_symbols['difference'], **kwargs)) setXLabel('r_{t,\mathrm{geom}}', 'um') setYLabel('r_{t,\mathrm{func}}', 'um')
def plotSimHbProfile(self, nProfiles, **kwargs): """Plot individual simulated hemoblogin saturation profiles.""" style = kwargs.get('style', style_scheme['individualRBC']) S = self.postprocessor.rbcDataPostProcessor.fieldOnLastPaths( 'Hb_mean', self.postprocessor.sValues(), nProfiles) plt.plot(1e6 * self.xValues, S, **style) labels.setXLabel('x', 'um') labels.setYLabel('S', '')
def plotNoModelStdHbProfile(self, **kwargs): style = kwargs.get('style', style_scheme['stdNoModel']) plt.plot( 1e6 * self.xValues, self.postprocessor.initialStdSaturation() * np.ones(self.xValues.shape), **style) labels.setXLabel('x', 'um') labels.setYLabel('\sigma_S', '')
def plotODEMeanHbProfile(self, **kwargs): """Plot the mean hemoglobin saturation profiles from the ODE model. """ lineStyle = kwargs.get('style', style_scheme['meanRBCInter']) SMean = self.postprocessor.meanSaturationODE() plt.plot(1e6 * self.xValues, SMean, **lineStyle) labels.setXLabel('x', 'um') labels.setYLabel('S', '')
def contour_time_scale(self): levels = np.arange(0, 2, 0.1) vrbc, ld = self.post_processor.param_study.meshGrid() time_scale = self._reshape_to_grid(self.post_processor.call_post_processor_method( 'exponential_fit_decay_time')) c1 = plt.contour(ld, 1e3*vrbc, time_scale, levels, cmap=plt.cm.jet) labels.setXLabel('LD', '-') labels.setYLabel('vrbc', 'mm/s') plt.clabel(c1, inline=1, fontsize=12, fmt='%g')
def plotSimStdHbProfile(self, **kwargs): """Plot the standard deviation of the simulated hemoblogin saturation""" style = kwargs.get('style', style_scheme['stdSim']) SStd = self.postprocessor.rbcDataPostProcessor.fieldStd( 'Hb_mean', self.postprocessor.sValues(), self.postprocessor.nAverage) plt.plot(1e6 * self.xValues, SStd, **style) labels.setXLabel('x', 'um') labels.setYLabel('\sigma_S', '')
def plotExponentialFitToHbDifference(self, **kwargs): """ Plot the exponential fit to the simulated hemoglobin saturation difference. """ style = kwargs.get('style', {'dashes': (1,2), 'color': 'r'}) fittedHbDiff = self.postprocessor.exponentialFitToHbDifference() plt.plot(1e6*self.postprocessor.xValues, fittedHbDiff, **style) labels.setXLabel('x', 'um') labels.setYLabel('\Delta S', '')
def plotODELinearizedStdHbProfile(self, **kwargs): """Plots the standard deviation of the hemoglobin saturation from the linearized ODE. """ style = kwargs.get('style', style_scheme['stdLinear']) SLinStd = self.postprocessor.linearizedStdSaturationODE() plt.plot(1e6 * self.xValues, SLinStd, **style) labels.setXLabel('x', 'um') labels.setYLabel('\sigma_S', '')
def plotODEStdHbProfile(self, **kwargs): """Plots the standard deviation of the hemoglobin saturation from the ODE model. """ style = kwargs.get('style', style_scheme['stdRBCInter']) SStd = self.postprocessor.stdSaturationODE() plt.plot(1e6 * self.xValues, SStd, **style) labels.setXLabel('x', 'um') labels.setYLabel('\sigma_S', '')
def plotExponentialFitStdHb(self, **kwargs): """ Plot the exponential fit to the standard deviation of the simulated hemoglobin saturation. """ style = kwargs.get('style', style_scheme['stdExpFit']) fittedStd = self.postprocessor.exponentialFitToStdHb() plt.plot(1e6 * self.xValues, fittedStd, **style) labels.setXLabel('x', 'um') labels.setYLabel('\sigma_S', '')
def contour_delta_po2(self): levels = np.arange(2, 27, 2) vrbc, ld = self.post_processor.param_study.meshGrid() delta_p_simul = self._reshape_to_grid(self.post_processor.delta_p_tissue_simul()) delta_p_fitted = self._reshape_to_grid(self.post_processor.delta_p_tissue_fitted()) c1 = plt.contour(ld, 1e3*vrbc, delta_p_simul, levels, cmap=plt.cm.jet) c2 = plt.contour(ld, 1e3*vrbc, delta_p_fitted, levels, linestyles='dashed', cmap=plt.cm.jet) labels.setXLabel('LD', '-') labels.setYLabel('vrbc', 'mm/s') plt.clabel(c1, inline=1, fontsize=12, fmt='%g')
def plotNoModelMeanPlusMinusStdHbProfile(self, **kwargs): """Plot the mean +/- std of the hemoglobin saturation with no RBC interaction modeling. """ style = kwargs.get('style', style_scheme['meanPmStdNoModel']) SMean = self.postprocessor.meanSaturationNoModel() SStd = self.postprocessor.stdSaturationNoModel() plt.plot(1e6 * self.xValues, SMean + SStd, **style) plt.plot(1e6 * self.xValues, SMean - SStd, **style) labels.setXLabel('x', 'um') labels.setYLabel('S', '')
def plotODEMeanPlusMinusStdHbProfile(self, **kwargs): """Plot the mean +/- std of the hemoglobin saturation from the ODE model. """ lineStyle = kwargs.get('style', style_scheme['meanPmStdRBCInter']) SMean = self.postprocessor.meanSaturationODE() SStd = self.postprocessor.stdSaturationODE() plt.plot(1e6 * self.xValues, SMean + SStd, **lineStyle) plt.plot(1e6 * self.xValues, SMean - SStd, **lineStyle) labels.setXLabel('x', 'um') labels.setYLabel('S', '')
def plot_tissue_radii_vs_edge_index(self, **kwargs): self.plot(self.results.edge_ids, self.results.topological_tissue_radii, y_factor=1e6, **dict(self.volume_type_symbols['topological'], **kwargs)) self.plot(self.results.edge_ids, self.results.functional_tissue_radii, y_factor=1e6, **dict(self.volume_type_symbols['functional'], **kwargs)) setXLabel('e_i', '') setYLabel('\mathrm{tissue\;radius}\;r_t', 'um')
def plot_tissue_radii_vs_hematocrit(self, **kwargs): self.plot(self.results.hematocrit, self.results.topological_tissue_radii, y_factor=1e6, **dict(self.volume_type_symbols['topological'], **kwargs)) self.plot(self.results.hematocrit, self.results.functional_tissue_radii, y_factor=1e6, **dict(self.volume_type_symbols['functional'], **kwargs)) setXLabel('\mathrm{tube\;hematocrit}\;H_T', '') setYLabel('\mathrm{tissue\;radius}\;r_t', 'um')
def plot_tissue_radii_vs_hb_drop(self, **kwargs): self.plot(self.results.hb_mean_drop, self.results.topological_tissue_radii, y_factor=1e6, **dict(self.volume_type_symbols['topological'], **kwargs)) self.plot(self.results.hb_mean_drop, self.results.functional_tissue_radii, y_factor=1e6, **dict(self.volume_type_symbols['functional'], **kwargs)) setXLabel(r'S_a - S_v', '') setYLabel('\mathrm{tissue\;radius}\;r_t', 'um')
def plotSimMeanHbProfile(self, **kwargs): """Plot the mean simulated hemoblogin saturation""" style = kwargs.get('style', style_scheme['meanSim']) # S = self.rbcDataPostProcessor.fieldAverageAlternating('Hb_mean', # self.sValues(), 2, self.nAverage) SMean = self.postprocessor.rbcDataPostProcessor.fieldAverage( 'Hb_mean', self.postprocessor.sValues(), self.postprocessor.nAverage) plt.plot(1e6 * self.xValues, SMean, **style) labels.setXLabel('x', 'um') labels.setYLabel('S', '')
def plotHillEquation(bloodChem, P, reversed=False): S = bloodChem.hillS(P) if reversed: plt.plot(S, P) labels.setXLabel('S', '-') labels.setYLabel('P', 'mmHg') plt.xlim(xmax=1.0) else: plt.plot(P, S) labels.setXLabel('P', 'mmHg') labels.setYLabel('S', '-') plt.ylim(ymax=1.0)
def plotRelErrorInStdDrop(self): self.plotRelODEModelErrorInStdDrop(style=style_scheme['stdRBCInter']) self.plotRelLinearizedModelErrorInStdDrop( style=style_scheme['stdLinear']) self.plotRelExponentialFitErrorInStdDrop( style=style_scheme['stdExpFit']) ax = plt.gca() ax.yaxis.set_major_locator(MultipleLocator(1)) set_rounded_axis_limits(ax, 1.0, 'y') include_zero_in_axis_range(ax, 'y') labels.setYLabel('\mathrm{error\;in}\;\sigma_{S,a} - \sigma_{S,v}', '\%')