-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_fs_mgh_test.go
124 lines (90 loc) · 2.72 KB
/
read_fs_mgh_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package neuro
// https://pkg.go.dev/testing
import (
"testing"
)
func TestReadFsMghHeader(t *testing.T) {
var mghFile string = "testdata/brain.mgh"
hdr, _ := ReadFsMghHeader(mghFile, "auto")
got := hdr.MghDataType
want, _ := getMghDataTypeCode("MRI_UCHAR")
if got != want {
t.Errorf("got MGH data type %d, wanted %d", got, want)
}
}
func TestReadFsMghHeaderRAS(t *testing.T) {
var mghFile string = "testdata/brain.mgh"
hdr, _ := ReadFsMghHeader(mghFile, "no")
got := hdr.RasGoodFlag
var want int16 = 1
if got != want {
t.Errorf("got MGH RasGoodFlag=%d, wanted %d", got, want)
}
}
func TestReadFsMghFull(t *testing.T) {
var mghFile string = "testdata/brain.mgh"
mgh, _ := ReadFsMgh(mghFile, "mgh")
got := mgh.Header.RasGoodFlag
var want int16 = 1
if got != want {
t.Errorf("got MGH RasGoodFlag=%d, wanted %d", got, want)
}
}
func TestReadFsMghFullAt0000(t *testing.T) {
var mghFile string = "testdata/brain.mgh"
mgh, _ := ReadFsMgh(mghFile, "no")
got := mgh.Data.DataMriUchar[0]
var want uint8 = 0
if got != want {
t.Errorf("got data value=%d, wanted %d", got, want)
}
}
func TestReadFsMghFullSum(t *testing.T) {
var mghFile string = "testdata/brain.mgh"
mgh, _ := ReadFsMgh(mghFile, "no")
var sum int = 0
for _, voxel_val := range mgh.Data.DataMriUchar {
sum += int(voxel_val)
}
var got = sum
var want int = 121035479 // known from external tests with standard software.
if got != want {
t.Errorf("got MGH data sum=%d, wanted %d", got, want)
}
}
func TestReadFsMgzFullSum(t *testing.T) {
var mgzFile string = "testdata/brain.mgz"
mgh, _ := ReadFsMgh(mgzFile, "yes")
var sum int = 0
for _, voxel_val := range mgh.Data.DataMriUchar {
sum += int(voxel_val)
}
var got = sum
var want int = 121035479 // known from external tests with standard software.
if got != want {
t.Errorf("got MGH data sum=%d, wanted %d", got, want)
}
}
func TestReadFsMgzFullSumisGzippedMgz(t *testing.T) {
var mgzFile string = "testdata/brain.mgz"
mgh, _ := ReadFsMgh(mgzFile, "mgz") // Use 'mgz' for isGzipped
var sum int = 0
for _, voxel_val := range mgh.Data.DataMriUchar {
sum += int(voxel_val)
}
var got = sum
var want int = 121035479 // known from external tests with standard software.
if got != want {
t.Errorf("got MGH data sum=%d, wanted %d", got, want)
}
}
func TestReadFsMghPervertex(t *testing.T) {
var mgzFile string = "testdata/lh.thickness.fwhm5.fsaverage.mgh"
mgh, _ := ReadFsMgh(mgzFile, "auto")
mean_thickness, _ := mean(mgh.Data.DataMriFloat)
lower_border := 2.31
upper_border := 2.33
if mean_thickness < float32(lower_border) || mean_thickness > float32(upper_border) {
t.Errorf("got mean thickness=%f, wanted between %f and %f", mean_thickness, lower_border, upper_border)
}
}