def draw_infection_curves_and_histograms(simOutputs_ANNUAL, simOutputs_SEMI):
    """ draws the infection curves and the histograms of time until HIV deaths
    :param simOutputs_mono: output of a cohort simulated under mono therapy
    :param simOutputs_combo: output of a cohort simulated under combination therapy
    """

    # histograms of infection times
    set_of_infection_times = [
        simOutputs_ANNUAL.get_infection_durations(),
        simOutputs_SEMI.get_infection_durations()
    ]

    # graph histograms
    Figs.graph_histograms(data_sets=set_of_infection_times,
                          title='Histogram of Infection Duration',
                          x_label='Infection Duration (Year)',
                          y_label='Counts',
                          bin_width=1,
                          legend=['Annual Treatment', 'Semi-Annual Treatment'],
                          transparency=0.6)

    #get infection curves of both treatments
    infection_curves = [
        simOutputs_ANNUAL.get_infection_curve(),
        simOutputs_SEMI.get_infection_curve()
    ]

    # graph infection curve
    PathCls.graph_sample_paths(sample_paths=infection_curves,
                               title='infection curve',
                               x_label='Simulation time step (year)',
                               y_label='Number of infected patients',
                               legends=['ANNUAL', '6-month'])
def draw_survival_curves_and_histograms(simOutputs_warfarin,
                                        simOutputs_Dabigitran150):
    """ draws the survival curves and the histograms of time until stoke deaths
    :param simOutputs_warfarin: output of a cohort simulated under warfarin therapy
    :param simOutputs_Dabigitran150: output of a cohort simulated under dab150 therapy
    """

    # get survival curves of both treatments
    survival_curves = [
        simOutputs_warfarin.get_survival_curve(),
        simOutputs_Dabigitran150.get_survival_curve()
    ]

    # graph survival curve
    PathCls.graph_sample_paths(sample_paths=survival_curves,
                               title='Survival curve',
                               x_label='Simulation time step (year)',
                               y_label='Number of alive patients',
                               legends=['Warfarin', 'Dabigitran150 Therapy'])

    # histograms of survival times
    set_of_survival_times = [
        simOutputs_warfarin.get_survival_times(),
        simOutputs_Dabigitran150.get_survival_times()
    ]

    # graph histograms
    Figs.graph_histograms(data_sets=set_of_survival_times,
                          title='Histogram of patient survival time',
                          x_label='Survival time (year)',
                          y_label='Counts',
                          bin_width=1,
                          legend=['Warfarin Therapy', 'Dabigitran150 Therapy'],
                          transparency=0.6)
def draw_survival_curves_and_histograms(simOutputs_mono, simOutputs_combo):
    """ draws the survival curves and the histograms of time until HIV deaths
    :param simOutputs_mono: output of a cohort simulated under mono therapy
    :param simOutputs_combo: output of a cohort simulated under combination therapy
    """

    # get survival curves of both treatments
    survival_curves = [
        simOutputs_mono.get_survival_curve(),
        simOutputs_combo.get_survival_curve()
    ]

    # graph survival curve
    PathCls.graph_sample_paths(sample_paths=survival_curves,
                               title='Exposure of antibiotics',
                               x_label='Simulation time step (day)',
                               y_label='Number of patients using antibiotics',
                               legends=['Standard treatment', 'PCT-guided'])

    # histograms of survival times
    set_of_survival_times = [
        simOutputs_mono.get_survival_times(),
        simOutputs_combo.get_survival_times()
    ]

    # graph histograms
    Figs.graph_histograms(data_sets=set_of_survival_times,
                          title='Histogram of exposure time to antibiotics',
                          x_label='Exposure time to antibiotics (day)',
                          y_label='Counts',
                          bin_width=1,
                          legend=['Standard care', 'PCT-guided'],
                          transparency=0.5)
def draw_survival_curves_and_histograms(simOutputs_mono, simOutputs_combo):
    """ draws the survival curves and the histograms of time until HIV deaths
    :param simOutputs_mono: output of a cohort simulated under mono therapy
    :param simOutputs_combo: output of a cohort simulated under combination therapy
    """

    # get survival curves of both treatments
    survival_curves = [
        simOutputs_mono.get_survival_curve(),
        simOutputs_combo.get_survival_curve()
    ]

    # graph survival curve
    PathCls.graph_sample_paths(sample_paths=survival_curves,
                               title='Survival curve',
                               x_label='Simulation time step (year)',
                               y_label='Number of alive patients',
                               legends=['Mono Therapy', 'Combination Therapy'])

    # histograms of survival times
    set_of_survival_times = [
        simOutputs_mono.get_survival_times(),
        simOutputs_combo.get_survival_times()
    ]

    # graph histograms
    Figs.graph_histograms(data_sets=set_of_survival_times,
                          title='Histogram of patient survival time',
                          x_label='Survival time (year)',
                          y_label='Counts',
                          bin_width=1,
                          legend=['Mono Therapy', 'Combination Therapy'],
                          transparency=0.6)
def draw_survival_curves_and_histograms(simOutputs_standard,
                                        simOutputs_population):
    """ draws the survival curves and the histograms of time until cancer
    :param simOutputs_standard: output of a cohort simulated under standard testing
    :param simOutputs_population: output of a cohort simulated under population testing
    """
    # get survival curves of both treatments
    survival_curves = [
        simOutputs_standard.get_survival_curve(),
        simOutputs_population.get_survival_curve()
    ]

    # graph survival curve
    PathCls.graph_sample_paths(
        sample_paths=survival_curves,
        title='Survival curve',
        x_label='Simulation time step (year)',
        y_label='Number of alive patients',
        legends=['Standard Testing', 'Population Testing'])

    # histograms of survival times
    set_of_survival_times = [
        simOutputs_standard.get_survival_times(),
        simOutputs_population.get_survival_times()
    ]

    # graph histograms
    Figs.graph_histograms(data_sets=set_of_survival_times,
                          title='Histogram of patient survival time',
                          x_label='Survival time (year)',
                          y_label='Counts',
                          bin_width=1,
                          legend=['Mono Therapy', 'Combination Therapy'],
                          transparency=0.6)
Exemple #6
0
def draw_survival_curves_and_histograms(sim_output_no_drug,
                                        sim_output_with_drug):
    """ draws the survival curves and the histograms of survival time
    :param sim_output_no_drug: output of a cohort simulated when drug is not available
    :param sim_output_with_drug: output of a cohort simulated when drug is available
    """

    # get survival curves of both treatments
    survival_curves = [
        sim_output_no_drug.get_survival_curve(),
        sim_output_with_drug.get_survival_curve()
    ]

    # graph survival curve
    PathCls.graph_sample_paths(sample_paths=survival_curves,
                               title='Survival curve',
                               x_label='Simulation time step',
                               y_label='Number of alive patients',
                               legends=['No Drug', 'With Drug'])

    # histograms of survival times
    set_of_survival_times = [
        sim_output_no_drug.get_survival_times(),
        sim_output_with_drug.get_survival_times()
    ]

    # graph histograms
    Figs.graph_histograms(data_sets=set_of_survival_times,
                          title='Histogram of patient survival time',
                          x_label='Survival time',
                          y_label='Counts',
                          bin_width=1,
                          legend=['No Drug', 'With Drug'],
                          transparency=0.6)
Exemple #7
0
def draw_survival_curves_and_histograms(simOutputs_none, simOutputs_anticoag):
    """ draws the survival curves and the histograms of time until HIV deaths
    :param simOutputs_none: output of a cohort simulated under the natural history of disease
    :param simOutputs_anticoag: output of a cohort simulated under angicoagulation therapy recepit
    """

    # get survival curves of both treatments
    survival_curves = [
        simOutputs_none.get_survival_curve(),
        simOutputs_anticoag.get_survival_curve()
    ]

    # graph survival curve
    PathCls.graph_sample_paths(
        sample_paths=survival_curves,
        title='Survival curve',
        x_label='Simulation time step (year)',
        y_label='Number of alive patients',
        legends=['No Therapy', 'Anticoagulation Therapy'])

    # histograms of survival times
    set_of_survival_times = [
        simOutputs_none.get_survival_times(),
        simOutputs_anticoag.get_survival_times()
    ]

    # graph histograms
    Figs.graph_histograms(data_sets=set_of_survival_times,
                          title='Histogram of patient survival time',
                          x_label='Survival time (year)',
                          y_label='Counts',
                          bin_width=1,
                          legend=['No Therapy', 'Anticoagulation Therapy'],
                          transparency=0.6)

    # histograms of the number of strokes
    set_of_stroke_counts = [
        simOutputs_none.get_if_developed_stroke(),
        simOutputs_anticoag.get_if_developed_stroke()
    ]

    # graph histograms
    Figs.graph_histograms(data_sets=set_of_stroke_counts,
                          title='Histogram of patient stroke counts',
                          x_label='Number of strokes',
                          y_label='Counts',
                          bin_width=1,
                          legend=['No Therapy', 'Anticoagulation Therapy'],
                          transparency=0.6)
    def __init__(self, simulated_cohort):

        self._survivalTimes = []
        self._numberStrokes_cohort = []

        # survival curve
        self._survivalCurve = \
            Path.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' survival times
        for patient in simulated_cohort.get_patients():

            # get the patient survival time
            survival_time = patient.get_survival_time()
            if not (survival_time is None):
                self._survivalTimes.append(survival_time)
                self._survivalCurve.record(survival_time, -1)

        # summary statistic
        self._sumStat_survivalTime = Stat.SummaryStat('Patient survival time',
                                                      self._survivalTimes)

        # find patients' number of strokes
        for patient in simulated_cohort.get_patients():
            self._numberStrokes_cohort.append(
                patient.get_number_strokes_individual())

        # summary statistic of strokes
        self._sumStat_numberStrokes = Stat.SummaryStat(
            'Patient number of strokes', self._numberStrokes_cohort)
    def __init__(self, simulated_cohort):
        """ extracts outputs from a simulated cohort
        :param simulated_cohort: a cohort after being simulated
        """

        self._survivalTimes = []  # patients' survival times
        self._timeToSTROKE = []  # patients' stroke times
        #we dont need costs or utilities here.

        # survival curve
        self._survivalCurve = \
            PathCls.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' survival times
        for patient in simulated_cohort.get_patients():

            # get the patient survival time
            survival_time = patient.get_survival_time()
            if not (survival_time is None):
                self._survivalTimes.append(
                    survival_time)  # store the survival time of this patient
                self._survivalCurve.record(survival_time,
                                           -1)  # update the survival curve

            # get the patient's time to AIDS
            time_To_STROKE = patient.get_these_stroke_times()
            if not (time_To_STROKE is None):
                self._time_To_STROKE.append(stroke_times)

        # summary statistics
        self._sumStat_survivalTime = StatCls.SummaryStat(
            'Patient survival time is... ', self._survivalTimes)
        self._sumState_timeToSTROKE = StatCls.SummaryStat(
            'Time until STROKE is...', self._timeToSTROKE)
    def __init__(self, simulated_cohort):
        """ extracts outputs from a simulated cohort
        :param simulated_cohort: a cohort after being simulated
        """

        self._eclampsiaTimes = []  # patients' eclampsia times
        self._utilities = []
        self._costs = []

        # eclampsia curve
        self._eclampsiaCurve = \
            PathCls.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' ec times
        for patient in simulated_cohort.get_patients():

            # get the patient EC time
            eclampsia_time = patient.get_eclampsia_time()
            if not (eclampsia_time is None):
                self._eclampsiaTimes.append(
                    eclampsia_time)  # store the EC time of this patient
                self._eclampsiaCurve.record(eclampsia_time,
                                            -1)  # update the EC curve

            self._costs.append(patient.get_total_discounted_cost())
            self._utilities.append(patient.get_total_discounted_utility())

        # summary statistics
        self._sumStat_ECTime = StatCls.SummaryStat('Patient Eclampsia time',
                                                   self._eclampsiaTimes)
        self._sumStat_cost = StatCls.SummaryStat('Patient discounted cost',
                                                 self._costs)
        self._sumStat_utility = StatCls.SummaryStat(
            'Patient discounted utility', self._utilities)
Exemple #11
0
    def __init__(self, simulated_cohort):
        """ extracts outputs from a simulated cohort
        :param simulated_cohort: a cohort after being simulated
        """

        self._survivalTimes = []  # patients' survival times
        self._strokes = []

        # survival curve
        self._survivalCurve = \
            PathCls.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' survival times
        for patient in simulated_cohort.get_patients():
            a = patient.get_numberofstroke()
            self._strokes.append(a)
            # get the patient survival time
            survival_time = patient.get_survival_time()
            if not (survival_time is None):
                self._survivalTimes.append(
                    survival_time)  # store the survival time of this patient
                self._survivalCurve.record(survival_time,
                                           -1)  # update the survival curve

        # summary statistics
        self._sumStat_survivalTime = StatCls.SummaryStat(
            'Patient survival time', self._survivalTimes)
Exemple #12
0
    def __init__(self, simulated_cohort):
        """ extracts outputs from a simulated cohort
        :param simulated_cohort: a cohort after being simulated
        """

        self._survivalTimes = []  # patients' survival times
        self._times_to_Stroke = []  # patients' times to have had a stroke

        # survival curve
        self._survivalCurve = \
            PathCls.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' survival times
        for patient in simulated_cohort.get_patients():

            # get the patient survival time
            survival_time = patient.get_survival_time()
            if not (survival_time is None):
                self._survivalTimes.append(
                    survival_time)  # store the survival time of this patient
                self._survivalCurve.record(survival_time,
                                           -1)  # update the survival curve

            # get the patient's time to post stroke
            time_to_stroke = patient.get_time_to_Stroke()
            if not (time_to_stroke is None):
                self._times_to_Stroke.append(time_to_stroke)

        # summary statistics
        self._sumStat_survivalTime = StatCls.SummaryStat(
            'Patient survival time', self._survivalTimes)
        self._sumState_timeToStroke = StatCls.SummaryStat(
            'Time until AIDS', self._times_to_Stroke)
Exemple #13
0
    def __init__(self, simulated_cohort):
        """ extracts outputs from a simulated cohort
        :param simulated_cohort: a cohort after being simulated
        """

        self._survivalTimes = []          # patients' survival times
        self._times_to_Stroke = []        # patients' times to stroke
        self._count_strokes = []
        self._utilities = []
        self._costs = []

        # survival curve
        self._survivalCurve = \
            PathCls.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' survival times
        for patient in simulated_cohort.get_patients():

            # get the patient survival time
            survival_time = patient.get_survival_time()
            if not (survival_time is None):
                self._survivalTimes.append(survival_time)           # store the survival time of this patient
                self._survivalCurve.record(survival_time, -1)       # update the survival curve

            count_strokes = patient.get_number_of_strokes()
            self._count_strokes.append(count_strokes)
            self._costs.append(patient.get_total_discounted_cost())
            self._utilities.append(patient.get_total_discounted_utility())

        # summary statistics
        self._sumStat_survivalTime = StatCls.SummaryStat('Patient survival time', self._survivalTimes)
        self._sumState_number_strokes = StatCls.SummaryStat('Time until stroke', self._count_strokes)
        self._sumStat_cost = StatCls.SummaryStat('Patient discounted cost', self._costs)
        self._sumStat_utility = StatCls.SummaryStat('Patient discounted utility', self._utilities)
Exemple #14
0
    def get_survival_curve(self):
        """ returns the sample path for the number of living patients over time """

        # find the initial population size
        n_pop = 2000
        # sample path (number of alive patients over time)
        n_living_patients = PathCls.SamplePathBatchUpdate('# of living patients', 0, n_pop)

        # record the times of deaths
        for obs in self._simulatedCohort.get_survival_time():
            n_living_patients.record(time=obs, increment=-1)

        return n_living_patients
def draw_survival_curves_and_histograms(simOutputs_no_therapy, simOutputs_anticoagulation):
    """
    :param simOutputs_no_therapy: no therapy
    :param simOutputs_anticoagulation: anticoagulation
    :return:
    """

    # get survival curves of both treatments
    survival_curves = [
        simOutputs_no_therapy.get_survival_curve(),
        simOutputs_anticoagulation.get_survival_curve()
    ]

    # graph survival curve
    PathCls.graph_sample_paths(
        sample_paths=survival_curves,
        title='Survival curve',
        x_label='Simulation time step (year)',
        y_label='Number of alive patients',
        legends=['No Therapy', 'Anticoagulation Therapy']
    )

    # histograms of survival times
    set_of_survival_times = [
        simOutputs_no_therapy.get_survival_times(),
        simOutputs_anticoagulation.get_survival_times()
    ]

    # graph histograms
    Figs.graph_histograms(
        data_sets=set_of_survival_times,
        title='Histogram of patient survival time',
        x_label='Survival time (year)',
        y_label='Counts',
        bin_width=1,
        legend=['No Therapy', 'Anticoagualtion Therapy'],
        transparency=0.6
    )
Exemple #16
0
def draw_survival_curves_and_histograms(simOutputs_anti, simOutputs_none):
    """ draws the survival curves and the histograms of time until STROKE deaths
    :param simOutputs_anti: output of a cohort simulated under ANTI therapy
    :param simOutputs_none: output of a cohort simulated under NONE therapy
    """

    # get survival curves of both treatments
    survival_curves = [
        simOutputs_anti.get_survival_curve(),
        simOutputs_none.get_survival_curve()
    ]

    # graph survival curve
    PathCls.graph_sample_paths(
        sample_paths=survival_curves,
        title='Survival curve',
        x_label='Simulation time step (year)',
        y_label='Number of alive patients',
        legends=['Anticoagulant Therapy', 'None Therapy']
    )

    # histograms of survival times
    set_of_survival_times = [
        simOutputs_anti.get_survival_times(),
        simOutputs_none.get_survival_times()
    ]

    # graph histograms
    Figs.graph_histograms(
        data_sets=set_of_survival_times,
        title='Histogram of patient survival time',
        x_label='Survival time (year)',
        y_label='Counts',
        bin_width=1,
        legend=['Anticoagulant Therapy', 'None Therapy'],
        transparency=0.6
    )
def draw_survival_curves_and_histograms(simOutputs_warfarin,
                                        simOutputs_dabigatran_110,
                                        simOutputs_dabigatran_150):
    # draws the survival curves and the histograms of time until death

    # get survival curves of all treatments
    survival_curves = [
        simOutputs_warfarin.get_survival_curve(),
        simOutputs_dabigatran_110.get_survival_curve(),
        simOutputs_dabigatran_150.get_survival_curve()
    ]

    # graph survival curve
    PathCls.graph_sample_paths(
        sample_paths=survival_curves,
        title='Survival curve',
        x_label='Simulation time step (year)',
        y_label='Number of alive patients',
        legends=['Warfarin', 'Dabigatran 110', 'Dabigatran 150'])

    # histograms of survival times
    set_of_survival_times = [
        simOutputs_warfarin.get_survival_times(),
        simOutputs_dabigatran_110.get_survival_times(),
        simOutputs_dabigatran_150.get_survival_times()
    ]

    # graph histograms
    Figs.graph_histograms(
        data_sets=set_of_survival_times,
        title='Histogram of patient survival time',
        x_label='Survival time (year)',
        y_label='Counts',
        bin_width=0.5,
        legend=['Warfarin', 'Dabigatran 110', 'Dabigatran 150'],
        transparency=0.6)
    def get_survival_curve(self):
        """ returns the sample path for the number of living patients over time """

        # find the initial population size
        n_pop = self._simulatedCohort.get_initial_pop_size()
        # sample path (number of alive patients over time)
        n_living_patients = PathCls.SamplePathBatchUpdate('# of living patients', 5, n_pop)

        # record the times of deaths
        for obs in self._simulatedCohort.get_survival_times():
            n_living_patients.record(time=obs, increment=-1)

        return n_living_patients

        after5 = n_living_patients / n_pop

        print('Percentage of living patients after 5 years:', after5 )
    def __init__(self, simulated_cohort):

        self._survivalTimes = []

        self._survivalCurve = PathClasses.SamplePathBatchUpdate(
            'Population over time', id,
            simulated_cohort.get_initial_pop_size())

        for patient in simulated_cohort.get_patients():

            survival_time = patient.get_survival_time()
            if not (survival_time is None):
                self._survivalTimes.append(survival_time)
                self._survivalCurve.record(survival_time, -1)

        self._sumStat_survivalTime = StatClasses.SummaryStat(
            'Patient Survival Time', self._survivalTimes)
    def __init__(self, simulated_cohort):
        """ extracts outputs from a simulated cohort
        :param simulated_cohort: a cohort after being simulated
        """

        self._survivalTimes = []  # patients' survival times
        self._times_to_CANCER = []  # patients' times to CANCER
        self._costs = []  # patients' discounted total costs
        self._utilities = []  # patients' discounted total utilities

        # survival curve
        self._survivalCurve = \
            PathCls.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' survival times
        for patient in simulated_cohort.get_patients():

            # get the patient survival time
            survival_time = patient.get_survival_time()
            if not (survival_time is None):
                self._survivalTimes.append(
                    survival_time)  # store the survival time of this patient
                self._survivalCurve.record(survival_time,
                                           -1)  # update the survival curve

            # get the patient's time to CANCER
            time_to_CANCER = patient.get_time_to_CANCER()
            if not (time_to_CANCER is None):
                self._times_to_CANCER.append(time_to_CANCER)

            # cost and utility
            self._costs.append(patient.get_total_discounted_cost())
            self._utilities.append(patient.get_total_discounted_utility())

        # summary statistics
        self._sumStat_survivalTime = StatCls.SummaryStat(
            'Patient survival time', self._survivalTimes)
        self._sumState_timeToCANCER = StatCls.SummaryStat(
            'Time until Cancer', self._times_to_CANCER)
        self._sumStat_cost = StatCls.SummaryStat('Patient discounted cost',
                                                 self._costs)
        self._sumStat_utility = StatCls.SummaryStat(
            'Patient discounted utility', self._utilities)
    def __init__(self, simulated_cohort):
        """ extracts outputs from a simulated cohort
        :param simulated_cohort: a cohort after being simulated
        """

        self._survivalTimes = []  # patients' survival times
        self._times_to_POST_STROKE = []  # patients' times to POST_STROKE
        self._strokeCount = []

        # survival curve
        self._survivalCurve = \
            PathCls.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' survival times
        for patient in simulated_cohort.get_patients():

            # get the patient survival time
            survival_time = patient.get_survival_time()
            if not (survival_time is None):
                self._survivalTimes.append(
                    survival_time)  # store the survival time of this patient
                self._survivalCurve.record(survival_time,
                                           -1)  # update the survival curve

            stroke_count = patient.get_stroke_count()
            if not (stroke_count is None):
                self._strokeCount.append(stroke_count)

            # get the patient's time to POST_STROKE
            time_to_POST_STROKE = patient.get_time_to_POST_STROKE()
            if not (time_to_POST_STROKE is None):
                self._times_to_POST_STROKE.append(time_to_POST_STROKE)

        # summary statistics
        self._sumStat_survivalTime = StatCls.SummaryStat(
            'Patient survival time', self._survivalTimes)
        self._sumState_timeToPOST_STROKE = StatCls.SummaryStat(
            'Time until POST_STROKE', self._times_to_POST_STROKE)
        self._sumStat_stroke = StatCls.SummaryStat('Number of strokes',
                                                   self._strokeCount)
    def __init__(self, simulated_cohort):
        """ extracts outputs from a simulated cohort
        :param simulated_cohort: a cohort after being simulated
        """

        self._infectionTimes = []        # patients' infection times
        self._count_infections = []
        self._utilities = []
        self._costs = []
        self._count_treated = []

        #infection curve
        self._infectionCurve = \
            PathCls.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' infection times
        for patient in simulated_cohort.get_patients():

            # get the patient infection time
            infection_time = patient.get_infection_duration()
            if not (infection_time is None):
                self._infectionTimes.append(infection_time)           # store the infection time of this patient
                self._infectionCurve.record(infection_time, -1)       # update the infection curve

            count_infections = patient.get_number_of_infections()
            count_treated = patient.get_number_of_infections()

            self._count_infections.append(count_infections)
            self._infectionTimes.append(infection_time)
            self._costs.append(patient.get_total_discounted_cost())
            self._utilities.append(patient.get_total_discounted_utility())
            self._count_treated.append(count_treated)

        # summary statistics
        self._sumStat_infectionTime = StatCls.SummaryStat('Patient infection time', self._infectionTimes)
        self._sumStat_number_infections = StatCls.SummaryStat('Time until infection', self._count_infections)
        self._sumStat_cost = StatCls.SummaryStat('Patient discounted cost', self._costs)
        self._sumStat_utility = StatCls.SummaryStat('Patient discounted utility', self._utilities)
        self._sumStat_treated= StatCls.SummaryStat('Number of Infections Treated', self._count_treated)
    def __init__(self, simulated_cohort):
        """ extracts outputs from a simulated cohort
        :param simulated_cohort: a cohort after being simulated
        """

        self._survivalTimes = []  # patients' survival times
        self._times_to_AIDS = []  # patients' times to AIDS
        self._stroke_total_number = []
        # survival curve
        self._survivalCurve = \
            PathCls.SamplePathBatchUpdate('Population size over time', id, simulated_cohort.get_initial_pop_size())

        # find patients' survival times
        for patient in simulated_cohort.get_patients():
            self._stroke_total_number.append(
                patient._stateMonitor.get_stroke_number())
            # get the patient survival time
            survival_time = patient.get_survival_time()
            if not (survival_time is None):
                self._survivalTimes.append(
                    survival_time)  # store the survival time of this patient
                self._survivalCurve.record(survival_time,
                                           -1)  # update the survival curve

            # get the patient's time to AIDS
            time_to_AIDS = patient.get_time_to_AIDS()
            if not (time_to_AIDS is None):
                self._times_to_AIDS.append(time_to_AIDS)

        # summary statistics
        self._sumStat_survivalTime = StatCls.SummaryStat(
            'Patient survival time', self._survivalTimes)
        self._sumState_timeToAIDS = StatCls.SummaryStat(
            'Time until AIDS', self._times_to_AIDS)
        self._sumStat_strokenumber = StatCls.SummaryStat(
            "number of stroke", self.get_stroke_total())
    [0, 0, 0, 0, 0, 0, 0]  #OTHERDEATH
]

# Run
# create cohorts
standard = Cohort(id=1, therapy=Therapies.STANDARD)

population = Cohort(id=1, therapy=Therapies.POPULATION)

# simulate the cohorts
standardOutputs = standard.simulate()
populationOutputs = population.simulate()

# graph survival curve
PathCls.graph_sample_path(sample_path=standardOutputs.get_survival_curve(),
                          title='Survival curve for standard testing',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

# graph histogram of survival times
Figs.graph_histogram(data=standardOutputs.get_survival_times(),
                     title='Survival times of patients for standard testing',
                     x_label='Survival time (years)',
                     y_label='Counts',
                     bin_width=1)
# graph survival curve
PathCls.graph_sample_path(sample_path=populationOutputs.get_survival_curve(),
                          title='Survival curve for population testing',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

# graph histogram of survival times
Exemple #25
0
import Q4_ParameterClasses as P
import Q4_MarkovModelClasses as MarkovCls
import Q4_SupportMarkovModel as SupportMarkov
import scr.SamplePathClasses as PathCls
import scr.FigureSupport as Figs

# create a cohort
cohort = MarkovCls.Cohort(id=1, therapy=P.Therapies.MONO)

# simulate the cohort
simOutputs = cohort.simulate()

# graph survival curve
PathCls.graph_sample_path(sample_path=simOutputs.get_survival_curve(),
                          title='Survival curve',
                          x_label='Simulation time step',
                          y_label='Number of alive patients')

# graph histogram of survival times
Figs.graph_histogram(
    data=simOutputs.get_survival_times(),
    title='Survival times of patients with atrial fibrillation',
    x_label='Survival time (years)',
    y_label='Counts',
    bin_width=1)

# graph histogram of number of stroke
Figs.graph_histogram(
    data=simOutputs.get_survival_times(),
    title='Survival times of patients with atrial fibrillation',
    x_label='Survival time (years)',
Exemple #26
0
print(meansurvival, CI_of_Expected)
print(meansurvival_TWO, CI_of_Expected_TWO)

cohortOUT_ONE = CohortOutcomes(cohort_ONE)

cohortOUT_TWO = CohortOutcomes(cohort_TWO)

survival_curves = [
    cohortOUT_ONE.get_survival_curve(),
    cohortOUT_TWO.get_survival_curve()
]

PathCls.graph_sample_paths(sample_paths=survival_curves,
                           title='Survival curve',
                           x_label='Simulation time step',
                           y_label='Number of alive patients',
                           legends=['No Drug', 'With Drug'])

set_of_STROKE_times = [
    cohort_ONE.get_STROKE_time(),
    cohort_TWO.get_STROKE_time()
]

Figs.graph_histograms(data_sets=set_of_STROKE_times,
                      title='Histogram of patient STROKE time',
                      x_label='Survival time',
                      y_label='Counts',
                      bin_width=1,
                      legend=['No Drug', 'With Drug'],
                      transparency=0.6)
Exemple #27
0
import MarkovModelClasses as MarkovCls
import ParameterClasses as ParameterCls
import SupportMarkovModel as SupportModel
import scr.SamplePathClasses as PathCls
import scr.FigureSupport as Figs

# create the cohorts
cohort_anticoagulant = MarkovCls.Cohort(
    id=0, therapy=ParameterCls.Therapies.ANTICOAGULANT)
cohort_no_therapy = MarkovCls.Cohort(id=0,
                                     therapy=ParameterCls.Therapies.NO_THERAPY)

# simulate the cohorts
simOutputs_anticoagulant = cohort_anticoagulant.simulate()
simOutputs_no_therapy = cohort_no_therapy.simulate()

# graph the survival curve for anticoagulant
PathCls.graph_sample_path(
    sample_path=simOutputs_anticoagulant.get_survival_curve(),
    title='Survival Curve for Treatment (anticoag)',
    x_label='Time',
    y_label='Number of people still alive')

# graph the survival curve for no therapy
PathCls.graph_sample_path(
    sample_path=simOutputs_no_therapy.get_survival_curve(),
    title='Survival Curve for Those Without Treatment',
    x_label='Time',
    y_label='Number of people still alive')
Exemple #28
0
import MarkovModel as MarkovCls
import SupportMarkovModel as SupportMarkov
import scr.SamplePathClasses as PathCls
import scr.FigureSupport as Figs

# create and simulate cohort for warfarin
warfarin_cohort = MarkovCls.Cohort(
    id=1,
    therapy=P.Therapies.WARFARIN)

warfarin_simOutputs = warfarin_cohort.simulate()

# graph survival curve
PathCls.graph_sample_path(
    sample_path=warfarin_simOutputs.get_survival_curve(),
    title='Survival curve, Warfarin',
    x_label='Simulation time step',
    y_label='Number of alive patients'
    )

# graph histogram of survival times
Figs.graph_histogram(
    data=warfarin_simOutputs.get_survival_times(),
    title='Survival times of patients with Stroke, Warfarin',
    x_label='Survival time (years)',
    y_label='Counts',
    bin_width=0.5
)

# graph histogram of number of strokes
Figs.graph_histogram(
    data=warfarin_simOutputs.get_if_developed_stroke(),
Exemple #29
0
import MarkovcClasses as MarkovClasses
import Parameters as Parameters
import SupportMarkovModel as Support
import scr.SamplePathClasses as PathClasses

# no drug
cohort1 = MarkovClasses.Cohort(id=1, therapy=Parameters.Therapies.no_drug)
simOutputs1 = cohort1.simulate()
Support.print_outcomes(simOutputs1, "No drug")

# drug treatment
cohort2 = MarkovClasses.Cohort(id=1, therapy=Parameters.Therapies.tx_drug)
simOutputs2 = cohort2.simulate()
Support.print_outcomes(simOutputs2, "Drug Treatment")

# survival curves
PathClasses.graph_sample_path(sample_path=simOutputs1.get_survival_curve(),
                              title='Survival curve (no drug)',
                              x_label='Simulation time step',
                              y_label='Number of alive individuals')

PathClasses.graph_sample_path(sample_path=simOutputs2.get_survival_curve(),
                              title='Survival curve (drug treatment)',
                              x_label='Simulation time step',
                              y_label='Number of alive individuals')
Exemple #30
0
import SupportMarkovModel as SupportMarkov
import scr.SamplePathClasses as PathCls
import scr.FigureSupport as Figs

# create a cohort
cohort_NONE = MarkovCls.Cohort(id=0, therapy=P.Therapies.NONE)

cohort_ANTICOAG = MarkovCls.Cohort(id=0, therapy=P.Therapies.ANTICOAG)

# simulate the cohort
simOutputs_NONE = cohort_NONE.simulate()
simOutputs_ANTICOAG = cohort_ANTICOAG.simulate()

# graph survival curve
PathCls.graph_sample_path(sample_path=simOutputs_NONE.get_survival_curve(),
                          title='Survival curve',
                          x_label='Simulation time step (no therapy)',
                          y_label='Number of alive patients')

PathCls.graph_sample_path(
    sample_path=simOutputs_ANTICOAG.get_survival_curve(),
    title='Survival curve',
    x_label='Simulation time step (anticoagulation therapy)',
    y_label='Number of alive patients')

# graph histogram of survival times
Figs.graph_histogram(
    data=simOutputs_NONE.get_survival_times(),
    title='Survival times of patients with Stroke (no therapy)',
    x_label='Survival time (years)',
    y_label='Counts',
    bin_width=1)