* Add the analysis window.
[master-thesis.git] / Parasitemia / Parasitemia / GUI / PiaZ.fs
index a373e53..e330a2d 100644 (file)
@@ -1,6 +1,7 @@
 // ParasitemIA Zipped file format.
 module Parasitemia.GUI.PiaZ
 
+open System
 open System.Windows
 open System.IO
 open System.IO.Compression
@@ -22,6 +23,8 @@ type FileData = {
 // The json type associated to a source image.
 type JSONSourceImage = JsonProvider<"""
     {
+        "RBCRadius" : 32.5,
+        "dateLastAnalysis" : 1.5,
         "rbcs": [
             {
                 "num": 1,
@@ -66,8 +69,10 @@ let save (filePath: string) (data: FileData) =
         imgSrc.img.ToBitmap().Save(imgEntry.Open(), System.Drawing.Imaging.ImageFormat.Tiff)
 
         let imgJSON =
-            JSONSourceImage.Root([| for rbc in imgSrc.rbcs ->
-                                        JSONSourceImage.Rbc(
+            JSONSourceImage.Root(decimal imgSrc.rbcRadius,
+                                 decimal <| imgSrc.dateLastAnalysis.ToFileTimeUtc(),
+                                 [| for rbc in imgSrc.rbcs ->
+                                       JSONSourceImage.Rbc(
                                             rbc.num,
                                             rbc.infected, rbc.setManually,
                                             decimal rbc.center.X, decimal rbc.center.Y, decimal rbc.size.Width, decimal rbc.size.Height,
@@ -94,9 +99,13 @@ let load (filePath: string) : FileData =
                 imgNum <- imgNum + 1
                 let imgJSONEntry = file.GetEntry(filename + ".json")
                 let imgJSON = JSONSourceImage.Load(imgJSONEntry.Open())
-                yield { num = imgNum; img = img; rbcs = [ for rbc in imgJSON.Rbcs ->
-                                                            { num = rbc.Num;
-                                                              infected = rbc.Infected; setManually = rbc.SetManually;
-                                                              center = Point(float rbc.PosX, float rbc.PosY); size = Size(float rbc.Width, float rbc.Height);
-                                                              infectedArea = rbc.StainArea } ] } ]
+                yield { num = imgNum
+                        rbcRadius = float imgJSON.RbcRadius
+                        dateLastAnalysis = DateTime.FromFileTimeUtc(int64 imgJSON.DateLastAnalysis)
+                        img = img
+                        rbcs = [ for rbc in imgJSON.Rbcs ->
+                                    { num = rbc.Num;
+                                      infected = rbc.Infected; setManually = rbc.SetManually;
+                                      center = Point(float rbc.PosX, float rbc.PosY); size = Size(float rbc.Width, float rbc.Height);
+                                      infectedArea = rbc.StainArea } ] } ]
     { sources = sources; patientID = mainJSON.PatientId }
\ No newline at end of file