432bad9141dff61e97a73a8322a1e0d521b0b4fa
1
// ParasitemIA file format.
2 module Parasitemia.GUI.Pia
6 open System.IO.Compression
11 open Emgu.CV.Structure
15 let extension = ".pia"
16 let filter = "PIA|*.pia"
19 sources
: SourceImage list
22 // The json type associated to a source image.
23 type JSONSourceImage = JsonProvider<"""
29 "addedManually
": false,
41 // The json type associated to a file.
42 type JSONMainInformation = JsonProvider<"""
44 "patientID
": "1234abcd"
48 let mainFilename = "info.json"
50 let save (filePath
: string) (data
: FileData) =
51 use file = ZipFile.Open(filePath
, ZipArchiveMode.Update)
53 let mainJSON = JSONMainInformation.Root(data
.patientID
)
56 match file.GetEntry(mainFilename) with
57 | null -> file.CreateEntry(mainFilename)
60 use mainFileWriter = new StreamWriter(mainFile.Open())
61 mainJSON.JsonValue.WriteTo(mainFileWriter, JsonSaveOptions.None)
64 let load (filePath
: string) : FileData =
65 use file = ZipFile.Open(filePath
, ZipArchiveMode.Read)
67 let mainFile = file.GetEntry(mainFilename)
68 let mainJSON = JSONMainInformation.Load(mainFile.Open())
70 { sources
= []; patientID
= mainJSON.PatientId }