1
module ParasitemiaCore.Config
10 | DebugOn of string // Output directory.
13 rbcDiameter
: float<μm
>
14 resolution
: float<ppi
>
16 ratioAreaPaleCenter
: float32
// The area of the second opening is 'ratioSecondAreaOpen' * mean RBC area. It's applied only if greater than 'initialAreaOpen'.
18 granulometryRange
: float32
// The radius will be seeked from radius - granulometryRange * radius to radius + granulometryRange * radius.
20 minRbcRadius
: float32
// Factor of the mean RBC radius.
21 maxRbcRadius
: float32
// Factor of the mean RBC radius.
23 LPFStandardDeviation: float<μm
> // Sigma parameter of the gaussian to remove the high frequency noise.
26 factorNbPick
: float // The number of computed ellipse per edge pixel.
28 // Parasites detection.
29 darkStainLevel
: float // Lower -> more sensitive. Careful about illumination on the borders.
30 maxDarkStainRatio
: float // When a cell must own less than this ratio to be a RBC.
32 stainArea
: float32
// Factor of a RBC area. 0.5 means the half of RBC area.
33 stainSensitivity
: float // between 0 (the least sensitive) and 1 (the most sensitive).
34 maxStainRatio
: float // A cell must own less than this ratio to be a RBC.
36 infectionArea
: float32
// Factor of a RBC area. 0.5 means the half of RBC area.
37 infectionSensitivity
: float // between 0 (the least sensitive) and 1 (the most sensitive).
39 standardDeviationMaxRatio
: float // The standard deviation of the pixel values of a cell can't be greater than standardDeviationMaxRatio * global standard deviation
40 minimumCellAreaFactor
: float32
// Factor of the mean RBC area. A cell with an area below this will be rejected.
43 let defaultParameters = {
45 resolution
= 220.e3
<ppi
> // Correspond to 50X.
47 ratioAreaPaleCenter
= 1.f
/ 3.f
// The ratio between an RBC area and the area of the its pale center.
49 granulometryRange
= 0.5f
54 LPFStandardDeviation = 0.2<μm
> // 8.5e-6<inch>.
58 darkStainLevel
= 0.25 // 0.3
59 maxDarkStainRatio
= 0.1 // 10 %
61 infectionArea
= 0.012f // 1.2 %
62 infectionSensitivity
= 0.9
64 stainArea
= 0.08f // 8 %
65 stainSensitivity
= 0.9
66 maxStainRatio
= 0.12 // 12 %
68 standardDeviationMaxRatio
= 0.5 // 0.5
69 minimumCellAreaFactor
= 0.4f }
71 type RBCRadius (radius: float32
, parameters
: Parameters) =
72 member this
.Pixel = radius
73 member this
.μm
: float<μm
> =
74 1.<px
> * (float radius) / parameters
.resolution
|> inchToμm
76 member this
.Min = radius + parameters
.minRbcRadius
* radius
77 member this
.Max = radius + parameters
.maxRbcRadius
* radius
79 member this
.Area = PI * radius ** 2.f
80 member this
.MinArea = parameters
.minimumCellAreaFactor
* radius
82 member this
.InfectionArea = parameters
.infectionArea
* this
.Area
83 member this
.StainArea = parameters
.stainArea
* this
.Area
85 override this.ToString() =
86 sprintf
"%d px (%.1f μm)" (Utils.roundInt
<| 2.f
* radius) (2. * this.μm
)
88 type Config (param
: Parameters) =
89 let RBCadiusInPixels (rbcDiameter
: float<μm
>) (resolution
: float<ppi
>) : float32
=
90 let rbcRadiusInch: float<inch
> = (μmToInch rbcDiameter
) / 2.
91 let rbcRadiusPx: float<px
> = resolution
* rbcRadiusInch
94 let mutable parameters: Parameters = param
95 let mutable rbcRadiusByResolution = RBCRadius(RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, parameters)
96 let mutable rbcRadius = RBCRadius(0.f
, parameters)
98 new () = Config(defaultParameters)
100 member this.Parameters
101 with get
() = parameters
104 rbcRadiusByResolution <- RBCRadius(RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, param
)
105 rbcRadius <- RBCRadius(rbcRadius.Pixel, param
)
107 member val Debug = DebugOff with get
, set
109 member this.LPFStandardDeviation =
110 let stdDeviation: float<px
> = (μmToInch
parameters.LPFStandardDeviation) * parameters.resolution
113 member this.RBCRadiusByResolution = rbcRadiusByResolution
114 member this.RBCRadius = rbcRadius
116 member this.SetRBCRadius (radiusPixel
: float32
) =
117 rbcRadius <- RBCRadius(radiusPixel
, parameters)
119 member this.Copy () =
120 this.MemberwiseClone() :?> Config