X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FGUI%2FState.fs;h=45272cab7de11b7bb1525ee28959e49cfc1986a1;hp=44ca21b81a0daab734c861b16c4c1568a36d4418;hb=05be8164d308447b916544ae3ce4211500dfd8da;hpb=807437584bdd3d7b7b33be8282472f81f8cce606 diff --git a/Parasitemia/Parasitemia/GUI/State.fs b/Parasitemia/Parasitemia/GUI/State.fs index 44ca21b..45272ca 100644 --- a/Parasitemia/Parasitemia/GUI/State.fs +++ b/Parasitemia/Parasitemia/GUI/State.fs @@ -45,7 +45,7 @@ type State () = rbc.setManually <- not rbc.setManually member this.Save () = - let data = { PiaZ.sources = List.ofSeq sourceImages; PiaZ.patientID = this.PatientID } + let data = { PiaZ.FileData.patientID = this.PatientID; PiaZ.FileData.images = List.ofSeq sourceImages } PiaZ.save this.FilePath data alteredSinceLastSave <- false @@ -53,13 +53,13 @@ type State () = let data = PiaZ.load this.FilePath this.PatientID <- data.patientID sourceImages.Clear() - sourceImages.InsertRange(0, data.sources) + sourceImages.InsertRange(0, data.images) if sourceImages.Count > 0 then this.CurrentImage <- Some sourceImages.[0] alteredSinceLastSave <- false - member this.AddSourceImage (filePath: string) : SourceImage = - let srcImg = { num = sourceImages.Count + 1; rbcRadius = 0.; dateLastAnalysis = DateTime(0L); rbcs = []; img = new Image(filePath) } + member this.AddSourceImage (filePath: string) (defaultConfig: Config.Config) : SourceImage = + let srcImg = { num = sourceImages.Count + 1; config = defaultConfig.Copy(); dateLastAnalysis = DateTime(0L); rbcs = []; img = new Image(filePath) } sourceImages.Add(srcImg) if sourceImages.Count = 1 then this.CurrentImage <- Some sourceImages.[0] @@ -81,18 +81,17 @@ type State () = // Re-numbered the images. sourceImages |> Seq.iteri (fun i srcImg -> srcImg.num <- i + 1) - member this.SetResult (imgNum: int) (rbcRadius: float) (cells: Cell list) = + member this.SetResult (imgNum: int) (cells: Cell list) = let sourceImage = sourceImages.Find(fun srcImg -> srcImg.num = imgNum) let w = sourceImage.img.Width let h = sourceImage.img.Height - sourceImage.rbcRadius <- rbcRadius sourceImage.dateLastAnalysis <- DateTime.UtcNow // To match with previously manually altered RBC. let manuallyAlteredPreviousRBCS = sourceImage.rbcs |> List.filter (fun rbc -> rbc.setManually) - let tolerance = rbcRadius * 0.5 // +/-. + let tolerance = (float sourceImage.config.RBCRadius.Pixel) * 0.5 // +/-. let getPreviousRBC (center: Point) : RBC option = manuallyAlteredPreviousRBCS |> List.tryFind (fun rbc -> rbc.center.X > center.X - tolerance && rbc.center.X < center.X + tolerance && rbc.center.Y > center.Y - tolerance && rbc.center.Y < center.Y + tolerance)