Chapter 3: Support classes for Loop

3.1: Costs

The class Costs computes treatment, screening and biopsy costs given age and other arguments that specifically apply to the cost-type.

The class's constructor reads the costs specifications from its Scenario argument. The specifications are formatted like this:


#         discount:             pairs of (increasing) begin-diam: cost
#         age   cost    biop    (first diameter must be 0)
costs:    50    0       176     0: 6438  20: 7128  50: 7701
    

Its d_treatment vector stores the various diameter/costs combinations. The age specifications are double values.

Biopsy, screening and treatment costs are all computed by the member discount. Depending on the context (cf. section 2.5) either the screening age or the tumor self-detection age is used as discount's age argument.

When computing the biopsy cost the configured biopsy cost is used as discount's cost argument. When computing the screening costs the costs of the used modality are used. When computing the treatment costs the biopsy costs plus the costs associated with the tumor's diameter are used.

The member discount is a simple 1-line function:

    double Costs::discount(double age, size_t cost) const
    {
        return cost * pow(1 + d_discountProportion, d_referenceAge - age);
    }

The costs associated with the tumor's diameter is returned by the member cost, returning the costs that are associated with the last configured diameter that is at least equal to the specified diameter (e.g., if the diameters 0, 20, and 50 are configured and the specified diameter is equal to 30 then the costs associated with diameter 20 are used.

3.2: Densities

The Densities object provides access to information about the breast densities (cf. bi-rads info). The American College of Radiology (ACR) distinguishes four breast densitiy categories: (see also the ACR reference card)

In the simrisc configuration file the distributions of probabilities of these four categories by age groups are provided by the breastDensities: specifications, e.g.,


                                    bi-rad classification
                                 ----------------------------
                     agegroup     a       b       c       d
 breastDensities:    0  - 40     0.05    0.30    0.48    0.17
 ...
 breastDensities:    70 - *      0.18    0.54    0.26    0.02
    

Age groups consist of an initial age and an upper limit. The upper limit is not considered part of the age range, but becomes the initial age of the next range. The final age range may use age specification *, indicating the maximum possible age of simulated cases. Specifications following a specification using ending age * are ignored. Simrisc checks whether the bi-rad probabilities per age group add to 1.00, and whether the ending age of an age group is equal to the initial age of the next age group.

At the initialization phase of Loop::genCases (cf. section 2.5.2 breast densitiy indices (0..3) corresponding to bi-rad classifications a..d are determined for the simulated case's screening ages. The member Densities::indices generates a random value from the uniform random distribution and uses that probability to determine the bi-rad classification for the various screening ages, returning a vector containing the bi-rad classifications (0..3) for each screening round.

3.2.1: Density

Objects of the class Density contain the information about a single density age-group. It contains the density's age-group, bi-rad values and a vector of cumulative bi-rad values allowing fast lookups of a bi-rad category given a (randomly determined) proportion value.

3.3: Modalities

Screening modalities are accessed via the Modalities object. The modalities object provides the interface to modalities that are defined for screening rounds. All modalities that are thus accessible are derived from a base class ModBase. ModBase defines the interface that must be offered by classes derived from ModBase. This allows reuse of existing components of simrisc that use modalities, irrespective of what actual modalities are configured for the various screening rounds.

The structure of this design is illustrated in Figure 3.

Figure 3: The Modalities design

Figure 3 shows the Modality object in blue. It communicates with ModBase objects. ModBase is a polymorphic base clase completely defining the interface modalities must provide. What modalities there are or will be at some poiny in the future is irrelevant, as long as these future modalities implement the interface required by ModBase.

Currently three modalities are available: an MRI modality, a Mammo modality and a Tomo modality. The arrows pointing down from ModBase suggest time: MammoTomo was originally implemented. At some later point in time MRI was added. At some point in the future another, as yet unknown, modality may be added. At that point only the new modality must be implemented, but the program using the new modality can be reused, not requiring additional modifications.

The Modality constructor receives the modality parameter specifications from the configuration file. Modality parameters specify the name of the modality; the costs of using the modality; optionally specifications of radiation doses for the treatment of the four bi-rads categories; the modality's sensitivity (optionally differently specified for the four bi-rads categories, and the modality's specificity, optionally using age groups, like the age groups that were used when specifying breast density parameters. E.g.,


#                       bi-rads bi-rads             (agegroups: values)
# modalities id    cost dose    sensitivity         specificity
#                       1..4    1..4                            
modality:    Mammo 64   3 3 3 3 0.87 0.84 0.73 0.65 0-40: 0.961 40-*: 0.965
modality:    MRI   64           0.00                0.00
        

The constructor uses the specification ID to create the matching modality-handling object. Modality handlers are derived from the (polymorphic) modality base class ModBase (see the next section).

When a screening is performed for a specific screening age (cf. section 2.5.5.2) then all modalities that were specified for that screening age are visited in turn. Screening round specifications define the modalities that are used for those rounds (cf. section 3.4). The Screening class provides, per screening round, the names (IDs) of the modalities that are used for those rounds, The member Modality::use receives these IDs and returns pointers to the modalities that are associated with those IDs. Those modalities are then applied in turn to the current case.

3.3.1: the base class ModBase

The class ModBase defines the interface for modalities that is available to other parts of simrisc, in particular to members of the class Loop (cf. section 2.5). The interface provides the following members:

3.3.1.1: the derived class MRI

The class MRI is derived from ModBase.

MRI's base class extracts the costs parameter from the configuration file.

Its sensitivity (vSensitivity) and specificity vSpecificity) values are constants, and there are no radiation doses associated with this modality (the vDose members return zeroes).

3.3.1.2: the derived class Mammo

The class Mammo is derived from ModBase.

Mammo's base class extracts the costs parameter from the configuration file.

Its sensitivity is computed by its vSensitivity member. The sensitivity of the Mammo modality depends on the tumor's diameter and the configured beta parameters.

As a reference, here is the member implementing Mammo's sensitivity computation:

    // cf. Isheden, G., & Humphreys, K. (2017). Modelling breast cancer tumour
    // growth for a stable disease population. Statistical Methods in Medical
    // Research, 28(3), 681-702.
    
    double Mammo::vSensitivity(size_t idx) const
    {
        double diameter = d_tumor.diameter();
        double mValue = d_m[idx];
    
        double expBeta = 
            exp(
                d_beta[0]            +
                d_beta[1] * diameter +
                d_beta[2] * mValue   +
                d_beta[3] * mValue / (diameter * diameter)
            );
      
        return  (1 - d_sysErr) * expBeta / (1 + expBeta);
    
    }

This function also uses the systematic error which is also configured in the configuration file (Mammo: systematicError:).

The modality's specificity is obtained by finding the case's actual age in the vector d_specVect (as configured in the configuration file) and returning the associated specificity value.

Likewise, the radiation doses are returned by the vDose members, where the bi-rad category can be used as index (0 for 'a' through 3 for 'd').

3.3.1.3: the derived class Tomo

The class Tomo is derived from ModBase.

Tomo's base class extracts the costs parameter from the configuration file.

The modality's specificity is obtained by finding the case's actual age in the vector d_specVect (as configured in the configuration file) and returning the associated specificity value.

Likewise, the radiation doses and sensitivity values are returned by the vDose and vSensitivity members, using bi-rad category as index (0 for 'a' through 3 for 'd').

3.4: Screening and Rounds

The class Screening handles the screening parameters. Screening parameters are obtained from the Scenario object (cf. section 2.4).

At construction time the following parameters are obtained:

Its member radiationRisk returns a vector of double values for each (integral) age. It uses the bi-rad indices which are recomputed for each new case (cf. section 2.5.2) and consequently it is called by Loop::genCases for each similated case.

3.5: Tumor

3.5.1: Resetting the tumor data

3.5.2: Computing the tumor's characteristics

3.5.3: Computing the dying age because of the tumor

3.6: TumorInfo

Objects of the class TumorInfo provide access to the following paramters: Beir7, Growth, Incidence and Survival, which are covered in the following sections.

In addition its member cumTotalRisk computes the cumulative total risk, given the radiationrisk as determined in Loop::caseInit. For each case the (Incidence) carrier is randomly determined given the probabilites of the various carriers.

The cumulative total risks over all ages are computed by subsequently adding the products of the risk of getting a tumor (given the selected carrier) times the radiation risk (for the used age).

3.6.1: Beir7

The class Beir7 stores the Tumor Beir7's beta, eta, spread and the spread-distribution configuration parameters. It's a wrapper class for these parameters, offering accessors to each of them.

3.6.2: Growth

3.6.3: Incidence

3.6.4: Survival