Example #1
0
 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')
Example #2
0
    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}', '')
Example #3
0
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')
Example #4
0
 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')
Example #5
0
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', '')
Example #6
0
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)
Example #7
0
 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')
Example #8
0
 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')
Example #9
0
 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()
Example #10
0
 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()
Example #11
0
 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')
Example #12
0
 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')
Example #13
0
 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', '')
Example #14
0
 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', '')
Example #15
0
 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', '')
Example #16
0
 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')
Example #17
0
 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', '')
Example #19
0
 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', '')
Example #20
0
 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', '')
Example #21
0
 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', '')
Example #22
0
 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')
Example #23
0
 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', '')
Example #24
0
 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', '')
Example #25
0
 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')
Example #26
0
 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')
Example #27
0
 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')
Example #28
0
 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', '')
Example #29
0
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)
Example #30
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}',
                      '\%')