X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;ds=sidebyside;f=Parasitemia%2FParasitemiaUI%2FState.fs;fp=Parasitemia%2FParasitemiaUI%2FState.fs;h=129e6a6bae522b0e7d3af94893b9669ea8364254;hb=d3f9cd7b16d25f49bd8d06394b0f1d4040809fbd;hp=3355a429b849cdd38a97f721cfa008f9e1842a2d;hpb=a6aee26e20f3b24e6b07120cf95a7221dc072778;p=master-thesis.git
diff --git a/Parasitemia/ParasitemiaUI/State.fs b/Parasitemia/ParasitemiaUI/State.fs
index 3355a42..129e6a6 100644
--- a/Parasitemia/ParasitemiaUI/State.fs
+++ b/Parasitemia/ParasitemiaUI/State.fs
@@ -25,36 +25,11 @@ type State (defaultConfig : ParasitemiaCore.Config.Config) =
alteredSinceLastSave <- true
patientID <- id
- member this.ImageParasitemia (srcImg : SourceImage) : int * int =
- List.length srcImg.rbcs,
- srcImg.rbcs |> List.fold (fun nbInfected rbc -> if rbc.infected then nbInfected + 1 else nbInfected) 0
-
- member this.ImageNbManuallyChangedRBC (srcImg : SourceImage) (setAsInfected : bool) : int * int =
- List.length srcImg.rbcs,
- srcImg.rbcs |> List.fold (fun nb rbc -> if rbc.setManually && rbc.infected = setAsInfected then nb + 1 else nb) 0
-
- member this.ImageNbManuallyChangedRBCStr (srcImg : SourceImage) (setAsInfected : bool) : string =
- Utils.percentText (this.ImageNbManuallyChangedRBC srcImg setAsInfected)
-
- member this.ImageManuallyChangedRBC (srcImg : SourceImage) (setAsInfected : bool) : int seq =
- query {
- for rbc in srcImg.rbcs do
- where (rbc.setManually && rbc.infected = setAsInfected)
- select rbc.num
- }
-
- member this.ImageManuallyChangedRBCStr (srcImg : SourceImage) (setAsInfected : bool) : string =
- let listStr = Utils.listAsStr <| this.ImageManuallyChangedRBC srcImg setAsInfected
- if listStr = "" then
- ""
- else
- "[" + listStr + "]"
-
member this.GlobalParasitemia : int * int =
sourceImages
|> Seq.fold (
fun (nbTotal, nbTotalInfected) srcImg ->
- let nb, nbInfected = this.ImageParasitemia srcImg
+ let nb, nbInfected = srcImg.ImageParasitemia
nbTotal + nb, nbTotalInfected + nbInfected
) (0, 0)
@@ -89,18 +64,7 @@ type State (defaultConfig : ParasitemiaCore.Config.Config) =
///
/// If the image cannot be read
member this.AddSourceImage (filePath : string) (defaultConfig : ParasitemiaCore.Config.Config) : SourceImage =
- let srcImg =
- {
- num = sourceImages.Count + 1
- name = System.IO.FileInfo(filePath).Name
- config = defaultConfig.Copy ()
- dateLastAnalysis = DateTime (0L)
- rbcs = []
- img = new Image (filePath)
- healthyRBCBrightness = 1.f
- infectedRBCBrightness = 1.f
- }
-
+ let srcImg = SourceImage (sourceImages.Count + 1, System.IO.FileInfo(filePath).Name, defaultConfig.Copy (), DateTime (0L), new Image (filePath), [])
sourceImages.Add srcImg
if sourceImages.Count = 1 then
this.CurrentImage <- Some sourceImages.[0]
@@ -118,24 +82,24 @@ type State (defaultConfig : ParasitemiaCore.Config.Config) =
if isCurrent then
this.CurrentImage <- if sourceImages.Count > 0 then Some sourceImages.[0] else None
// Re-numbered the images.
- sourceImages |> Seq.iteri (fun i srcImg -> srcImg.num <- i + 1)
+ sourceImages |> Seq.iteri (fun i srcImg -> srcImg.Num <- i + 1)
member this.SetName (srcImg : SourceImage) (name : string) =
- if name <> srcImg.name then
- srcImg.name <- name
+ if name <> srcImg.Name then
+ srcImg.Name <- name
alteredSinceLastSave <- true
- member this.SetResult (imgNum : int) (cells : ParasitemiaCore.Types.Cell list) =
- let sourceImage = sourceImages.Find (fun srcImg -> srcImg.num = imgNum)
+ member this.SetResult (imgNum : int) (result : ParasitemiaCore.Types.AnalysisResult) =
+ let sourceImage = sourceImages.Find (fun srcImg -> srcImg.Num = imgNum)
- let w = sourceImage.img.Width
- let h = sourceImage.img.Height
+ let w = sourceImage.Img.Width
+ let h = sourceImage.Img.Height
- sourceImage.dateLastAnalysis <- DateTime.UtcNow
+ sourceImage.DateLastAnalysis <- DateTime.UtcNow
// To match with previously manually altered RBC.
- let manuallyAlteredPreviousRBCS = sourceImage.rbcs |> List.filter (fun rbc -> rbc.setManually)
- let tolerance = (float sourceImage.config.RBCRadius.Pixel) * 0.5 // +/-.
+ let manuallyAlteredPreviousRBCS = sourceImage.RBCs |> List.filter (fun rbc -> rbc.setManually)
+ let tolerance = (float sourceImage.Config.RBCRadius.Pixel) * 0.5 // +/-.
let getPreviousManuallyAlteredRBC (center : Point) : RBC option =
manuallyAlteredPreviousRBCS
|> List.tryFind (
@@ -146,8 +110,8 @@ type State (defaultConfig : ParasitemiaCore.Config.Config) =
rbc.center.Y < center.Y + tolerance
)
- sourceImage.rbcs <-
- cells
+ sourceImage.RBCs <-
+ result.Cells
|> List.filter (fun cell -> match cell.cellClass with ParasitemiaCore.Types.HealthyRBC | ParasitemiaCore.Types.InfectedRBC -> true | _ -> false )
|> List.sortByDescending (fun cell -> cell.nucleusArea, (w - cell.center.X) + (h - cell.center.Y))
|> List.mapi (