forked from InsightSoftwareConsortium/ITK-Wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MINCTest.js
36 lines (34 loc) · 2.05 KB
/
MINCTest.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
import test from 'ava'
import path from 'path'
const FloatTypes = require(path.resolve(__dirname, '..', 'dist', 'FloatTypes.js'))
const PixelTypes = require(path.resolve(__dirname, '..', 'dist', 'PixelTypes.js'))
const readImageLocalFile = require(path.resolve(__dirname, '..', 'dist', 'readImageLocalFile.js'))
test('Test reading a MINC file', t => {
const testFilePath = path.resolve(__dirname, '..', 'build', 'ExternalData', 'test', 'Input', 't1_z+_short_cor.mnc')
return readImageLocalFile(testFilePath).then(function (image) {
t.is(image.imageType.dimension, 3, 'dimension')
t.is(image.imageType.componentType, FloatTypes.Float32, 'componentType')
t.is(image.imageType.pixelType, PixelTypes.Scalar, 'pixelType')
t.is(image.imageType.components, 1, 'components')
t.is(image.origin[0], -21.425182690867963, 'origin[0]')
t.is(image.origin[1], 59.12510556251424, 'origin[1]')
t.is(image.origin[2], -8.31768365930949, 'origin[2]')
t.is(image.spacing[0], 1.0, 'spacing[0]')
t.is(image.spacing[1], 1.0, 'spacing[1]')
t.is(image.spacing[2], 1.2, 'spacing[2]')
t.is(image.direction.getElement(0, 0), 0.9980212170406957, 'direction (0, 0)')
t.is(image.direction.getElement(0, 1), -0.05172001539071517, 'direction (0, 1)')
t.is(image.direction.getElement(0, 2), 0.03575998606925314, 'direction (0, 2)')
t.is(image.direction.getElement(1, 0), 0.0523040113746069, 'direction (1, 0)')
t.is(image.direction.getElement(1, 1), 0.9985092971339445, 'direction (1, 1)')
t.is(image.direction.getElement(1, 2), -0.015601993922049426, 'direction (1, 2)')
t.is(image.direction.getElement(2, 0), -0.034899007589522905, 'direction (2, 0)')
t.is(image.direction.getElement(2, 1), 0.01744200519034907, 'direction (2, 1)')
t.is(image.direction.getElement(2, 2), 0.9992386107341845, 'direction (2, 2)')
t.is(image.size[0], 30, 'size[0]')
t.is(image.size[1], 40, 'size[1]')
t.is(image.size[2], 10, 'size[2]')
t.is(image.data.length, 12000, 'data.length')
t.is(image.data[1000], 7.437521934509277, 'data[1000]')
})
})