Beispiel #1
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')
Beispiel #2
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)
Beispiel #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')
Beispiel #4
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', '')
Beispiel #5
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}', '')
Beispiel #6
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', '')
Beispiel #7
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', '')
Beispiel #8
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')
Beispiel #9
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', '')
Beispiel #10
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', '')
Beispiel #12
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')
Beispiel #13
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', '')
Beispiel #14
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', '')
Beispiel #15
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')
Beispiel #16
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', '')
Beispiel #17
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', '')
Beispiel #18
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', '')
Beispiel #19
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', '')
Beispiel #20
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')
Beispiel #21
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')
Beispiel #22
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')
Beispiel #23
0
def plotAveragedProbes(EAT_dicts, probes, from_time, **kwargs):

    nProbes = len(probes)

    # extract probe positions (scaled to mum)
    xProbes = [1e6 * probe['positions'][0][0] for probe in probes]

    # extract PO2 max, min and mean
    from_idx = np.searchsorted(EAT_dicts[0]['t_front'], from_time)

    PO2_max = [EAT_dict['PO2_max'][from_idx:] for EAT_dict in EAT_dicts]
    PO2_min = [EAT_dict['PO2_min'][from_idx:] for EAT_dict in EAT_dicts]
    PO2_mean = [EAT_dict['PO2_mean'][from_idx:] for EAT_dict in EAT_dicts]

    mean_PO2_max = np.asarray([np.mean(P) for P in PO2_max])
    mean_PO2_min = np.asarray([np.mean(P) for P in PO2_min])
    mean_PO2_mean = np.asarray([np.mean(P) for P in PO2_mean])

    mean_EAT = mean_PO2_max - mean_PO2_min

    style = kwargs.get('linestyle', {
        'markerfacecolor': 'None',
        'markersize': 5,
        'linewidth': 0.4
    })
    plt.plot(xProbes, mean_PO2_max, 'ro-', label=r'RBC', **style)
    # plt.plot(xProbes, mean_PO2_max, 'r-', label=r'RBC', **style)
    plt.plot(xProbes, mean_PO2_mean, 'ks-', label=r'mean', **style)
    plt.plot(xProbes, mean_PO2_min, 'b^-', label=r'inter-RBC', **style)
    # plt.plot(xProbes, mean_PO2_min, 'b-', label=r'inter-RBC', **style)
    plt.plot(xProbes, mean_EAT, 'k--', dashes=(5, 3), label='EAT', **style)

    labels.setXLabel('x', 'um')
    labels.setYLabel('PO2', 'mmHg')

    # plt.legend()
    plt.ylim([0, 80])
    # plt.xlim([8.6, 91.4])
    # plt.xlim([10, 90])

    print 'Mean PO2 max = ', mean_PO2_max
    print 'Mean PO2 min = ', mean_PO2_min
    print 'Mean PO2 mean = ', mean_PO2_mean
    print 'Mean EAT      = ', mean_EAT
    print 'Average mean PO2 max = ', np.mean(mean_PO2_max)
    print 'Average mean PO2 min = ', np.mean(mean_PO2_min)
    print 'Average mean PO2 mean = ', np.mean(mean_PO2_mean)
    print 'Average mean EAT = ', np.mean(mean_EAT)

    print 'Differences over 50 mum:'
    print 'Delta PO2 max = ', mean_PO2_max[:-5] - mean_PO2_max[-4:]
    print 'Delta PO2 min = ', mean_PO2_min[:-5] - mean_PO2_min[-4:]
    print 'Delta PO2 mean = ', mean_PO2_mean[:-5] - mean_PO2_mean[-4:]
Beispiel #24
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)
Beispiel #25
0
 def plot_tissue_radii_vs_arrival_path_length(self, **kwargs):
     self.plot(self.results.mean_arrival_path_length,
               self.results.topological_tissue_radii,
               x_factor=1e6,
               y_factor=1e6,
               **dict(self.volume_type_symbols['topological'], **kwargs))
     self.plot(self.results.mean_arrival_path_length,
               self.results.functional_tissue_radii,
               x_factor=1e6,
               y_factor=1e6,
               **dict(self.volume_type_symbols['functional'], **kwargs))
     setXLabel('\mathrm{arrival\;path\;length}\;ts', 'um')
     setYLabel('\mathrm{tissue\;radius}\;r_t', 'um')
Beispiel #26
0
 def plot_tissue_radii_vs_arrival_transit_time(self, **kwargs):
     self.plot(self.results.mean_arrival_transit_time,
               self.results.topological_tissue_radii,
               x_factor=1e3,
               y_factor=1e6,
               **dict(self.volume_type_symbols['topological'], **kwargs))
     self.plot(self.results.mean_arrival_transit_time,
               self.results.functional_tissue_radii,
               x_factor=1e3,
               y_factor=1e6,
               **dict(self.volume_type_symbols['functional'], **kwargs))
     setXLabel('\mathrm{arrival\;transit\;time}\;tt', 'ms')
     setYLabel('\mathrm{tissue\;radius}\;r_t', 'um')
Beispiel #27
0
 def plot_tissue_radii_vs_rbc_velocity(self, **kwargs):
     self.plot(self.results.rbc_velocity,
               self.results.topological_tissue_radii,
               x_factor=1e3,
               y_factor=1e6,
               **dict(self.volume_type_symbols['topological'], **kwargs))
     self.plot(self.results.rbc_velocity,
               self.results.functional_tissue_radii,
               x_factor=1e3,
               y_factor=1e6,
               **dict(self.volume_type_symbols['functional'], **kwargs))
     setXLabel('\mathrm{RBC\;velocity}\;v_{\mathrm{rbc}}', '\mathrm{mm/s}')
     setYLabel('\mathrm{tissue\;radius}\;r_t', 'um')
Beispiel #28
0
def plot_probe(probe, probe_idx, min_time, max_time, **kwargs):
    linestyle = kwargs.get('linestyle', {'linestyle': '-'})
    times = probe.times(min_time=min_time, max_time=max_time)
    ymax = 0
    if probe_idx is None:
        probe_idx = probe.position_indices()
    for i in probe_idx:
        values = probe.values(position=i, min_time=min_time, max_time=max_time)
        plt.plot(times, values, **linestyle)
        setXLabel('t', 's')
        setYLabel('PO2', 'mmHg')
        ymax = np.max([ymax, np.max(values)])
    plt.xlim([min(times) - 1e-6, max(times) + 1e-6])
Beispiel #29
0
 def plotSimMeanPlusMinusHbProfile(self, **kwargs):
     """Plot the mean simulated hemoblogin saturation"""
     style = kwargs.get('style', style_scheme['meanPmStdSim'])
     SMean = self.postprocessor.rbcDataPostProcessor.fieldAverage(
         'Hb_mean', self.postprocessor.sValues(),
         self.postprocessor.nAverage)
     SStd = self.postprocessor.rbcDataPostProcessor.fieldStd(
         'Hb_mean', self.postprocessor.sValues(),
         self.postprocessor.nAverage)
     plt.plot(1e6 * self.xValues, SMean + SStd, **style)
     plt.plot(1e6 * self.xValues, SMean - SStd, **style)
     labels.setXLabel('x', 'um')
     labels.setYLabel('S', '')
Beispiel #30
0
 def plot_tissue_radii_vs_rbc_flow(self, **kwargs):
     kwargs_topol, kwargs_func = self.append_label_with_geom_and_func(
         **kwargs)
     self.plot(self.results.rbc_flow,
               self.results.topological_tissue_radii,
               y_factor=1e6,
               **dict(self.volume_type_symbols['topological'],
                      **kwargs_topol))
     self.plot(self.results.rbc_flow,
               self.results.functional_tissue_radii,
               y_factor=1e6,
               **dict(self.volume_type_symbols['functional'],
                      **kwargs_func))
     setXLabel('\mathrm{RBC\;flow}', '\mathrm{s}^{-1}')
     setYLabel('\mathrm{tissue\;radius}\;r_t', 'um')