adecd6c76567ca1c718c9117c4beb2992a52f73c
[master-thesis.git] / Parasitemia / ParasitemiaUI / Export.fs
1 module ParasitemiaUI.Export
2
3 open System
4 open System.IO
5
6 open State
7
8 /// <exception cref="System.IOException">If the results cannot be exported</exception>
9 let exportResults (state: State) (filePath: string) =
10 use writer = new StreamWriter(new FileStream(filePath, FileMode.Create, FileAccess.Write))
11 fprintfn writer "File: %s" state.FilePath
12 fprintfn writer "Export date: %A" DateTime.Now
13
14 fprintfn writer ""
15 fprintfn writer "Patient ID: %s" state.PatientID
16 fprintfn writer "Global parasitemia: %s" (Utils.percentText state.GlobalParasitemia)
17
18 for srcImg in state.SourceImages do
19 fprintfn writer ""
20 fprintfn writer "Image name: %s" srcImg.name
21 fprintfn writer "Parasitemia: %s" (Utils.percentText (state.ImageParasitemia srcImg))
22 fprintfn writer "Added infected erythrocyte: %s %s" (state.ImageNbManuallyChangedRBCStr srcImg true) (state.ImageManuallyChangedRBCStr srcImg true)
23 fprintfn writer "Removed infected erythrocyte: %s %s" (state.ImageNbManuallyChangedRBCStr srcImg false) (state.ImageManuallyChangedRBCStr srcImg false)
24 ()