e5b853cc488a8fd7d412bbc91df5733eb992e051
1
module ParasitemiaCore.Config
10 | DebugOn of string // Output directory.
14 rbcDiameter
: float<μm
>
15 resolution
: float<ppi
>
17 ratioAreaPaleCenter
: float32
// The area of the second opening is 'ratioSecondAreaOpen' * mean RBC area. It's applied only if greater than 'initialAreaOpen'.
19 granulometryRange
: float32
// The radius will be seeked from radius - granulometryRange * radius to radius + granulometryRange * radius.
21 minRbcRadius
: float32
// Factor of the mean RBC radius.
22 maxRbcRadius
: float32
// Factor of the mean RBC radius.
24 LPFStandardDeviationParasite : float<μm
> // Sigma parameter of the gaussian to remove the high frequency noise.
25 LPFStandardDeviationRBC : float<μm
>
28 nbPickElementsMin
: int
29 factorNbValidPick
: float // The number of computed ellipse per edge pixel.
30 factorNbMaxPick
: float
32 // Parasites detection.
33 darkStainLevel
: float // Lower -> more sensitive. Careful about illumination on the borders.
34 maxDarkStainRatio
: float // When a cell must own less than this ratio to be a RBC.
36 parasiteRadiusRatio
: float32
// The ratio of the parasite radius of the RBC radius.
37 minimumParasiteAreaRatio
: float32
// Factor of a RBC area. 0.5 means the half of RBC area.
39 cytoplasmSizeRatio
: float32
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 // [<Obsolete>] 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 =
52 resolution
= 230.e3
<ppi
> // 230.e3<ppi> Correspond to 50X.
54 ratioAreaPaleCenter
= 2.f
/ 5.f
// The ratio between an RBC area and the area of the its pale center.
56 granulometryRange
= 0.5f
61 LPFStandardDeviationParasite = 0.15<μm
>
62 LPFStandardDeviationRBC = 0.22<μm
>
64 nbPickElementsMin
= 10
65 factorNbValidPick
= 0.06 //1.0
69 maxDarkStainRatio
= 0.1 // 10 %
71 parasiteRadiusRatio
= 0.5f // 50 %
72 minimumParasiteAreaRatio
= 0.02f // 2 %
74 cytoplasmSizeRatio
= 1.f
/ 5.f
75 cytoplasmSensitivity
= 0.96
77 nucleusAreaRatio
= 0.01f // 1.0 %
78 infectionSensitivity
= 0.92
80 // standardDeviationMaxRatio = 0.6 // Obsolete.
81 minimumCellAreaFactor
= 0.4f
84 type RBCRadius (radius : float32
, parameters
: Parameters) =
85 member this
.Pixel = radius
86 member this
.μm
: float<μm
> =
87 1.<px
> * (float radius) / parameters
.resolution
|> inchToμm
89 member this
.Min = radius + parameters
.minRbcRadius
* radius
90 member this
.Max = radius + parameters
.maxRbcRadius
* radius
92 member this
.Area = PI * radius ** 2.f
93 member this
.MinArea = parameters
.minimumCellAreaFactor
* this
.Area
95 member this
.ParasiteRadius = parameters
.parasiteRadiusRatio
* radius
96 member this
.CytoplasmSize = parameters
.cytoplasmSizeRatio
* radius
98 member this
.NucleusArea = parameters
.nucleusAreaRatio
* this
.Area
99 member this
.MinimumParasiteArea = parameters
.minimumParasiteAreaRatio
* this
.Area
101 override this.ToString () =
102 sprintf
"%d px (%.1f μm)" (Utils.roundInt
<| 2.f
* radius) (2. * this.μm
)
104 type Config (param
: Parameters) =
105 let RBCadiusInPixels (rbcDiameter
: float<μm
>) (resolution
: float<ppi
>) : float32
=
106 let rbcRadiusInch : float<inch
> = (μmToInch rbcDiameter
) / 2.
107 let rbcRadiusPx : float<px
> = resolution
* rbcRadiusInch
110 let mutable parameters : Parameters = param
111 let mutable rbcRadiusByResolution = RBCRadius (RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, parameters)
112 let mutable rbcRadius = RBCRadius (0.f
, parameters)
114 new () = Config defaultParameters
116 member this.Parameters
117 with get
() = parameters
120 rbcRadiusByResolution <- RBCRadius (RBCadiusInPixels parameters.rbcDiameter
parameters.resolution
, param)
121 rbcRadius <- RBCRadius (rbcRadius.Pixel, param)
123 member val Debug = DebugOff with get
, set
125 member this.LPFStandardDeviationParasite =
126 let stdDeviation : float<px
> = (μmToInch
parameters.LPFStandardDeviationParasite) * parameters.resolution
129 member this.LPFStandardDeviationRBC =
130 let stdDeviation : float<px
> = (μmToInch
parameters.LPFStandardDeviationRBC) * parameters.resolution
133 member this.RBCRadiusByResolution = rbcRadiusByResolution
134 member this.RBCRadius = rbcRadius
136 member this.SetRBCRadius (radiusPixel
: float32
) =
137 rbcRadius <- RBCRadius (radiusPixel
, parameters)
139 member this.Copy () =
140 this.MemberwiseClone () :?> Config
142 override this.ToString () =
143 $
"{{{nameof Config}: " +
144 $
"{nameof this.LPFStandardDeviationParasite} = {this.LPFStandardDeviationParasite}, " +
145 $
"{nameof this.LPFStandardDeviationRBC} = {this.LPFStandardDeviationRBC}, " +
146 $
"{nameof this.RBCRadiusByResolution} = {this.RBCRadiusByResolution}, " +
147 $
"{nameof this.RBCRadius} = {this.RBCRadius}, " +
148 $
"{nameof this.Parameters} = {this.Parameters}}}"