1
module ParasitemiaCore.Config
10 | DebugOn of string // Output directory.
13 rbcDiameter
: float<μm
>
14 resolution
: float<ppi
>
16 averageColor_BG
: float32
* float32
* float32
// R * G * B.
17 averageColor_RBC
: float32
* float32
* float32
// R * G * B.
18 averageColor_Parasite
: float32
* float32
* float32
// R * G * B.
20 ratioAreaPaleCenter
: float32
// The area of the second opening is 'ratioSecondAreaOpen' * mean RBC area. It's applied only if greater than 'initialAreaOpen'.
22 granulometryRange
: float32
// The radius will be seeked from radius - granulometryRange * radius to radius + granulometryRange * radius.
24 minRbcRadius
: float32
// Factor of the mean RBC radius.
25 maxRbcRadius
: float32
// Factor of the mean RBC radius.
27 LPFStandardDeviationParasite: float<μm
> // Sigma parameter of the gaussian to remove the high frequency noise.
28 LPFStandardDeviationRBC: float<μm
>
31 factorNbPick
: float // The number of computed ellipse per edge pixel.
33 // Parasites detection.
34 darkStainLevel
: float // Lower -> more sensitive. Careful about illumination on the borders.
35 maxDarkStainRatio
: float // When a cell must own less than this ratio to be a RBC.
37 parasiteRadiusRatio
: float32
// The ratio of the parasite radius of the RBC radius.
38 minimumParasiteAreaRatio
: float32
// Factor of a RBC area. 0.5 means the half of RBC area.
40 cytoplasmSensitivity
: float // between 0 (the least sensitive) and 1 (the most sensitive).
42 nucleusAreaRatio
: float32
// Factor of a RBC area. 0.5 means the half of RBC area.
43 infectionSensitivity
: float // between 0 (the least sensitive) and 1 (the most sensitive).
45 standardDeviationMaxRatio
: float // The standard deviation of the pixel values of a cell can't be greater than standardDeviationMaxRatio * global standard deviation
46 minimumCellAreaFactor
: float32
// Factor of the mean RBC area. A cell with an area below this will be rejected.
49 let defaultParameters = {
51 resolution
= 220.e3
<ppi
> // 220.e3<ppi> Correspond to 50X.
53 averageColor_BG
= 113.3f, 135.3f, 150.3f
54 averageColor_RBC
= 94.7f, 80.7f, 99.3f
55 averageColor_Parasite
= 76.f
, 58.f
, 94.f
57 (*averageColor_BG = 179.f, 148.f, 121.f
58 averageColor_RBC = 141.f, 96.f, 83.f
59 averageColor_Parasite = 123.f, 89.f, 83.f*)
61 ratioAreaPaleCenter
= 2.f
/ 5.f
// The ratio between an RBC area and the area of the its pale center.
63 granulometryRange
= 0.5f
68 LPFStandardDeviationParasite = 0.15<μm
>
69 LPFStandardDeviationRBC = 0.2<μm
>
74 maxDarkStainRatio
= 0.1 // 10 %
76 parasiteRadiusRatio
= 0.5f // 40 %
78 minimumParasiteAreaRatio
= 0.02f // 2 %
79 cytoplasmSensitivity
= 0.96 // 1) 0.91, 2) 0.92
81 nucleusAreaRatio
= 0.01f // 1.0 %
82 infectionSensitivity
= 0.9 // 1) 0.93, 2) 0.94
84 standardDeviationMaxRatio
= 0.5 // 0.5
85 minimumCellAreaFactor
= 0.4f }
87 type RBCRadius (radius: float32
, parameters
: Parameters) =
88 member this
.Pixel = radius
89 member this
.μm
: float<μm
> =
90 1.<px
> * (float radius) / parameters
.resolution
|> inchToμm
92 member this
.Min = radius + parameters
.minRbcRadius
* radius
93 member this
.Max = radius + parameters
.maxRbcRadius
* radius
95 member this
.Area = PI * radius ** 2.f
96 member this
.MinArea = parameters
.minimumCellAreaFactor
* this
.Area
98 member this
.ParasiteRadius = parameters
.parasiteRadiusRatio
* radius
100 member this
.NucleusArea = parameters
.nucleusAreaRatio
* this
.Area
101 member this
.MinimumParasiteArea = parameters
.minimumParasiteAreaRatio
* this
.Area
103 override this.ToString() =
104 sprintf
"%d px (%.1f μm)" (Utils.roundInt
<| 2.f
* radius) (2. * this.μm
)
106 type Config (param
: Parameters) =
107 let RBCadiusInPixels (rbcDiameter
: float<μm
>) (resolution
: float<ppi
>) : float32
=
108 let rbcRadiusInch: float<inch
> = (μmToInch rbcDiameter
) / 2.
109 let rbcRadiusPx: float<px
> = resolution
* rbcRadiusInch
112 let mutable parameters: Parameters = param
113 let mutable rbcRadiusByResolution = RBCRadius(RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, parameters)
114 let mutable rbcRadius = RBCRadius(0.f
, parameters)
116 new () = Config(defaultParameters)
118 member this.Parameters
119 with get
() = parameters
122 rbcRadiusByResolution <- RBCRadius(RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, param
)
123 rbcRadius <- RBCRadius(rbcRadius.Pixel, param
)
125 member val Debug = DebugOff with get
, set
127 member this.LPFStandardDeviationParasite =
128 let stdDeviation: float<px
> = (μmToInch
parameters.LPFStandardDeviationParasite) * parameters.resolution
131 member this.LPFStandardDeviationRBC =
132 let stdDeviation: float<px
> = (μmToInch
parameters.LPFStandardDeviationRBC) * parameters.resolution
135 member this.RBCRadiusByResolution = rbcRadiusByResolution
136 member this.RBCRadius = rbcRadius
138 member this.SetRBCRadius (radiusPixel
: float32
) =
139 rbcRadius <- RBCRadius(radiusPixel
, parameters)
141 member this.Copy () =
142 this.MemberwiseClone() :?> Config