forked from InsightSoftwareConsortium/ITK-Wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GETest.js
96 lines (92 loc) · 4.89 KB
/
GETest.js
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
const test = require('ava')
const path = require('path')
const IntTypes = require(path.resolve(__dirname, '..', 'dist', 'IntTypes.js'))
const PixelTypes = require(path.resolve(__dirname, '..', 'dist', 'PixelTypes.js'))
const readImageLocalFile = require(path.resolve(__dirname, '..', 'dist', 'readImageLocalFile.js'))
test('Test reading a GE4 file', t => {
const testFilePath = path.resolve(__dirname, '..', 'build', 'ExternalData', 'test', 'Input', '19771.002.001')
return readImageLocalFile(testFilePath).then(function (image) {
t.is(image.imageType.dimension, 3, 'dimension')
t.is(image.imageType.componentType, IntTypes.Int16, 'componentType')
t.is(image.imageType.pixelType, PixelTypes.Scalar, 'pixelType')
t.is(image.imageType.components, 1, 'components')
t.is(image.origin[0], 0.0, 'origin[0]')
t.is(image.origin[1], 0.0, 'origin[1]')
t.is(image.origin[2], 0.0, 'origin[2]')
t.is(image.spacing[0], 1.015625, 'spacing[0]')
t.is(image.spacing[1], 1.015625, 'spacing[1]')
t.is(image.spacing[2], 1.5, 'spacing[2]')
t.is(image.direction.getElement(0, 0), 1.0, 'direction (0, 0)')
t.is(image.direction.getElement(0, 1), 0.0, 'direction (0, 1)')
t.is(image.direction.getElement(0, 2), 0.0, 'direction (0, 2)')
t.is(image.direction.getElement(1, 0), 0.0, 'direction (1, 0)')
t.is(image.direction.getElement(1, 1), 0.0, 'direction (1, 1)')
t.is(image.direction.getElement(1, 2), -1.0, 'direction (1, 2)')
t.is(image.direction.getElement(2, 0), 0.0, 'direction (2, 0)')
t.is(image.direction.getElement(2, 1), -1.0, 'direction (2, 1)')
t.is(image.direction.getElement(2, 2), 0.0, 'direction (2, 2)')
t.is(image.size[0], 4, 'size[0]')
t.is(image.size[1], 4, 'size[1]')
t.is(image.size[2], 1, 'size[2]')
t.is(image.data.length, 16, 'data.length')
t.is(image.data[10], 80, 'data[10]')
})
})
test('Test reading a GE5 file', t => {
const testFilePath = path.resolve(__dirname, '..', 'build', 'ExternalData', 'test', 'Input', '113766.003.001')
return readImageLocalFile(testFilePath).then(function (image) {
t.is(image.imageType.dimension, 3, 'dimension')
t.is(image.imageType.componentType, IntTypes.Int16, 'componentType')
t.is(image.imageType.pixelType, PixelTypes.Scalar, 'pixelType')
t.is(image.imageType.components, 1, 'components')
t.is(image.origin[0], -125, 'origin[0]')
t.is(image.origin[1], 105, 'origin[1]')
t.is(image.origin[2], 144, 'origin[2]')
t.is(image.spacing[0], 1.015625, 'spacing[0]')
t.is(image.spacing[1], 1.015625, 'spacing[1]')
t.is(image.spacing[2], 3, 'spacing[2]')
t.is(image.direction.getElement(0, 0), 1.0, 'direction (0, 0)')
t.is(image.direction.getElement(0, 1), -0.0, 'direction (0, 1)')
t.is(image.direction.getElement(0, 2), 0.0, 'direction (0, 2)')
t.is(image.direction.getElement(1, 0), -0.0, 'direction (1, 0)')
t.is(image.direction.getElement(1, 1), -0.0, 'direction (1, 1)')
t.is(image.direction.getElement(1, 2), 1.0, 'direction (1, 2)')
t.is(image.direction.getElement(2, 0), 0.0, 'direction (2, 0)')
t.is(image.direction.getElement(2, 1), -1.0, 'direction (2, 1)')
t.is(image.direction.getElement(2, 2), -0.0, 'direction (2, 2)')
t.is(image.size[0], 4, 'size[0]')
t.is(image.size[1], 4, 'size[1]')
t.is(image.size[2], 1, 'size[2]')
t.is(image.data.length, 16, 'data.length')
t.is(image.data[10], 80, 'data[10]')
})
})
test('Test reading a GEAdw file', t => {
const testFilePath = path.resolve(__dirname, '..', 'build', 'ExternalData', 'test', 'Input', 'I.001')
return readImageLocalFile(testFilePath).then(function (image) {
t.is(image.imageType.dimension, 3, 'dimension')
t.is(image.imageType.componentType, IntTypes.Int16, 'componentType')
t.is(image.imageType.pixelType, PixelTypes.Scalar, 'pixelType')
t.is(image.imageType.components, 1, 'components')
t.is(image.origin[0], 0, 'origin[0]')
t.is(image.origin[1], 0, 'origin[1]')
t.is(image.origin[2], 0, 'origin[2]')
t.is(image.spacing[0], 0.625, 'spacing[0]')
t.is(image.spacing[1], 0.625, 'spacing[1]')
t.is(image.spacing[2], 1.5, 'spacing[2]')
t.is(image.direction.getElement(0, 0), 1.0, 'direction (0, 0)')
t.is(image.direction.getElement(0, 1), 0.0, 'direction (0, 1)')
t.is(image.direction.getElement(0, 2), 0.0, 'direction (0, 2)')
t.is(image.direction.getElement(1, 0), 0.0, 'direction (1, 0)')
t.is(image.direction.getElement(1, 1), 0.0, 'direction (1, 1)')
t.is(image.direction.getElement(1, 2), -1.0, 'direction (1, 2)')
t.is(image.direction.getElement(2, 0), 0.0, 'direction (2, 0)')
t.is(image.direction.getElement(2, 1), -1.0, 'direction (2, 1)')
t.is(image.direction.getElement(2, 2), 0.0, 'direction (2, 2)')
t.is(image.size[0], 4, 'size[0]')
t.is(image.size[1], 4, 'size[1]')
t.is(image.size[2], 1, 'size[2]')
t.is(image.data.length, 16, 'data.length')
t.is(image.data[10], 80, 'data[10]')
})
})