1
module ParasitemiaCore.Config
10 | DebugOn of string // Output directory.
13 rbcDiameter
: float<μm
>
14 resolution
: float<ppi
>
16 colorContribution_BG_RBC
: float * float * float // (R, G, B).
17 colorContribution_RBC_parasite
: float * float * float // (R, G, B).
19 ratioAreaPaleCenter
: float32
// The area of the second opening is 'ratioSecondAreaOpen' * mean RBC area. It's applied only if greater than 'initialAreaOpen'.
21 granulometryRange
: float32
// The radius will be seeked from radius - granulometryRange * radius to radius + granulometryRange * radius.
23 minRbcRadius
: float32
// Factor of the mean RBC radius.
24 maxRbcRadius
: float32
// Factor of the mean RBC radius.
26 LPFStandardDeviationParasite: float<μm
> // Sigma parameter of the gaussian to remove the high frequency noise.
27 LPFStandardDeviationStain: float<μm
>
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.
39 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 colorContribution_BG_RBC
= (* 0., 1., 0. *) 0.16, 0.44, 0.4
54 colorContribution_RBC_parasite
= (* 1., 0., 0. *) 0.54, 0.41, 0.05
56 ratioAreaPaleCenter
= 2.f
/ 5.f
// The ratio between an RBC area and the area of the its pale center.
58 granulometryRange
= 0.5f
63 LPFStandardDeviationParasite = 0.15<μm
>
64 LPFStandardDeviationStain = 0.15<μm
> // 0.12
65 LPFStandardDeviationRBC = 0.2<μm
> // 8.5e-6<inch>. // 0.2<μm>
69 darkStainLevel
= 0.25 // 0.3
70 maxDarkStainRatio
= 0.1 // 10 %
72 parasiteRadiusRatio
= 0.5f // 40 %
74 minimumParasiteAreaRatio
= 0.02f // 2 %
75 cytoplasmSensitivity
= 0.96 // 1) 0.91, 2) 0.92
77 nucleusAreaRatio
= 0.01f // 1.0 %
78 infectionSensitivity
= 0.9 // 1) 0.93, 2) 0.94
80 standardDeviationMaxRatio
= 0.5 // 0.5
81 minimumCellAreaFactor
= 0.4f }
83 type RBCRadius (radius: float32
, parameters
: Parameters) =
84 member this
.Pixel = radius
85 member this
.μm
: float<μm
> =
86 1.<px
> * (float radius) / parameters
.resolution
|> inchToμm
88 member this
.Min = radius + parameters
.minRbcRadius
* radius
89 member this
.Max = radius + parameters
.maxRbcRadius
* radius
91 member this
.Area = PI * radius ** 2.f
92 member this
.MinArea = parameters
.minimumCellAreaFactor
* this
.Area
94 member this
.ParasiteRadius = parameters
.parasiteRadiusRatio
* radius
96 member this
.NucleusArea = parameters
.nucleusAreaRatio
* this
.Area
97 member this
.MinimumParasiteArea = parameters
.minimumParasiteAreaRatio
* this
.Area
99 override this.ToString() =
100 sprintf
"%d px (%.1f μm)" (Utils.roundInt
<| 2.f
* radius) (2. * this.μm
)
102 type Config (param
: Parameters) =
103 let RBCadiusInPixels (rbcDiameter
: float<μm
>) (resolution
: float<ppi
>) : float32
=
104 let rbcRadiusInch: float<inch
> = (μmToInch rbcDiameter
) / 2.
105 let rbcRadiusPx: float<px
> = resolution
* rbcRadiusInch
108 let mutable parameters: Parameters = param
109 let mutable rbcRadiusByResolution = RBCRadius(RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, parameters)
110 let mutable rbcRadius = RBCRadius(0.f
, parameters)
112 new () = Config(defaultParameters)
114 member this.Parameters
115 with get
() = parameters
118 rbcRadiusByResolution <- RBCRadius(RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, param
)
119 rbcRadius <- RBCRadius(rbcRadius.Pixel, param
)
121 member val Debug = DebugOff with get
, set
123 member this.LPFStandardDeviationParasite =
124 let stdDeviation: float<px
> = (μmToInch
parameters.LPFStandardDeviationParasite) * parameters.resolution
127 member this.LPFStandardDeviationStain =
128 let stdDeviation: float<px
> = (μmToInch
parameters.LPFStandardDeviationStain) * 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