// ParasitemIA Zipped file format.
module Parasitemia.GUI.PiaZ
+open System
open System.Windows
open System.IO
open System.IO.Compression
// The json type associated to a source image.
type JSONSourceImage = JsonProvider<"""
{
+ "RBCRadius" : 32.5,
+ "dateLastAnalysis" : 1.5,
"rbcs": [
{
"num": 1,
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,
- rbc.stainArea) |])
+ rbc.infectedArea) |])
let imgJSONEntry = file.CreateEntry(imgFilename + ".json", CompressionLevel.Fastest)
use imgJSONFileWriter = new StreamWriter(imgJSONEntry.Open())
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);
- stainArea = 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