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 stainArea
: float32
// Factor of a RBC area. 0.5 means the half of RBC area.
38 stainSensitivity
: float // between 0 (the least sensitive) and 1 (the most sensitive).
39 maxStainRatio
: float // A cell must own less than this ratio to be a RBC.
41 infectionArea
: float32
// Factor of a RBC area. 0.5 means the half of RBC area.
42 infectionSensitivity
: float // between 0 (the least sensitive) and 1 (the most sensitive).
44 standardDeviationMaxRatio
: float // The standard deviation of the pixel values of a cell can't be greater than standardDeviationMaxRatio * global standard deviation
45 minimumCellAreaFactor
: float32
// Factor of the mean RBC area. A cell with an area below this will be rejected.
48 let defaultParameters = {
50 resolution
= 220.e3
<ppi
> // 220.e3<ppi> Correspond to 50X.
52 colorContribution_BG_RBC
= 0.16, 0.44, 0.4
53 colorContribution_RBC_parasite
= 0.54, 0.41, 0.05
55 ratioAreaPaleCenter
= 2.f
/ 5.f
// The ratio between an RBC area and the area of the its pale center.
57 granulometryRange
= 0.5f
62 LPFStandardDeviationParasite = 0.15<μm
>
63 LPFStandardDeviationStain = 0.15<μm
> // 0.12
64 LPFStandardDeviationRBC = 0.2<μm
> // 8.5e-6<inch>. // 0.2<μm>
68 darkStainLevel
= 0.25 // 0.3
69 maxDarkStainRatio
= 0.1 // 10 %
71 infectionArea
= 0.01f // 0.8 % // 0.012f
72 infectionSensitivity
= 0.9 // 1) 0.93, 2) 0.94
74 stainArea
= 0.08f // 6 % // 0.08f
75 stainSensitivity
= 0.96 // 1) 0.91, 2) 0.92
76 maxStainRatio
= 0.12 // 12 %
78 standardDeviationMaxRatio
= 0.5 // 0.5
79 minimumCellAreaFactor
= 0.4f }
81 type RBCRadius (radius: float32
, parameters
: Parameters) =
82 member this
.Pixel = radius
83 member this
.μm
: float<μm
> =
84 1.<px
> * (float radius) / parameters
.resolution
|> inchToμm
86 member this
.Min = radius + parameters
.minRbcRadius
* radius
87 member this
.Max = radius + parameters
.maxRbcRadius
* radius
89 member this
.Area = PI * radius ** 2.f
90 member this
.MinArea = parameters
.minimumCellAreaFactor
* this
.Area
92 member this
.InfectionArea = parameters
.infectionArea
* this
.Area
93 member this
.StainArea = parameters
.stainArea
* this
.Area
95 override this.ToString() =
96 sprintf
"%d px (%.1f μm)" (Utils.roundInt
<| 2.f
* radius) (2. * this.μm
)
98 type Config (param
: Parameters) =
99 let RBCadiusInPixels (rbcDiameter
: float<μm
>) (resolution
: float<ppi
>) : float32
=
100 let rbcRadiusInch: float<inch
> = (μmToInch rbcDiameter
) / 2.
101 let rbcRadiusPx: float<px
> = resolution
* rbcRadiusInch
104 let mutable parameters: Parameters = param
105 let mutable rbcRadiusByResolution = RBCRadius(RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, parameters)
106 let mutable rbcRadius = RBCRadius(0.f
, parameters)
108 new () = Config(defaultParameters)
110 member this.Parameters
111 with get
() = parameters
114 rbcRadiusByResolution <- RBCRadius(RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, param
)
115 rbcRadius <- RBCRadius(rbcRadius.Pixel, param
)
117 member val Debug = DebugOff with get
, set
119 member this.LPFStandardDeviationParasite =
120 let stdDeviation: float<px
> = (μmToInch
parameters.LPFStandardDeviationParasite) * parameters.resolution
123 member this.LPFStandardDeviationStain =
124 let stdDeviation: float<px
> = (μmToInch
parameters.LPFStandardDeviationStain) * parameters.resolution
127 member this.LPFStandardDeviationRBC =
128 let stdDeviation: float<px
> = (μmToInch
parameters.LPFStandardDeviationRBC) * parameters.resolution
131 member this.RBCRadiusByResolution = rbcRadiusByResolution
132 member this.RBCRadius = rbcRadius
134 member this.SetRBCRadius (radiusPixel
: float32
) =
135 rbcRadius <- RBCRadius(radiusPixel
, parameters)
137 member this.Copy () =
138 this.MemberwiseClone() :?> Config