Skip to content

Commit b32cc5f

Browse files
committed
dft tests and test data
1 parent 13ee49e commit b32cc5f

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

nibabel/dft/test_data/0.dcm

221 KB
Binary file not shown.

nibabel/dft/test_data/1.dcm

221 KB
Binary file not shown.

nibabel/tests/test_dft.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
""" Testing dft
2+
"""
3+
4+
import StringIO
5+
import PIL.Image
6+
from nose.tools import assert_true, assert_false, assert_equal, assert_raises
7+
from .. import dft
8+
from .. import nifti1
9+
10+
data_dir = 'dft_test_data/td'
11+
12+
def test_init():
13+
dft.clear_cache()
14+
dft.update_cache(data_dir)
15+
return
16+
17+
def test_study():
18+
studies = dft.get_studies(data_dir)
19+
assert_equal(len(studies), 1)
20+
assert_equal(studies[0].uid,
21+
'1.3.12.2.1107.5.2.32.35119.30000010011408520750000000022')
22+
assert_equal(studies[0].date, '20100114')
23+
assert_equal(studies[0].time, '121314.000000')
24+
assert_equal(studies[0].comments, 'dft study comments')
25+
assert_equal(studies[0].patient_name, 'dft patient name')
26+
assert_equal(studies[0].patient_id, '1234')
27+
assert_equal(studies[0].patient_birth_date, '19800102')
28+
assert_equal(studies[0].patient_sex, 'F')
29+
30+
31+
def test_series():
32+
studies = dft.get_studies(data_dir)
33+
assert_equal(len(studies[0].series), 1)
34+
ser = studies[0].series[0]
35+
assert_equal(ser.uid,
36+
'1.3.12.2.1107.5.2.32.35119.2010011420292594820699190.0.0.0')
37+
assert_equal(ser.number, '12')
38+
assert_equal(ser.description, 'CBU_DTI_64D_1A')
39+
assert_equal(ser.rows, 256)
40+
assert_equal(ser.columns, 256)
41+
assert_equal(ser.bits_allocated, 16)
42+
assert_equal(ser.bits_stored, 12)
43+
44+
def test_storage_instances():
45+
studies = dft.get_studies(data_dir)
46+
sis = studies[0].series[0].storage_instances
47+
assert_equal(len(sis), 2)
48+
assert_equal(sis[0].instance_number, 1)
49+
assert_equal(sis[1].instance_number, 2)
50+
assert_equal(sis[0].uid,
51+
'1.3.12.2.1107.5.2.32.35119.2010011420300180088599504.0')
52+
assert_equal(sis[1].uid,
53+
'1.3.12.2.1107.5.2.32.35119.2010011420300180088599504.1')
54+
55+
def test_storage_instance():
56+
return
57+
58+
def test_png():
59+
studies = dft.get_studies(data_dir)
60+
data = studies[0].series[0].as_png()
61+
im = PIL.Image.open(StringIO.StringIO(data))
62+
assert_equal(im.size, (256, 256))
63+
return
64+
65+
def test_nifti():
66+
studies = dft.get_studies(data_dir)
67+
data = studies[0].series[0].as_nifti()
68+
assert_equal(len(data), 352 + 2*256*256*2)
69+
h = nifti1.Nifti1Header(data[:348])
70+
assert_equal(h.get_data_shape(), (256, 256, 2))
71+
return
72+

0 commit comments

Comments
 (0)