X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;ds=inline;f=Parasitemia%2FParasitemiaUI%2FPiaZ.fs;h=bb553b8442cc015198a567474913016e47f76b07;hb=154264f33619b78e17182082b483cba97e128698;hp=c9dfd5b8247d4022dfd1dcd810c38d1516654dec;hpb=cb90b01c85183b2c75ee6d22b378b3ca99df6bf3;p=master-thesis.git
diff --git a/Parasitemia/ParasitemiaUI/PiaZ.fs b/Parasitemia/ParasitemiaUI/PiaZ.fs
index c9dfd5b..bb553b8 100644
--- a/Parasitemia/ParasitemiaUI/PiaZ.fs
+++ b/Parasitemia/ParasitemiaUI/PiaZ.fs
@@ -20,29 +20,28 @@ let filter = "PIA|*.piaz"
// Information associated to a document.
type JSONInformation = {
patientID: string
- fileVersion: int
-}
+ fileVersion: int }
// Information associated to each images.
type JSONSourceImage = {
num: int
+ name: string
+
RBCRadius: float32 // The RBC Radius found by granulometry.
parameters: ParasitemiaCore.Config.Parameters
dateLastAnalysis: DateTime
rbcs: RBC List
healthyRBCBrightness: float32 // 0 to 1.
- infectedRBCBrightness: float32 // 0 to 1.
-}
+ infectedRBCBrightness: float32 } // 0 to 1.
type DocumentData = {
patientID: string
- images: SourceImage list
-}
+ images: SourceImage list }
let mainEntryName = "info.json"
let imageExtension = ".tiff"
-let currentFileVersion = 1
+let currentFileVersion = 2
///
/// Save a document in a give file path. The file may already exist.
@@ -72,6 +71,7 @@ let save (filePath: string) (data: DocumentData) =
imgJSONFileWriter.Write(
JsonConvert.SerializeObject(
{ num = srcImg.num
+ name = srcImg.name
RBCRadius = srcImg.config.RBCRadius.Pixel
parameters = srcImg.config.Parameters
dateLastAnalysis = srcImg.dateLastAnalysis
@@ -92,7 +92,7 @@ let updateDocumentData (fromVersion: int) (toVersion: int) (data: DocumentData)
///
///
/// If the file cannot be read
-let load (filePath: string) : DocumentData =
+let load (filePath: string) (defaultConfig: ParasitemiaCore.Config.Config) : DocumentData =
use file = ZipFile.Open(filePath, ZipArchiveMode.Read)
let mainEntry = file.GetEntry(mainEntryName)
@@ -108,12 +108,18 @@ let load (filePath: string) : DocumentData =
use bitmap = new System.Drawing.Bitmap(imgEntry.Open(), false)
let img = new Image(bitmap)
imgNum <- imgNum + 1
- let imgEntry = file.GetEntry(imgEntry.Name + ".json")
- use imgEntryFileReader = new StreamReader(imgEntry.Open())
- let imgInfo = JsonConvert.DeserializeObject(imgEntryFileReader.ReadToEnd())
- let config = ParasitemiaCore.Config.Config(imgInfo.parameters)
+ let imgJSONEntry = file.GetEntry(imgEntry.Name + ".json")
+ use imgJSONFileReader = new StreamReader(imgJSONEntry.Open())
+ let imgInfo = JsonConvert.DeserializeObject(imgJSONFileReader.ReadToEnd())
+
+ let config = defaultConfig.Copy()
+ config.Parameters <-
+ { ParasitemiaCore.Config.defaultParameters with
+ resolution = imgInfo.parameters.resolution }
+
config.SetRBCRadius imgInfo.RBCRadius
yield { num = imgNum
+ name = imgInfo.name
config = config
dateLastAnalysis = imgInfo.dateLastAnalysis
img = img