Mercurial > hg > orthanc-tests
annotate Tests/Tests.py @ 78:b89af51797ff
test_decode_transfer_syntax
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Jan 2016 17:25:11 +0100 |
parents | 8d16ed93ce09 |
children | 962274ebd797 |
rev | line source |
---|---|
22 | 1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 | |
3 | 5 # Orthanc - A Lightweight, RESTful DICOM Store |
73 | 6 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
3 | 7 # Department, University Hospital of Liege, Belgium |
8 # | |
9 # This program is free software: you can redistribute it and/or | |
10 # modify it under the terms of the GNU General Public License as | |
11 # published by the Free Software Foundation, either version 3 of the | |
12 # License, or (at your option) any later version. | |
13 # | |
14 # This program is distributed in the hope that it will be useful, but | |
15 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 # General Public License for more details. | |
18 # | |
19 # You should have received a copy of the GNU General Public License | |
20 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | |
22 | |
14 | 23 import tempfile |
3 | 24 import unittest |
36 | 25 import base64 |
3 | 26 |
11 | 27 from PIL import ImageChops |
3 | 28 from Toolbox import * |
13 | 29 from xml.dom import minidom |
3 | 30 |
31 _LOCAL = None | |
32 _REMOTE = None | |
33 | |
34 | |
35 def SetOrthancParameters(local, remote): | |
36 global _LOCAL, _REMOTE | |
37 _LOCAL = local | |
38 _REMOTE = remote | |
39 | |
40 | |
14 | 41 def ExtractDicomTags(rawDicom, tags): |
42 with tempfile.NamedTemporaryFile(delete = True) as f: | |
43 f.write(rawDicom) | |
44 f.flush() | |
45 | 45 data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
14 | 46 |
47 result = [] | |
48 for tag in tags: | |
49 match = re.search('<element[^>]+name="%s">([^>]*)</element>' % tag, data) | |
50 if match == None: | |
51 result.append('') | |
52 else: | |
53 result.append(match.group(1)) | |
54 | |
55 return result | |
56 | |
57 | |
15 | 58 def InstallLuaScript(path): |
59 with open(GetDatabasePath(path), 'r') as f: | |
60 DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua') | |
61 | |
62 | |
63 def UninstallLuaCallbacks(): | |
64 DoPost(_REMOTE, '/tools/execute-script', 'function OnStoredInstance() end', 'application/lua') | |
43 | 65 InstallLuaScript('Lua/TransferSyntaxEnable.lua') |
15 | 66 |
67 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
68 def CompareLists(a, b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
69 if len(a) != len(b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
70 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
71 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
72 for i in range(len(a)): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
73 d = a[i] - b[i] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
74 if abs(d) >= 0.51: # Add some tolerance for rounding errors |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
75 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
76 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
77 return True |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
78 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
79 |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
80 def CallFindScu(args): |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
81 p = subprocess.Popen([ FindExecutable('findscu'), |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
82 '-P', '-aec', _REMOTE['DicomAet'], '-aet', _LOCAL['DicomAet'], |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
83 _REMOTE['Server'], str(_REMOTE['DicomPort']) ] + args, |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
84 stderr=subprocess.PIPE) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
85 return p.communicate()[1] |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
86 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
87 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
88 def CallMoveScu(args): |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
89 subprocess.check_call([ FindExecutable('movescu'), |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
90 '--move', _LOCAL['DicomAet'], # Target AET (i.e. storescp) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
91 '--call', _REMOTE['DicomAet'], # Called AET (i.e. Orthanc) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
92 '--aetitle', _LOCAL['DicomAet'], # Calling AET (i.e. storescp) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
93 _REMOTE['Server'], str(_REMOTE['DicomPort']) ] + args, |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
94 stderr=subprocess.PIPE) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
95 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
96 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
97 |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
98 def GenerateTestSequence(): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
99 return [ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
100 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
101 'StudyDescription': 'Hello^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
102 'ReferencedStudySequence' : [ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
103 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
104 'StudyDescription': 'Toto', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
105 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
106 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
107 'StudyDescription': 'Tata', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
108 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
109 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
110 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
111 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
112 'StudyDescription': 'Sébastien^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
113 'StudyDate' : '19700202', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
114 } |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
115 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
116 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
117 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
118 |
15 | 119 |
3 | 120 class Orthanc(unittest.TestCase): |
121 def setUp(self): | |
122 DropOrthanc(_LOCAL) | |
123 DropOrthanc(_REMOTE) | |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
124 UninstallLuaCallbacks() |
45 | 125 #print "In test", self._testMethodName |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
126 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
127 def AssertSameImages(self, truth, url): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
128 im = GetImage(_REMOTE, url) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
129 self.assertTrue(CompareLists(truth, im.getdata())) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
130 |
3 | 131 |
132 def test_system(self): | |
133 self.assertTrue('Version' in DoGet(_REMOTE, '/system')) | |
134 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
135 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
136 | |
137 def test_upload(self): | |
138 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
139 self.assertEqual('Success', u['Status']) | |
140 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
141 self.assertEqual('AlreadyStored', u['Status']) | |
142 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
143 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
144 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
145 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
146 | |
147 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % u['ID']) | |
148 self.assertEqual('20070101', i['StudyDate']) | |
149 | |
150 | |
5 | 151 def test_upload_2(self): |
3 | 152 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
153 instance = DoGet(_REMOTE, '/instances/%s' % i) | |
154 self.assertEqual(i, instance['ID']) | |
155 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', | |
156 instance['MainDicomTags']['SOPInstanceUID']) | |
157 | |
158 series = DoGet(_REMOTE, '/series/%s' % instance['ParentSeries']) | |
159 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
160 series['MainDicomTags']['SeriesInstanceUID']) | |
161 | |
162 study = DoGet(_REMOTE, '/studies/%s' % series['ParentStudy']) | |
163 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
164 study['MainDicomTags']['StudyInstanceUID']) | |
165 | |
166 patient = DoGet(_REMOTE, '/patients/%s' % study['ParentPatient']) | |
167 self.assertEqual('ozp00SjY2xG', | |
168 patient['MainDicomTags']['PatientID']) | |
169 | |
170 dicom = DoGet(_REMOTE, '/instances/%s/file' % instance['ID']) | |
171 self.assertEqual(2472, len(dicom)) | |
172 self.assertEqual('3e29b869978b6db4886355a2b1132124', ComputeMD5(dicom)) | |
173 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
174 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/simplified-tags' % i)['StationName']) | |
175 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags' % i)['0008,1010']['Value']) | |
176 | |
177 | |
5 | 178 def test_images(self): |
179 i = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] | |
180 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
3 | 181 |
5 | 182 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
183 self.assertEqual("L", im.mode) | |
184 self.assertEqual(512, im.size[0]) | |
185 self.assertEqual(358, im.size[1]) | |
186 | |
187 im = GetImage(_REMOTE, '/instances/%s/image-uint8' % i) | |
188 self.assertEqual("L", im.mode) | |
189 self.assertEqual(512, im.size[0]) | |
190 self.assertEqual(358, im.size[1]) | |
191 | |
192 im = GetImage(_REMOTE, '/instances/%s/image-uint16' % i) | |
193 self.assertEqual(512, im.size[0]) | |
194 self.assertEqual(358, im.size[1]) | |
195 | |
196 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
197 self.assertEqual("L", im.mode) | |
198 self.assertEqual(512, im.size[0]) | |
199 self.assertEqual(358, im.size[1]) | |
200 | |
201 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
202 self.assertEqual("L", im.mode) | |
203 self.assertEqual(512, im.size[0]) | |
204 self.assertEqual(358, im.size[1]) | |
205 | |
206 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
207 self.assertEqual(512, im.size[0]) | |
208 self.assertEqual(358, im.size[1]) | |
64 | 209 |
210 # This is Little Endian Explicit | |
211 self.assertEqual('1.2.840.10008.1.2.1', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) | |
212 | |
6 | 213 |
214 def test_hierarchy(self): | |
215 UploadFolder(_REMOTE, 'Brainix/Epi') | |
216 UploadFolder(_REMOTE, 'Brainix/Flair') | |
217 UploadFolder(_REMOTE, 'Knee/T1') | |
218 UploadFolder(_REMOTE, 'Knee/T2') | |
219 | |
220 p = DoGet(_REMOTE, '/patients') | |
221 s = DoGet(_REMOTE, '/studies') | |
222 t = DoGet(_REMOTE, '/series') | |
223 self.assertEqual(2, len(p)) | |
224 self.assertEqual(2, len(s)) | |
225 self.assertEqual(4, len(t)) | |
226 self.assertEqual(94, len(DoGet(_REMOTE, '/instances'))) | |
227 | |
228 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
229 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
230 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
231 brainixFlair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
232 | |
233 kneePatient = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
234 kneeStudy = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
235 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
236 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
237 | |
238 self.assertTrue(brainixPatient in p) | |
239 self.assertTrue(kneePatient in p) | |
240 self.assertTrue(brainixStudy in s) | |
241 self.assertTrue(kneeStudy in s) | |
242 self.assertTrue(brainixEpi in t) | |
243 self.assertTrue(brainixFlair in t) | |
244 self.assertTrue(kneeT1 in t) | |
245 self.assertTrue(kneeT2 in t) | |
246 | |
247 self.assertEqual(44, len(DoGet(_REMOTE, '/patients/%s/instances' % brainixPatient))) | |
248 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % brainixPatient))) | |
249 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % brainixPatient))) | |
250 | |
251 self.assertEqual(50, len(DoGet(_REMOTE, '/patients/%s/instances' % kneePatient))) | |
252 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % kneePatient))) | |
253 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % kneePatient))) | |
254 | |
255 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % brainixStudy))) | |
256 self.assertEqual(44, len(DoGet(_REMOTE, '/studies/%s/instances' % brainixStudy))) | |
257 | |
258 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % kneeStudy))) | |
259 self.assertEqual(50, len(DoGet(_REMOTE, '/studies/%s/instances' % kneeStudy))) | |
260 | |
261 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixEpi))) | |
262 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixFlair))) | |
263 self.assertEqual(24, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT1))) | |
264 self.assertEqual(26, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT2))) | |
265 | |
266 for patient in p: | |
267 for study in DoGet(_REMOTE, '/patients/%s/studies' % patient): | |
268 self.assertEqual(patient, study['ParentPatient']) | |
269 for series in DoGet(_REMOTE, '/studies/%s/series' % study['ID']): | |
270 self.assertEqual(study['ID'], series['ParentStudy']) | |
271 for instance in DoGet(_REMOTE, '/series/%s/instances' % series['ID']): | |
272 self.assertEqual(series['ID'], instance['ParentSeries']) | |
273 | |
274 self.assertEqual(json.dumps(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance['ID'])), | |
275 json.dumps(DoGet(_REMOTE, '/instances/%s/tags' % instance['ID']))) | |
276 | |
277 | |
278 r = DoDelete(_REMOTE, "/studies/%s" % brainixStudy)['RemainingAncestor'] | |
279 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
280 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
281 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
282 self.assertEqual(50, len(DoGet(_REMOTE, '/instances'))) | |
283 self.assertEqual(None, r) | |
284 | |
285 r = DoDelete(_REMOTE, "/series/%s" % kneeT2)['RemainingAncestor'] | |
286 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
287 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
288 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
289 self.assertEqual(24, len(DoGet(_REMOTE, '/instances'))) | |
290 self.assertEqual('Study', r['Type']) | |
291 self.assertEqual(kneeStudy, r['ID']) | |
292 | |
293 r = DoDelete(_REMOTE, "/instances/%s" % DoGet(_REMOTE, '/instances')[0])['RemainingAncestor'] | |
294 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
295 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
296 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
297 self.assertEqual(23, len(DoGet(_REMOTE, '/instances'))) | |
298 self.assertEqual('Series', r['Type']) | |
299 self.assertEqual(kneeT1, r['ID']) | |
300 | |
301 r = DoDelete(_REMOTE, "/patients/%s" % kneePatient)['RemainingAncestor'] | |
302 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
303 self.assertEqual(0, len(DoGet(_REMOTE, '/studies'))) | |
304 self.assertEqual(0, len(DoGet(_REMOTE, '/series'))) | |
305 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
306 self.assertEqual(None, r) | |
307 | |
308 DropOrthanc(_REMOTE) | |
309 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
310 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
7 | 311 |
312 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
313 def test_multiframe(self): |
7 | 314 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
315 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
316 | |
317 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
318 self.assertEqual("L", im.mode) | |
319 self.assertEqual(512, im.size[0]) | |
320 self.assertEqual(512, im.size[1]) | |
321 | |
322 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
323 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
324 DoGet(_REMOTE, '/instances/%s/frames/75/preview' % i) | |
325 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/aaa/preview' % i)) | |
326 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/preview' % i)) | |
327 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
328 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
329 def test_changes(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
330 # Check emptiness |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
331 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
332 self.assertEqual(0, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
333 self.assertEqual(0, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
334 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
335 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
336 self.assertEqual(0, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
337 self.assertEqual(0, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
338 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
339 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
340 # Add 1 instance |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
341 i = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
342 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
343 begin = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
344 self.assertEqual(4, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
345 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
346 self.assertEqual(c['Changes'][-1]['Seq'], c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
347 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
348 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
349 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
350 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
351 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
352 c = DoGet(_REMOTE, '/changes?limit=1&since=' + str(begin - 1)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
353 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
354 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
355 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
356 c = DoGet(_REMOTE, '/changes?limit=1&since=' + str(begin - 2)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
357 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
358 self.assertEqual(begin - 1, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
359 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
360 c = DoGet(_REMOTE, '/changes?limit=1&since=' + str(begin - 3)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
361 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
362 self.assertEqual(begin - 2, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
363 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
364 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
365 UploadFolder(_REMOTE, 'Knee/T1') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
366 UploadFolder(_REMOTE, 'Knee/T2') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
367 since = begin |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
368 countPatients = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
369 countStudies = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
370 countSeries = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
371 countInstances = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
372 completed = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
373 while True: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
374 c = DoGet(_REMOTE, '/changes', { 'since' : since, 'limit' : 3 }) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
375 since = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
376 for i in c['Changes']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
377 if i['ResourceType'] == 'Instance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
378 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
379 if i['ResourceType'] == 'Patient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
380 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
381 if i['ResourceType'] == 'Study': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
382 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
383 if i['ResourceType'] == 'Series': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
384 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
385 if i['ChangeType'] == 'NewInstance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
386 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
387 if i['ChangeType'] == 'NewPatient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
388 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
389 if i['ChangeType'] == 'NewStudy': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
390 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
391 if i['ChangeType'] == 'NewSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
392 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
393 if i['ChangeType'] == 'CompletedSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
394 completed += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
395 self.assertTrue('ID' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
396 self.assertTrue('Path' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
397 self.assertTrue('Seq' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
398 if c['Done']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
399 break |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
400 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
401 self.assertEqual(2 * 50, countInstances) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
402 self.assertEqual(2 * 1, countPatients) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
403 self.assertEqual(2 * 1, countStudies) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
404 self.assertEqual(2 * 2, countSeries) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
405 self.assertEqual(0, completed) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
406 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
407 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
408 def test_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
409 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
410 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
411 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
412 z = GetArchive(_REMOTE, '/patients/%s/archive' % DoGet(_REMOTE, '/patients')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
413 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
414 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
415 z = GetArchive(_REMOTE, '/studies/%s/archive' % DoGet(_REMOTE, '/studies')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
416 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
417 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
418 z = GetArchive(_REMOTE, '/series/%s/archive' % DoGet(_REMOTE, '/series')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
419 self.assertEqual(1, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
420 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
421 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
422 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
423 z = GetArchive(_REMOTE, '/patients/%s/archive' % DoGet(_REMOTE, '/patients')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
424 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
425 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
426 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
427 def test_media_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
428 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
429 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
430 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
431 z = GetArchive(_REMOTE, '/patients/%s/media' % DoGet(_REMOTE, '/patients')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
432 self.assertEqual(3, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
433 self.assertTrue('IMAGES/IM0' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
434 self.assertTrue('IMAGES/IM1' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
435 self.assertTrue('DICOMDIR' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
436 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
437 try: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
438 os.remove('/tmp/DICOMDIR') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
439 except: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
440 # The file does not exist |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
441 pass |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
442 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
443 z.extract('DICOMDIR', '/tmp') |
45 | 444 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
445 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
446 self.assertEqual(3, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
447 self.assertTrue(a[0].startswith('Warning')) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
448 self.assertEqual('BasicDirectory', a[1]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
449 self.assertEqual('', a[2]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
450 |
45 | 451 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
452 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
453 self.assertEqual(1, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
454 self.assertEqual('', a[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
455 |
45 | 456 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
457 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', a) != None) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
458 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081909113806560', a) != None) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
459 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
460 os.remove('/tmp/DICOMDIR') |
10 | 461 |
462 | |
463 def test_protection(self): | |
464 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
465 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
466 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
467 a = DoGet(_REMOTE, '/patients')[0] | |
468 b = DoGet(_REMOTE, '/patients')[1] | |
469 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
470 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
471 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
472 DoPut(_REMOTE, '/patients/%s/protected' % a, '1', 'text/plain') | |
473 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
474 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
475 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
476 | |
477 | |
12 | 478 def test_raw_tags(self): |
10 | 479 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
480 | |
481 dicom = DoGet(_REMOTE, '/instances/%s/file' % i) | |
482 self.assertEqual('1a7c56cb02d6e742cc9c856a8ac182e3', ComputeMD5(dicom)) | |
483 | |
484 s = '/instances/%s/content/' % i | |
485 | |
486 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, s + '0008-1010').strip()) | |
487 self.assertRaises(Exception, lambda: DoGet(_REMOTE, s + '0008-1011')) | |
488 | |
489 self.assertEqual('Abdomen', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/0/7fe1-1057').strip()) | |
490 self.assertEqual('cla_3c', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/8/7fe1-1057').strip()) | |
491 | |
492 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
493 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
494 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
495 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
496 | |
497 for i in DoGet(_REMOTE, '/instances'): | |
498 aid = DoGet(_REMOTE, '/instances/%s' % i)['MainDicomTags']['SOPInstanceUID'] | |
499 self.assertEqual(aid, DoGet(_REMOTE, '/instances/%s/content/0008-0018' % i).replace(chr(0), '')) | |
500 | |
501 | |
502 def test_raw_tags_mdn(self): | |
503 # Bug reported by Cyril Paulus | |
504 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
505 self.assertAlmostEqual(0.000027, DoGet(_REMOTE, '/instances/%s/content/7053-1000' % i)) | |
506 | |
507 | |
508 def test_modify_instance(self): | |
509 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] | |
510 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, | |
511 json.dumps({ | |
512 "Replace" : { | |
513 "PatientName" : "hello", | |
514 #"PatientID" : "world" | |
515 }, | |
516 "Remove" : [ "StationName" ], | |
517 "RemovePrivateTags" : None | |
518 }), | |
519 'application/json') | |
520 j = DoPost(_REMOTE, '/instances', modified, 'application/dicom')['ID'] | |
521 | |
522 self.assertNotEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
523 #self.assertNotEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % i).strip()) | |
524 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i).strip()) | |
525 DoGet(_REMOTE, '/instances/%s/content/6003-1010' % i) # Some private tag | |
526 | |
527 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
528 #self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % j).strip()) | |
529 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j)) | |
530 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/6003-1010' % j)) | |
531 | |
532 | |
533 def test_modify_series(self): | |
534 # Upload 4 images from the same series | |
535 for i in range(4): | |
536 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
537 | |
538 origSeries = DoGet(_REMOTE, '/series')[0] | |
539 newSeries = DoPost(_REMOTE, '/series/%s/modify' % origSeries, | |
540 '{"Replace":{"PatientName":"Jodogne"}}', | |
541 'application/json')['ID'] | |
542 | |
543 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['ModifiedFrom']) | |
544 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
545 self.assertEqual(4, len(instances)) | |
546 for i in instances: | |
547 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
548 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
549 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
550 | |
551 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
552 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
553 | |
554 | |
555 def test_modify_study(self): | |
556 # Upload 4 images from the 2 series of the same study | |
557 for i in range(4): | |
558 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
559 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
560 | |
561 origStudy = DoGet(_REMOTE, '/studies')[0] | |
562 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, | |
563 '{"Replace":{"PatientName":"Jodogne"}}', | |
564 'application/json')['ID'] | |
565 | |
566 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['ModifiedFrom']) | |
567 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
568 self.assertEqual(2, len(series)) | |
569 for s in series: | |
570 ss = DoGet(_REMOTE, '/series/%s' % s)['ModifiedFrom'] | |
571 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
572 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
573 | |
574 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
575 for i in instances: | |
576 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
577 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
578 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
579 | |
580 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
581 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
582 | |
583 | |
584 def test_anonymize_series(self): | |
585 # Upload 4 images from the same series | |
586 for i in range(4): | |
587 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
588 | |
589 origSeries = DoGet(_REMOTE, '/series')[0] | |
590 newSeries = DoPost(_REMOTE, '/series/%s/anonymize' % origSeries, | |
591 '{}', | |
592 'application/json')['ID'] | |
593 | |
594 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['AnonymizedFrom']) | |
595 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
596 self.assertEqual(4, len(instances)) | |
597 for i in instances: | |
598 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
599 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
600 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
601 | |
602 DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j) | |
603 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i)) | |
604 | |
605 | |
606 def test_anonymize_study(self): | |
607 # Upload 4 images from the 2 series of the same study | |
608 for i in range(4): | |
609 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
610 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
611 | |
612 origStudy = DoGet(_REMOTE, '/studies')[0] | |
613 newStudy = DoPost(_REMOTE,'/studies/%s/anonymize' % origStudy, | |
614 '{"Replace":{"PatientName":"Jodogne"}}', | |
615 'application/json')['ID'] | |
616 | |
617 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['AnonymizedFrom']) | |
618 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
619 self.assertEqual(2, len(series)) | |
620 for s in series: | |
621 ss = DoGet(_REMOTE, '/series/%s' % s)['AnonymizedFrom'] | |
622 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
623 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
624 | |
625 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
626 for i in instances: | |
627 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
628 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
629 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
630 | |
631 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
632 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
11 | 633 |
634 | |
635 | |
636 def test_storescu(self): | |
637 # Check emptiness | |
638 e = DoGet(_REMOTE, '/exports') | |
639 self.assertEqual(0, len(e['Exports'])) | |
640 self.assertEqual(0, e['Last']) | |
641 self.assertTrue(e['Done']) | |
642 e = DoGet(_REMOTE, '/exports?last') | |
643 self.assertEqual(0, len(e['Exports'])) | |
644 self.assertEqual(0, e['Last']) | |
645 self.assertTrue(e['Done']) | |
646 | |
647 # Add 1 instance | |
648 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
649 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
650 | |
651 # Export the instance | |
652 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') # instance | |
653 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
654 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
655 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
656 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
657 | |
658 e = DoGet(_REMOTE, '/exports') | |
659 self.assertEqual(1, len(e['Exports'])) | |
660 self.assertTrue(e['Done']) | |
661 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
662 e = DoGet(_REMOTE, '/exports?limit=1') | |
663 self.assertEqual(1, len(e['Exports'])) | |
664 self.assertTrue(e['Done']) | |
665 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
666 e = DoGet(_REMOTE, '/exports?last') | |
667 self.assertEqual(1, len(e['Exports'])) | |
668 self.assertTrue(e['Done']) | |
669 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
670 seqInstance = e['Last'] | |
671 | |
672 # Export the series | |
673 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', 'text/plain') | |
674 | |
675 e = DoGet(_REMOTE, '/exports') | |
676 self.assertEqual(2, len(e['Exports'])) | |
677 self.assertTrue(e['Done']) | |
678 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
679 seqSeries = e['Last'] | |
680 self.assertNotEqual(seqInstance, seqSeries) | |
681 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
682 self.assertEqual(1, len(e['Exports'])) | |
683 self.assertFalse(e['Done']) | |
684 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
685 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
686 self.assertEqual(1, len(e['Exports'])) | |
687 self.assertTrue(e['Done']) | |
688 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
689 e = DoGet(_REMOTE, '/exports?last') | |
690 self.assertEqual(1, len(e['Exports'])) | |
691 self.assertTrue(e['Done']) | |
692 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
693 | |
694 # Export the study | |
695 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', 'text/plain') | |
696 seqStudy = DoGet(_REMOTE, '/exports')['Last'] | |
697 | |
698 # Export the patient | |
699 j = DoPost(_REMOTE, '/modalities/orthanctest/store', '6816cb19-844d5aee-85245eba-28e841e6-2414fae2', 'text/plain') | |
700 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
701 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
702 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
703 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
704 | |
705 e = DoGet(_REMOTE, '/exports') | |
706 self.assertEqual(4, len(e['Exports'])) | |
707 self.assertTrue(e['Done']) | |
708 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
709 seqPatient = e['Last'] | |
710 self.assertNotEqual(seqInstance, seqSeries) | |
711 self.assertNotEqual(seqSeries, seqStudy) | |
712 self.assertNotEqual(seqStudy, seqPatient) | |
713 self.assertTrue(seqInstance < seqSeries) | |
714 self.assertTrue(seqSeries < seqStudy) | |
715 self.assertTrue(seqStudy < seqPatient) | |
716 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
717 self.assertEqual(1, len(e['Exports'])) | |
718 self.assertFalse(e['Done']) | |
719 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
720 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
721 self.assertEqual(1, len(e['Exports'])) | |
722 self.assertFalse(e['Done']) | |
723 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
724 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqSeries)) | |
725 self.assertEqual(1, len(e['Exports'])) | |
726 self.assertFalse(e['Done']) | |
727 self.assertEqual(e['Exports'][-1]['Seq'], seqStudy) | |
728 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqStudy)) | |
729 self.assertEqual(1, len(e['Exports'])) | |
730 self.assertTrue(e['Done']) | |
731 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
732 e = DoGet(_REMOTE, '/exports?last') | |
733 self.assertEqual(1, len(e['Exports'])) | |
734 self.assertTrue(e['Done']) | |
735 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
736 | |
737 | |
738 # Check the content of the logged information | |
739 e = DoGet(_REMOTE, '/exports')['Exports'] | |
740 | |
741 if 'PatientID' in e[0]: | |
742 # Since Orthanc 0.8.6 | |
743 patient = 'PatientID' | |
744 study = 'StudyInstanceUID' | |
745 series = 'SeriesInstanceUID' | |
746 instance = 'SOPInstanceUID' | |
747 else: | |
748 # Up to Orthanc 0.8.5 | |
749 patient = 'PatientId' | |
750 study = 'StudyInstanceUid' | |
751 series = 'SeriesInstanceUid' | |
752 instance = 'SopInstanceUid' | |
753 | |
754 for k in range(4): | |
755 self.assertTrue('Date' in e[k]) | |
756 self.assertTrue('Seq' in e[k]) | |
757 self.assertEqual('orthanctest', e[k]['RemoteModality']) | |
758 | |
759 self.assertEqual(10, len(e[0])) | |
760 self.assertEqual('Instance', e[0]['ResourceType']) | |
761 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['ID']) | |
762 self.assertEqual('/instances/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['Path']) | |
763 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', e[0][instance]) | |
764 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[0][series]) | |
765 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[0][study]) | |
766 self.assertEqual('ozp00SjY2xG', e[0][patient]) | |
767 | |
768 self.assertEqual(9, len(e[1])) | |
769 self.assertEqual('Series', e[1]['ResourceType']) | |
770 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['ID']) | |
771 self.assertEqual('/series/f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['Path']) | |
772 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[1][series]) | |
773 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[1][study]) | |
774 self.assertEqual('ozp00SjY2xG', e[1][patient]) | |
775 | |
776 self.assertEqual(8, len(e[2])) | |
777 self.assertEqual('Study', e[2]['ResourceType']) | |
778 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['ID']) | |
779 self.assertEqual('/studies/b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['Path']) | |
780 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[2][study]) | |
781 self.assertEqual('ozp00SjY2xG', e[2][patient]) | |
782 | |
783 self.assertEqual(7, len(e[3])) | |
784 self.assertEqual('Patient', e[3]['ResourceType']) | |
785 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['ID']) | |
786 self.assertEqual('/patients/6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['Path']) | |
787 self.assertEqual('ozp00SjY2xG', e[3][patient]) | |
788 | |
789 DropOrthanc(_REMOTE) | |
790 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
791 | |
792 | |
793 def test_store_peer(self): | |
794 self.assertEqual(0, len(DoGet(_LOCAL, '/exports')['Exports'])) | |
795 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
796 | |
797 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
798 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
799 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
800 | |
801 j = DoPost(_REMOTE, '/peers/peer/store', str(i), 'text/plain') | |
802 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
803 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
804 | |
805 self.assertEqual(1, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
806 | |
807 DropOrthanc(_REMOTE) | |
808 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
809 | |
810 | |
811 def test_bulk_storescu(self): | |
812 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
813 | |
814 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
815 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
816 | |
817 j = DoPost(_REMOTE, '/modalities/orthanctest/store', [ a['ID'], b['ID'] ], 'application/json') | |
818 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
819 | |
820 DropOrthanc(_LOCAL) | |
821 | |
822 # Send using patient's UUID | |
823 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
824 j = DoPost(_REMOTE, '/modalities/orthanctest/store', | |
825 [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ], 'application/json') | |
826 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
827 | |
828 | |
829 def test_color(self): | |
830 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
831 im = GetImage(_REMOTE, '/instances/%s/preview' % i) | |
832 self.assertEqual("RGB", im.mode) | |
833 self.assertEqual(41, im.size[0]) | |
834 self.assertEqual(41, im.size[1]) | |
835 | |
836 # http://effbot.org/zone/pil-comparing-images.htm | |
13 | 837 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) |
11 | 838 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) |
839 | |
840 | |
12 | 841 def test_faking_ruby_put(self): |
842 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
843 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
844 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
845 a = DoGet(_REMOTE, '/patients')[0] | |
846 b = DoGet(_REMOTE, '/patients')[1] | |
847 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
848 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
849 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
850 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '1') | |
851 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
852 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
853 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
854 | |
855 | |
856 def test_faking_ruby_delete(self): | |
857 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
858 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
859 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
860 a = DoGet(_REMOTE, '/patients')[0] | |
861 b = DoGet(_REMOTE, '/patients')[1] | |
862 DoGet(_REMOTE, '/patients/%s' % a, data = { '_method' : 'DELETE' }) | |
863 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
864 DoGet(_REMOTE, '/patients/%s' % b, data = { '_method' : 'DELETE' }) | |
865 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
866 | |
867 | |
868 def test_faking_google_put(self): | |
869 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
870 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
871 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
872 a = DoGet(_REMOTE, '/patients')[0] | |
873 b = DoGet(_REMOTE, '/patients')[1] | |
874 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
875 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
876 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
877 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '1') | |
878 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
879 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
880 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
881 | |
882 | |
883 def test_faking_google_delete(self): | |
884 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
885 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
886 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
887 a = DoGet(_REMOTE, '/patients')[0] | |
888 b = DoGet(_REMOTE, '/patients')[1] | |
889 DoPost(_REMOTE, '/patients/%s' % a, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
890 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
891 DoPost(_REMOTE, '/patients/%s' % b, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
892 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
893 | |
894 | |
895 def test_lua(self): | |
896 self.assertEqual(42, DoPost(_REMOTE, '/tools/execute-script', 'print(42)')) | |
897 self.assertTrue(IsDefinedInLua(_REMOTE, 'PrintRecursive')) | |
898 self.assertFalse(IsDefinedInLua(_REMOTE, 'HelloWorld')) | |
899 | |
900 | |
901 def test_metadata(self): | |
902 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
903 p = DoGet(_REMOTE, '/patients')[0] | |
904 i = DoGet(_REMOTE, '/instances')[0] | |
905 | |
906 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
907 self.assertEqual(1, len(m)) | |
908 self.assertEqual('LastUpdate', m[0]) | |
909 | |
910 m = DoGet(_REMOTE, '/instances/%s/metadata' % i) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
911 self.assertEqual(4, len(m)) |
12 | 912 self.assertTrue('IndexInSeries' in m) |
913 self.assertTrue('ReceptionDate' in m) | |
914 self.assertTrue('RemoteAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
915 self.assertTrue('Origin' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
916 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/IndexInSeries' % i), 1) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
917 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i), 'RestApi') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
918 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i), '') # None, received by REST API |
12 | 919 |
920 # Play with custom metadata | |
921 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'coucou') | |
922 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
923 self.assertEqual(2, len(m)) | |
924 self.assertTrue('LastUpdate' in m) | |
925 self.assertTrue('5555' in m) | |
926 self.assertEqual('coucou', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
927 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'hello') | |
928 self.assertEqual('hello', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
929 DoDelete(_REMOTE, '/patients/%s/metadata/5555' % p) | |
930 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
931 self.assertEqual(1, len(m)) | |
932 self.assertTrue('LastUpdate' in m) | |
13 | 933 |
934 | |
935 def test_statistics(self): | |
936 # Upload 16 instances | |
937 for i in range(4): | |
938 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
939 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
940 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
941 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
942 | |
943 s = DoGet(_REMOTE, '/statistics') | |
944 self.assertEqual(16, s['CountInstances']) | |
945 self.assertEqual(2, s['CountPatients']) | |
946 self.assertEqual(2, s['CountStudies']) | |
947 self.assertEqual(4, s['CountSeries']) | |
948 d = int(s['TotalUncompressedSize']) | |
949 | |
950 e = 0 | |
951 for patient in DoGet(_REMOTE, '/patients'): | |
952 s = DoGet(_REMOTE, '/patients/%s/statistics' % patient) | |
953 self.assertEqual(8, s['CountInstances']) | |
954 self.assertEqual(1, s['CountStudies']) | |
955 self.assertEqual(2, s['CountSeries']) | |
956 e += int(s['UncompressedSize']) | |
957 | |
958 for study in DoGet(_REMOTE, '/studies'): | |
959 s = DoGet(_REMOTE, '/studies/%s/statistics' % study) | |
960 self.assertEqual(8, s['CountInstances']) | |
961 self.assertEqual(2, s['CountSeries']) | |
962 e += int(s['UncompressedSize']) | |
963 | |
964 for series in DoGet(_REMOTE, '/series'): | |
965 s = DoGet(_REMOTE, '/series/%s/statistics' % series) | |
966 self.assertEqual(4, s['CountInstances']) | |
967 e += int(s['UncompressedSize']) | |
968 | |
969 self.assertEqual(3 * d, e) | |
970 | |
971 | |
972 def test_custom_attachment(self): | |
973 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
974 patient = DoGet(_REMOTE, '/patients')[0] | |
975 instance = DoGet(_REMOTE, '/instances')[0] | |
976 size = int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']) | |
977 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
978 | |
979 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
980 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) | |
981 self.assertTrue('dicom' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
982 self.assertTrue('dicom-as-json' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
983 | |
984 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/22' % patient, 'hello')) | |
985 hello = 'hellohellohellohellohellohellohellohellohello' | |
986 DoPut(_REMOTE, '/patients/%s/attachments/1025' % patient, hello) | |
987 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
988 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
989 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
990 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient))) | |
991 | |
992 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world') | |
993 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
994 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
995 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
996 size + | |
997 int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient)) + | |
998 int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
999 | |
1000 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1001 self.assertEqual(hello, DoGet(_REMOTE, '/patients/%s/attachments/1025/data' % patient)) | |
1002 self.assertEqual('world', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1003 DoPost(_REMOTE, '/patients/%s/attachments/1025/verify-md5' % patient) | |
1004 DoPost(_REMOTE, '/patients/%s/attachments/1026/verify-md5' % patient) | |
1005 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world2') | |
1006 self.assertEqual('world2', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1007 | |
1008 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) | |
1009 DoDelete(_REMOTE, '/patients/%s/attachments/1025' % patient) | |
1010 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1011 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1012 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1013 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1014 | |
1015 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1016 DoDelete(_REMOTE, '/patients/%s/attachments/1026' % patient) | |
1017 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1018 | |
1019 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), size) | |
1020 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1021 | |
1022 | |
1023 def test_incoming_storescu(self): | |
1024 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
45 | 1025 subprocess.check_call([ FindExecutable('storescu'), |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
1026 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
13 | 1027 GetDatabasePath('ColorTestImageJ.dcm') ]) |
1028 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1029 | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1030 i = DoGet(_REMOTE, '/instances') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1031 self.assertEqual(1, len(i)) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1032 m = DoGet(_REMOTE, '/instances/%s/metadata' % i[0]) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1033 self.assertEqual(4, len(m)) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1034 self.assertTrue('IndexInSeries' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1035 self.assertTrue('ReceptionDate' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1036 self.assertTrue('RemoteAET' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1037 self.assertTrue('Origin' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1038 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/IndexInSeries' % i[0]), 1) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1039 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i[0]), 'DicomProtocol') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1040 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i[0]), 'STORESCU') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1041 |
13 | 1042 |
1043 def test_incoming_findscu(self): | |
1044 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
1045 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') | |
1046 | |
1047 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', '0010,0010' ]) | |
1048 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) | |
1049 self.assertEqual(2, len(patientNames)) | |
1050 self.assertTrue('Test Patient BG ' in patientNames) | |
1051 self.assertTrue('Anonymized' in patientNames) | |
1052 | |
1053 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021' ]) | |
1054 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) | |
1055 self.assertEqual(2, len(series)) | |
1056 self.assertTrue('20070208' in series) | |
1057 self.assertTrue('19980312' in series) | |
1058 | |
56
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1059 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021', '-k', 'ModalitiesInStudy=MR\\XA' ]) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1060 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1061 self.assertEqual(1, len(series)) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1062 self.assertTrue('19980312' in series) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1063 |
13 | 1064 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=Anonymized' ]) |
1065 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1066 self.assertEqual(1, len(series)) | |
1067 | |
1068 # Test the "CaseSentitivePN" flag (false by default) | |
1069 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=anonymized' ]) | |
1070 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1071 self.assertEqual(1, len(series)) | |
66
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1072 |
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1073 # Test returning sequence values (only since Orthanc 0.9.5) |
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1074 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,2112' ]) # "ColorTestImageJ" has this sequence tag |
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1075 sequences = re.findall('\(0008,2112\)', i) |
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1076 self.assertEqual(1, len(sequences)) |
70 | 1077 |
1078 # Test range search (buggy if Orthanc <= 0.9.6) | |
1079 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-' ]) | |
1080 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1081 self.assertEqual(2, len(studies)) | |
1082 self.assertTrue('20070208' in studies) | |
1083 self.assertTrue('19980312' in studies) | |
1084 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-19980312' ]) | |
1085 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1086 self.assertEqual(1, len(studies)) | |
1087 self.assertTrue('19980312' in studies) | |
1088 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=-19980312' ]) | |
1089 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1090 self.assertEqual(1, len(studies)) | |
1091 self.assertTrue('19980312' in studies) | |
13 | 1092 |
1093 | |
1094 def test_incoming_movescu(self): | |
1095 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
1096 | |
1097 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
17 | 1098 CallMoveScu([ '--patient', '-k', '0008,0052=PATIENT', '-k', 'PatientID=none' ]) |
13 | 1099 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
1100 CallMoveScu([ '--patient', '-k', '0008,0052=PATIENT', '-k', 'PatientID=12345678' ]) | |
1101 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
1102 | |
1103 | |
1104 def test_findscu(self): | |
1105 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1106 j = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
1107 k = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] | |
1108 DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1109 | |
1110 # Test the "find-patient" level | |
1111 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1112 self.assertEqual(1, len(p)) | |
1113 self.assertEqual('ozp00SjY2xG', p[0]['PatientID']) | |
1114 | |
1115 # Test wildcards constraints. The "LO" value representation | |
1116 # for PatientID is always case-sensitive, but the "PN" for | |
1117 # PatientName might depend on the implementation: | |
1118 # "GenerateConfigurationForTests.py" will force it to be case | |
1119 # insensitive (which was the default until Orthanc 0.8.6). | |
1120 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'K*' }) | |
1121 self.assertEqual(1, len(p)) | |
1122 | |
1123 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'k*' }) | |
1124 self.assertEqual(1, len(p)) | |
1125 | |
1126 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'ozp*' }) | |
1127 self.assertEqual(1, len(p)) | |
1128 | |
1129 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'o?p*' }) | |
1130 self.assertEqual(1, len(p)) | |
1131 | |
1132 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : '0?q*' }) | |
1133 self.assertEqual(0, len(p)) | |
1134 | |
1135 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'B*' }) | |
1136 self.assertEqual(0, len(p)) | |
1137 | |
1138 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'b*' }) | |
1139 self.assertEqual(0, len(p)) | |
1140 | |
1141 DoPost(_REMOTE, '/modalities/orthanctest/store', str(j), 'text/plain') | |
1142 DoPost(_REMOTE, '/modalities/orthanctest/store', str(k), 'text/plain') | |
1143 DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1144 self.assertEqual(3, len(DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }))) | |
1145 | |
1146 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'A*' }) | |
1147 self.assertEqual(2, len(p)) | |
1148 | |
1149 # Test the "find-study" level. This is the instance "ColorTestImageJ.dcm" | |
1150 s = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ' }) | |
1151 self.assertEqual(1, len(s)) | |
1152 self.assertEqual('20070208', s[0]['StudyDate']) | |
1153 | |
1154 # Test range searches | |
1155 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1156 'StudyDate' : '-20070101' }) | |
1157 self.assertEqual(0, len(t)) | |
1158 | |
1159 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1160 'StudyDate' : '20090101-' }) | |
1161 self.assertEqual(0, len(t)) | |
1162 | |
1163 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1164 'StudyDate' : '20070101-' }) | |
1165 self.assertEqual(1, len(t)) | |
1166 | |
1167 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1168 'StudyDate' : '-20090101' }) | |
1169 self.assertEqual(1, len(t)) | |
1170 | |
1171 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1172 'StudyDate' : '20070207-20070207' }) | |
1173 self.assertEqual(0, len(t)) | |
1174 | |
1175 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1176 'StudyDate' : '20070208-20070208' }) | |
1177 self.assertEqual(1, len(t)) | |
1178 | |
1179 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1180 'StudyDate' : '20070209-20070209' }) | |
1181 self.assertEqual(0, len(t)) | |
1182 | |
1183 # Test the ModalitiesInStudy tag | |
1184 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1185 'PatientID' : 'B9uTHKOZ', | |
1186 'ModalitiesInStudy' : 'US' }) | |
1187 self.assertEqual(0, len(t)) | |
1188 | |
1189 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1190 'PatientID' : 'B9uTHKOZ', | |
1191 'ModalitiesInStudy' : 'CT' }) | |
1192 self.assertEqual(1, len(t)) | |
1193 | |
1194 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1195 'PatientID' : 'B9uTHKOZ', | |
1196 'ModalitiesInStudy' : 'US\\CT' }) | |
1197 self.assertEqual(1, len(t)) | |
1198 | |
1199 # Test the "find-series" level | |
1200 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1201 'PatientID' : 'B9uTHKOZ', | |
1202 'StudyInstanceUID' : s[0]['StudyInstanceUID'] }) | |
1203 self.assertEqual(1, len(t)) | |
1204 | |
1205 # Test "\" separator | |
1206 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1207 'PatientID' : 'B9uTHKOZ', | |
1208 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1209 'Modality' : 'MR\\CT\\US' }) | |
1210 self.assertEqual(1, len(t)) | |
1211 | |
1212 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1213 'PatientID' : 'B9uTHKOZ', | |
1214 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1215 'Modality' : 'MR\\US' }) | |
1216 self.assertEqual(0, len(t)) | |
1217 | |
1218 | |
1219 def test_update_modalities(self): | |
1220 try: | |
1221 DoDelete(_REMOTE, '/modalities/toto') | |
1222 except: | |
1223 pass | |
1224 try: | |
1225 DoDelete(_REMOTE, '/modalities/tata') | |
1226 except: | |
1227 pass | |
1228 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1229 DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000 ]) | |
1230 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'MedInria' ]) | |
1231 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000, 'MedInriaaa' ])) | |
1232 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/toto')) | |
1233 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/tata')) | |
1234 DoDelete(_REMOTE, '/modalities/toto') | |
1235 DoDelete(_REMOTE, '/modalities/tata') | |
1236 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1237 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/tata')) | |
1238 | |
1239 | |
1240 def test_update_peers(self): | |
1241 # curl -X PUT http://localhost:8042/peers/toto -d '["http://localhost:8042/"]' -v | |
1242 try: | |
1243 DoDelete(_REMOTE, '/peers/toto') | |
1244 except: | |
1245 pass | |
1246 try: | |
1247 DoDelete(_REMOTE, '/peers/tata') | |
1248 except: | |
1249 pass | |
1250 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1251 DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/' ]) | |
1252 DoPut(_REMOTE, '/peers/tata', [ 'http://localhost:8042/', 'user', 'pass' ]) | |
1253 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a' ])) | |
1254 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a', 'b', 'c' ])) | |
1255 self.assertTrue('store' in DoGet(_REMOTE, '/peers/toto')) | |
1256 self.assertTrue('store' in DoGet(_REMOTE, '/peers/tata')) | |
1257 DoDelete(_REMOTE, '/peers/toto') | |
1258 DoDelete(_REMOTE, '/peers/tata') | |
1259 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1260 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/tata')) | |
1261 | |
1262 | |
1263 def test_mesterhazy_modification(self): | |
1264 # When I modify a series ( eg. curl | |
1265 # http://localhost:8042/series/uidhere/modify -X POST -d | |
1266 # '{"Replace":{"SeriesDate":"19990101"}}' ) the modified | |
1267 # series is added to a new Study, instead of the existing | |
1268 # Study. Fixed in Orthanc 0.7.5 | |
1269 | |
1270 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1271 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1272 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1273 | |
1274 modified = DoPost(_REMOTE, '/series/%s/modify' % series, | |
1275 json.dumps({ "Replace" : { "SeriesDate" : "19990101" }})) | |
1276 | |
1277 self.assertEqual(study, DoGet(_REMOTE, '/series/%s' % modified['ID']) ['ParentStudy']) | |
1278 | |
1279 | |
1280 def test_create(self): | |
1281 i = DoPost(_REMOTE, '/tools/create-dicom', | |
1282 json.dumps({ | |
1283 'PatientName' : 'Jodogne', | |
1284 'Modality' : 'CT', | |
58 | 1285 'SOPClassUID' : '1.2.840.10008.5.1.4.1.1.1', |
13 | 1286 'PixelData' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' # red dot in RGBA |
1287 })) | |
1288 | |
1289 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
1290 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
1291 | |
1292 png = GetImage(_REMOTE, '/instances/%s/preview' % i['ID']) | |
1293 self.assertEqual((5, 5), png.size) | |
1294 | |
38 | 1295 j = DoGet(_REMOTE, i['Path']) |
1296 self.assertEqual('Instance', j['Type']) | |
1297 self.assertEqual(j['ID'], i['ID']) | |
1298 | |
13 | 1299 |
1300 def test_pilates(self): | |
1301 # "SCU failed error when accessing orthanc with osirix" by | |
1302 # Pilates Agentur (Mar 10, 2014 at 9:33 PM) | |
1303 i = UploadInstance(_REMOTE, 'PilatesArgenturGEUltrasoundOsiriX.dcm')['ID'] | |
1304 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
1305 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1306 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
1307 | |
1308 | |
1309 def test_shared_tags(self): | |
1310 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1311 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm')['ID'] | |
1312 p = DoGet(_REMOTE, '/patients')[0] | |
1313 | |
1314 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1315 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1316 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1317 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1318 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1319 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1320 self.assertFalse('0008,0018' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1321 self.assertFalse('SOPInstanceUID' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1322 | |
1323 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/tags' % a)) | |
1324 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)) | |
1325 | |
1326 | |
1327 def test_modules(self): | |
1328 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1329 p = DoGet(_REMOTE, '/patients')[0] | |
1330 s = DoGet(_REMOTE, '/studies')[0] | |
1331 t = DoGet(_REMOTE, '/series')[0] | |
1332 | |
1333 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/module' % p)) | |
1334 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/module?simplify' % p)) | |
1335 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/studies/%s/module-patient' % p)) | |
1336 self.assertTrue('PatientName' in DoGet(_REMOTE, '/studies/%s/module-patient?simplify' % p)) | |
1337 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/studies/%s/module' % s)) | |
1338 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/studies/%s/module?simplify' % s)) | |
1339 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/series/%s/module' % p)) | |
1340 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/series/%s/module?simplify' % p)) | |
1341 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/module' % a)) | |
1342 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/module?simplify' % a)) | |
1343 | |
1344 | |
1345 def test_auto_directory(self): | |
1346 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1347 self.assertTrue('now' in DoGet(_REMOTE, '/tools')) | |
1348 self.assertTrue('dicom-conformance' in DoGet(_REMOTE, '/tools')) | |
1349 self.assertTrue(len(DoGet(_REMOTE, '/tools/dicom-conformance')) > 1000) | |
1350 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
1351 self.assertTrue('echo' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1352 self.assertTrue('find' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1353 self.assertTrue('find-instance' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1354 self.assertTrue('find-patient' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1355 self.assertTrue('find-series' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1356 self.assertTrue('find-study' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1357 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1358 self.assertTrue('store' in DoGet(_REMOTE, '/peers/peer')) | |
1359 self.assertTrue('matlab' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) | |
1360 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/tools/nope')) | |
28 | 1361 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope')) |
1362 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope/nope.html')) | |
1363 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope')[0].status) | |
1364 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope/nope.html')[0].status) | |
13 | 1365 |
1366 | |
1367 def test_echo(self): | |
1368 DoPost(_REMOTE, '/modalities/orthanctest/echo') | |
1369 | |
1370 | |
1371 def test_xml(self): | |
1372 json = DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/json' }) | |
1373 xml = minidom.parseString(DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/xml' })) | |
1374 items = xml.getElementsByTagName('root')[0].getElementsByTagName('item') | |
1375 self.assertEqual(len(items), len(json)) | |
1376 | |
1377 self.assertTrue('dicom-conformance' in json) | |
1378 | |
1379 ok = False | |
1380 for i in items: | |
1381 if i.childNodes[0].data == 'dicom-conformance': | |
1382 ok = True | |
1383 self.assertTrue(ok) | |
1384 | |
1385 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1386 def test_googlecode_issue_16(self): |
13 | 1387 i = UploadInstance(_REMOTE, 'Issue16.dcm')['ID'] |
1388 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['FrameIncrementPointer'] | |
1389 self.assertEqual('0018,1063', t) | |
1390 | |
1391 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1392 def test_googlecode_issue_22(self): |
13 | 1393 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] |
1394 a = [ | |
1395 "f804691f62197040438f4627c6b994f1", # Frame 0 | |
1396 "c69eee9a51eea3e8611e82e578897254", | |
1397 "315666be83e2d0111c77bc0996d84901", | |
1398 "3e27aa959d911172c48a1436443c72b1", | |
1399 "958642c9e7e9d232d3869faff546058c", | |
1400 "5e7ea8e3e4230cae707d143481355c59", | |
1401 "eda37f83558d858a596175aed8b2ad47", | |
1402 "486713bd2895c4ecbe0e97715ac7f80a", | |
1403 "091ef729eb169e67da8a0faa9631f9a8", | |
1404 "5aa2b8c7ffe0a483efaa8e12417686ca", | |
1405 "e2f39e85896fe58876654b94cd0b5013", | |
1406 "6fd2129e4950abbe1be053bc814d5da8", | |
1407 "c3331a8ba7a757f3d423735ab7fa81f9", | |
1408 "746f808582156734dd6b6fdfd3a0b72c", | |
1409 "8075ea2b227a70c60ea6b7b75a6bb190", | |
1410 "806b8b3e300c615099c11a5ec23465aa", | |
1411 "7c836aa298ba6eef96434579af631a11", | |
1412 "a0357dc9f4f72d73a885c33d7c287446", | |
1413 "f25ba3be1cc7d7fad95706adc199ea7d", | |
1414 "8b114c526b8cbed6cad8a3248b7b480c", | |
1415 "44e6670f127e612a2b4aa60a0d207698", | |
1416 "b8945f90fe02facf2ace24ca1ecbe0a5", | |
1417 "95c796c2fa8f59018b15cf2987b1f79b", | |
1418 "ce0a51ab30224205b44920221dc27351", # Frame 23 | |
1419 ] | |
1420 | |
1421 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
1422 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/preview' % s)) | |
1423 | |
1424 for i in range(len(a)): | |
1425 self.assertEqual(a[i], ComputeMD5(DoGet(_REMOTE, '/instances/%s/frames/%d/preview' % (s, i)))) | |
1426 | |
1427 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1428 def test_googlecode_issue_19(self): |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1429 # This is an image with "YBR_FULL" photometric interpretation, it is not supported by Orthanc |
13 | 1430 # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm |
1431 | |
1432 a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID'] | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1433 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) |
13 | 1434 |
1435 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1436 def test_googlecode_issue_37(self): |
13 | 1437 # Same test for issues 35 and 37. Fixed in Orthanc 0.9.1 |
1438 u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] | |
1439 | |
1440 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1441 'CaseSensitive' : True, | |
1442 'Query' : { 'StationName' : 'SMR4-MP3' }}) | |
1443 self.assertEqual(1, len(a)) | |
14 | 1444 |
1445 | |
1446 def test_rest_find(self): | |
1447 # Upload 8 instances | |
1448 for i in range(2): | |
1449 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1450 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1451 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1452 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1453 | |
1454 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1455 'CaseSensitive' : False, | |
1456 'Query' : { 'PatientName' : '*n*' }}) | |
1457 self.assertEqual(2, len(a)) | |
1458 | |
1459 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1460 'CaseSensitive' : True, | |
1461 'Query' : { 'PatientName' : '*n*' }}) | |
1462 self.assertEqual(0, len(a)) | |
1463 | |
1464 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, | |
1465 'Level' : 'Patient', | |
1466 'CaseSensitive' : False, | |
1467 'Query' : { 'PatientName' : '*ne*' }}) | |
1468 self.assertEqual(1, len(a)) | |
1469 self.assertEqual('20080822', a[0]['MainDicomTags']['PatientBirthDate']) | |
1470 | |
1471 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1472 'CaseSensitive' : True, | |
1473 'Query' : { 'PatientName' : '*ne*' }}) | |
1474 self.assertEqual(0, len(a)) | |
1475 | |
1476 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', | |
1477 'CaseSensitive' : True, | |
1478 'Query' : { 'PatientName' : '*NE*' }}) | |
1479 self.assertEqual(1, len(a)) | |
1480 | |
1481 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1482 'CaseSensitive' : True, | |
1483 'Query' : { 'PatientName' : '*NE*' }}) | |
1484 self.assertEqual(2, len(a)) | |
1485 | |
1486 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
1487 'CaseSensitive' : True, | |
1488 'Query' : { 'PatientName' : '*NE*' }}) | |
1489 self.assertEqual(4, len(a)) | |
1490 | |
1491 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', 'Query' : { }}) | |
1492 self.assertEqual(2, len(a)) | |
1493 | |
1494 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', 'Query' : { }}) | |
1495 self.assertEqual(2, len(a)) | |
1496 | |
1497 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', 'Query' : { }}) | |
1498 self.assertEqual(4, len(a)) | |
1499 | |
1500 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', 'Query' : { }}) | |
1501 self.assertEqual(8, len(a)) | |
1502 | |
1503 | |
1504 def test_rest_query_retrieve(self): | |
1505 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1506 | |
1507 # Upload 8 instances | |
1508 for i in range(2): | |
1509 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1510 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1511 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1512 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1513 | |
1514 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1515 for p in DoGet(_REMOTE, '/patients'): | |
1516 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
1517 DoDelete(_REMOTE, '/patients/%s' % p) | |
1518 | |
1519 for q in DoGet(_REMOTE, '/queries'): | |
1520 DoDelete(_REMOTE, '/queries/%s' % q) | |
1521 | |
1522 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1523 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1524 a = DoPost(_REMOTE, '/modalities/orthanctest/query', { 'Level' : 'Series', | |
27 | 1525 'Query' : { |
1526 'PatientName' : '*NE*', | |
1527 'StudyDate' : '*', | |
1528 }})['ID'] | |
14 | 1529 self.assertEqual(1, len(DoGet(_REMOTE, '/queries'))) |
1530 | |
1531 b = DoGet(_REMOTE, '/queries/%s' % a) | |
1532 self.assertTrue('answers' in b) | |
1533 self.assertTrue('level' in b) | |
1534 self.assertTrue('modality' in b) | |
1535 self.assertTrue('query' in b) | |
1536 self.assertTrue('retrieve' in b) | |
1537 self.assertEqual('Series', DoGet(_REMOTE, '/queries/%s/level' % a)) | |
1538 self.assertEqual('orthanctest', DoGet(_REMOTE, '/queries/%s/modality' % a)) | |
1539 | |
1540 q = DoGet(_REMOTE, '/queries/%s/query?simplify' % a) | |
27 | 1541 self.assertEqual(2, len(q)) |
14 | 1542 self.assertTrue('PatientName' in q) |
27 | 1543 self.assertTrue('StudyDate' in q) |
14 | 1544 self.assertEqual('*NE*', q['PatientName']) |
27 | 1545 self.assertEqual('*', q['StudyDate']) |
14 | 1546 |
1547 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) | |
1548 | |
1549 s = DoGet(_REMOTE, '/queries/%s/answers/0' % a) | |
1550 self.assertTrue('content' in s) | |
1551 self.assertTrue('retrieve' in s) | |
1552 | |
1553 s = DoGet(_REMOTE, '/queries/%s/answers/0/content?simplify' % a) | |
1554 self.assertEqual('887', s['PatientID']) | |
1555 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s['StudyInstanceUID']) | |
1556 | |
1557 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1558 DoPost(_REMOTE, '/queries/%s/answers/0/retrieve' % a, 'ORTHANC') | |
1559 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1560 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1561 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
1562 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
1563 | |
1564 DoPost(_REMOTE, '/queries/%s/answers/1/retrieve' % a, 'ORTHANC') | |
1565 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1566 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1567 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1568 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
1569 | |
1570 DoDelete(_REMOTE, '/queries/%s' % a) | |
1571 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1572 | |
1573 | |
1574 def test_parent(self): | |
1575 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1576 patient = '6816cb19-844d5aee-85245eba-28e841e6-2414fae2' | |
1577 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1578 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1579 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
1580 self.assertEqual(instance, u); | |
1581 | |
1582 a = DoGet(_REMOTE, '/studies/%s/patient' % study) | |
1583 self.assertEqual('Patient', a['Type']) | |
1584 self.assertEqual(patient, a['ID']) | |
1585 | |
1586 a = DoGet(_REMOTE, '/series/%s/patient' % series) | |
1587 self.assertEqual('Patient', a['Type']) | |
1588 self.assertEqual(patient, a['ID']) | |
1589 | |
1590 a = DoGet(_REMOTE, '/series/%s/study' % series) | |
1591 self.assertEqual('Study', a['Type']) | |
1592 self.assertEqual(study, a['ID']) | |
1593 | |
1594 a = DoGet(_REMOTE, '/instances/%s/patient' % instance) | |
1595 self.assertEqual('Patient', a['Type']) | |
1596 self.assertEqual(patient, a['ID']) | |
1597 | |
1598 a = DoGet(_REMOTE, '/instances/%s/study' % instance) | |
1599 self.assertEqual('Study', a['Type']) | |
1600 self.assertEqual(study, a['ID']) | |
1601 | |
1602 a = DoGet(_REMOTE, '/instances/%s/series' % instance) | |
1603 self.assertEqual('Series', a['Type']) | |
1604 self.assertEqual(series, a['ID']) | |
1605 | |
1606 | |
1607 def test_shanon(self): | |
1608 def Anonymize(instance, replacements = {}): | |
1609 return DoPost(_REMOTE, '/instances/%s/anonymize' % instance, { 'Replace' : replacements }, 'application/json') | |
1610 | |
1611 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1612 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1613 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1614 | |
1615 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1616 ids = [ 'ozp00SjY2xG', | |
1617 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1618 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1619 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1620 | |
1621 a = ExtractDicomTags(Anonymize(u), tags) | |
1622 for i in range(4): | |
1623 self.assertNotEqual(ids[i], a[i]) | |
1624 self.assertTrue(a[4].startswith('Orthanc')) | |
1625 | |
1626 a = ExtractDicomTags(Anonymize(u, { 'PatientName' : 'toto' }), tags) | |
1627 for i in range(4): | |
1628 self.assertNotEqual(ids[i], a[i]) | |
1629 self.assertFalse(a[4].startswith('Orthanc')) | |
1630 | |
1631 a = ExtractDicomTags(Anonymize(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1632 self.assertEqual('instance', a[3]) | |
1633 self.assertFalse(a[4].startswith('Orthanc')) | |
1634 | |
1635 a = ExtractDicomTags(Anonymize(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1636 self.assertEqual('series', a[2]) | |
1637 self.assertFalse(a[4].startswith('Orthanc')) | |
1638 | |
1639 a = ExtractDicomTags(Anonymize(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1640 self.assertEqual('study', a[1]) | |
1641 self.assertFalse(a[4].startswith('Orthanc')) | |
1642 | |
1643 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient' }), tags) | |
1644 self.assertEqual('patient', a[0]) | |
1645 self.assertFalse(a[4].startswith('Orthanc')) | |
1646 | |
1647 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient', | |
1648 'StudyInstanceUID' : 'study', | |
1649 'SeriesInstanceUID' : 'series', | |
1650 'SOPInstanceUID' : 'instance' }), tags) | |
1651 self.assertEqual('patient', a[0]) | |
1652 self.assertFalse(a[4].startswith('Orthanc')) | |
1653 | |
1654 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1655 | |
1656 | |
1657 def test_shanon_2(self): | |
1658 def Modify(instance, replacements = {}): | |
1659 return DoPost(_REMOTE, '/instances/%s/modify' % instance, { 'Replace' : replacements }, 'application/json') | |
1660 | |
1661 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1662 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1663 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1664 | |
1665 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1666 ids = [ 'ozp00SjY2xG', | |
1667 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1668 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1669 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1670 | |
1671 a = ExtractDicomTags(Modify(u), tags) | |
1672 self.assertEqual(ids[0], a[0]) | |
1673 self.assertEqual(ids[1], a[1]) | |
1674 self.assertEqual(ids[2], a[2]) | |
1675 self.assertNotEqual(ids[3], a[3]) | |
1676 self.assertEqual(0, len(a[4])) | |
1677 | |
1678 a = ExtractDicomTags(Modify(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1679 self.assertEqual(ids[0], a[0]) | |
1680 self.assertEqual(ids[1], a[1]) | |
1681 self.assertEqual(ids[2], a[2]) | |
1682 self.assertEqual('instance', a[3]) | |
1683 | |
1684 a = ExtractDicomTags(Modify(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1685 self.assertEqual(ids[0], a[0]) | |
1686 self.assertEqual(ids[1], a[1]) | |
1687 self.assertEqual('series', a[2]) | |
1688 self.assertNotEqual(ids[3], a[3]) | |
1689 | |
1690 a = ExtractDicomTags(Modify(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1691 self.assertEqual(ids[0], a[0]) | |
1692 self.assertEqual('study', a[1]) | |
1693 self.assertNotEqual(ids[2], a[2]) | |
1694 self.assertNotEqual(ids[3], a[3]) | |
1695 | |
1696 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient' }), tags) | |
1697 self.assertEqual('patient', a[0]) | |
1698 self.assertNotEqual(ids[1], a[1]) | |
1699 self.assertNotEqual(ids[2], a[2]) | |
1700 self.assertNotEqual(ids[3], a[3]) | |
1701 | |
1702 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient', | |
1703 'StudyInstanceUID' : 'study', | |
1704 'SeriesInstanceUID' : 'series', | |
1705 'SOPInstanceUID' : 'instance' }), tags) | |
1706 self.assertEqual('patient', a[0]) | |
1707 self.assertEqual('study', a[1]) | |
1708 self.assertEqual('series', a[2]) | |
1709 self.assertEqual('instance', a[3]) | |
1710 | |
1711 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1712 | |
1713 | |
1714 def test_instances_tags(self): | |
1715 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1716 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] | |
1717 #a = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386937.676343')['ID'] | |
1718 #b = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386925.676329')['ID'] | |
1719 | |
1720 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/patients')[0]) | |
1721 self.assertEqual(2, len(i)) | |
1722 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1723 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1724 | |
1725 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/studies')[0]) | |
1726 self.assertEqual(2, len(i)) | |
1727 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1728 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1729 | |
1730 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1731 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[0]) | |
1732 self.assertEqual(1, len(i)) | |
1733 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1734 | |
1735 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[1]) | |
1736 self.assertEqual(1, len(i)) | |
1737 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1738 | |
1739 | |
1740 def test_lookup(self): | |
1741 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
1742 self.assertEqual(0, len(a)) | |
1743 | |
1744 UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1745 | |
1746 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
1747 self.assertEqual(1, len(a)) | |
1748 self.assertEqual('Patient', a[0]['Type']) | |
1749 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', a[0]['ID']) | |
1750 self.assertEqual('/patients/%s' % a[0]['ID'], a[0]['Path']) | |
1751 | |
1752 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390') | |
1753 self.assertEqual(1, len(a)) | |
1754 self.assertEqual('Study', a[0]['Type']) | |
1755 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', a[0]['ID']) | |
1756 self.assertEqual('/studies/%s' % a[0]['ID'], a[0]['Path']) | |
1757 | |
1758 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394') | |
1759 self.assertEqual(1, len(a)) | |
1760 self.assertEqual('Series', a[0]['Type']) | |
1761 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', a[0]['ID']) | |
1762 self.assertEqual('/series/%s' % a[0]['ID'], a[0]['Path']) | |
1763 | |
1764 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109') | |
1765 self.assertEqual(1, len(a)) | |
1766 self.assertEqual('Instance', a[0]['Type']) | |
1767 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a[0]['ID']) | |
1768 self.assertEqual('/instances/%s' % a[0]['ID'], a[0]['Path']) | |
1769 | |
1770 DropOrthanc(_REMOTE) | |
1771 a = DoPost(_REMOTE, '/tools/lookup', '3113719P') | |
1772 self.assertEqual(0, len(a)) | |
1773 | |
15 | 1774 |
1775 def test_autorouting(self): | |
1776 knee1 = 'Knee/T1/IM-0001-0001.dcm' | |
1777 knee2 = 'Knee/T2/IM-0001-0002.dcm' | |
1778 other = 'Brainix/Flair/IM-0001-0001.dcm' | |
1779 | |
1780 # Check that this version is >= 0.8.0 | |
1781 self.assertTrue(IsDefinedInLua(_REMOTE, '_InitializeJob')) | |
1782 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
1783 | |
1784 UploadInstance(_REMOTE, knee1) | |
1785 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
1786 | |
1787 DropOrthanc(_REMOTE) | |
1788 DropOrthanc(_LOCAL) | |
1789 InstallLuaScript('Lua/Autorouting.lua') | |
1790 UploadInstance(_REMOTE, knee1) | |
1791 UploadInstance(_REMOTE, knee2) | |
1792 UploadInstance(_REMOTE, other) | |
1793 WaitEmpty(_REMOTE) | |
1794 UninstallLuaCallbacks() | |
1795 self.assertEqual(3, len(DoGet(_LOCAL, '/instances'))) | |
1796 | |
1797 DropOrthanc(_REMOTE) | |
1798 DropOrthanc(_LOCAL) | |
1799 InstallLuaScript('Lua/AutoroutingConditional.lua') | |
1800 UploadInstance(_REMOTE, knee1) | |
1801 UploadInstance(_REMOTE, knee2) | |
1802 UploadInstance(_REMOTE, other) | |
1803 WaitEmpty(_REMOTE) | |
1804 UninstallLuaCallbacks() | |
1805 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
1806 | |
1807 DropOrthanc(_REMOTE) | |
1808 DropOrthanc(_LOCAL) | |
1809 InstallLuaScript('Lua/AutoroutingModification.lua') | |
1810 UploadInstance(_REMOTE, knee1) | |
1811 WaitEmpty(_REMOTE) | |
1812 UninstallLuaCallbacks() | |
1813 i = DoGet(_LOCAL, '/instances') | |
1814 self.assertEqual(1, len(i)) | |
1815 | |
1816 with tempfile.NamedTemporaryFile(delete = True) as f: | |
1817 f.write(DoGet(_LOCAL, '/instances/%s/file' % i[0])) | |
1818 f.flush() | |
45 | 1819 routed = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
15 | 1820 self.assertEqual('My Medical Device', re.search('"StationName">(.*?)<', routed).group(1).strip()) |
1821 self.assertEqual(None, re.search('"MilitaryRank"', routed)) | |
1822 self.assertEqual(None, re.search('"0051,0010"', routed)) # A private tag | |
17 | 1823 |
1824 | |
1825 def test_storescu_rf(self): | |
1826 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] | |
1827 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
1828 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1829 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
18 | 1830 |
1831 | |
1832 def test_anonymize_instance(self): | |
1833 def AnonymizeAndUpload(instanceId, parameters): | |
1834 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/anonymize' % instanceId, parameters, | |
1835 'application/json'), 'application/dicom')['ID'] | |
1836 | |
1837 def ModifyAndUpload(instanceId, parameters): | |
1838 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/modify' % instanceId, parameters, | |
1839 'application/json'), 'application/dicom')['ID'] | |
1840 | |
1841 a = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
1842 s1 = DoGet(_REMOTE, '/instances/%s/content/PatientName' % a) | |
1843 s2 = DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % a) # Some private tag | |
1844 s3 = DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % a) | |
1845 s4 = DoGet(_REMOTE, '/instances/%s/content/SeriesDescription' % a) | |
1846 s5 = DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
1847 | |
1848 b = AnonymizeAndUpload(a, '{}') | |
1849 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
1850 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1851 | |
1852 # Keep private tag (only OK since Orthanc 0.8.0) | |
1853 b = AnonymizeAndUpload(a, '{"Keep":["00e1-10c2"]}') | |
1854 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
1855 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1856 | |
1857 b = AnonymizeAndUpload(a, '{"Keep":["00e1,10c2","PatientName"]}') | |
1858 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
1859 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1860 | |
1861 b = AnonymizeAndUpload(a, '{"Keep":["PatientName"],"Replace":{"00e1,10c2":"Hello"}}') | |
1862 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
1863 self.assertTrue(DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b).startswith('Hello')) | |
1864 | |
1865 # Examples from the Wiki | |
1866 b = AnonymizeAndUpload(a, '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": null}') | |
1867 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) | |
1868 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
1869 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
1870 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
1871 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
1872 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1873 DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
1874 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
1875 | |
1876 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Remove":["InstitutionName"],"RemovePrivateTags": null}') | |
1877 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) | |
1878 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
1879 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
1880 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
1881 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1882 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
1883 | |
1884 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"}}') | |
1885 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) | |
1886 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
1887 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1,10c2' % b)) | |
1888 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
1889 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
1890 self.assertEqual(s5, DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
1891 | |
1892 | |
1893 # Test modify non-existing | |
1894 i = DoPost(_REMOTE, '/tools/create-dicom', | |
1895 json.dumps({ | |
1896 'PatientName' : 'Jodogne', | |
1897 'Modality' : 'CT', | |
1898 }))['ID'] | |
1899 | |
1900 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i).strip()) | |
1901 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % i)) | |
1902 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i).strip()) | |
1903 | |
1904 b = ModifyAndUpload(i, '{"Replace":{"StudyDescription":"hello","Modality":"world"}}') | |
1905 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % b).strip()) | |
1906 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % b).strip()) | |
1907 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/Modality' % b).strip()) | |
1908 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1909 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1910 def test_incoming_jpeg(self): |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1911 def storescu(image, acceptUnknownSopClassUid): |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1912 if acceptUnknownSopClassUid: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1913 tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1914 else: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1915 tmp = [ '-xs' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1916 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1917 with open(os.devnull, 'w') as FNULL: |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1918 subprocess.check_call([ FindExecutable('storescu') ] + tmp + |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1919 [ _REMOTE['Server'], str(_REMOTE['DicomPort']), |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1920 GetDatabasePath(image) ], |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1921 stderr = FNULL) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1922 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1923 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1924 InstallLuaScript('Lua/TransferSyntaxDisable.lua') |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1925 self.assertRaises(Exception, lambda: storescu('Knix/Loc/IM-0001-0001.dcm', False)) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1926 self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True)) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1927 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1928 InstallLuaScript('Lua/TransferSyntaxEnable.lua') |
62
f9c4ce95756f
removal of useless information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
61
diff
changeset
|
1929 DoPost(_REMOTE, '/tools/execute-script', "print('All special transfer syntaxes are now accepted')") |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1930 storescu('Knix/Loc/IM-0001-0001.dcm', False) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1931 storescu('UnknownSopClassUid.dcm', True) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1932 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1933 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1934 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1935 def test_storescu_jpeg(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1936 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1937 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1938 knixStudy = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
64 | 1939 i = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
1940 | |
1941 # This is JPEG lossless | |
1942 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) | |
1943 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1944 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0002.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1945 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0003.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1946 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1947 a = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1948 b = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1949 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1950 DoPost(_REMOTE, '/modalities/orthanctest/store', [ knixStudy, a, b ]) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1951 self.assertEqual(5, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1952 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1953 self.assertEqual(3, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1954 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1955 DropOrthanc(_REMOTE) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1956 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1957 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1958 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1959 def test_pixel_data(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1960 jpeg = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1961 color = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1962 phenix = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1963 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1964 phenixSize = 358 * 512 * 2 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1965 colorSize = 1000 * 1000 * 3 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1966 jpegSize = 51918 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1967 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1968 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010' % phenix))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1969 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1970 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010' % jpeg))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1971 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1972 self.assertEqual(0, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/0' % jpeg))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1973 self.assertEqual(jpegSize, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/1' % jpeg))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1974 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1975 self.assertEqual(phenixSize, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/0' % phenix))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1976 self.assertEqual(colorSize, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/0' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1977 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1978 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1979 def test_decode_brainix(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1980 brainix = [ |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1981 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'], # (*) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1982 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm')['ID'], # JPEG-LS, same as (*) (since Orthanc 0.7.6) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1983 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm')['ID'], # JPEG, same as (*) (since Orthanc 0.7.6) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1984 ] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1985 h = '6fb11b932d535c2be04beabd99793ff8' |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1986 maxValue = 426.0 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1987 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1988 truth = Image.open(GetDatabasePath('Formats/Brainix.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1989 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1990 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1991 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1992 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1993 truth2 = map(lambda x: min(255, x), truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1994 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1995 self.AssertSameImages(truth2, '/instances/%s/image-uint8' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1996 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1997 truth2 = map(lambda x: x * 255.0 / maxValue, truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1998 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1999 self.AssertSameImages(truth2, '/instances/%s/preview' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2000 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2001 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2002 self.assertEqual(h, ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % i))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2003 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2004 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2005 def test_decode_color(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2006 imagej = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2007 color = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2008 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2009 for i in [ imagej, color ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2010 for j in [ 'image-uint8', 'image-uint16', 'image-int16' ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2011 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/%s' % (i, j))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2012 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2013 self.assertEqual('c14c687f7a1ea9fe022479fc87c67274', ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % imagej))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2014 self.assertEqual('a87d122918a56f803bcfe9d2586b9125', ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2015 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2016 self.assertEqual('30cc46bfa7aba77a40e4178f6184c25a', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % imagej))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2017 self.assertEqual('ff195005cef06b59666fd220a9b4cd9a', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2018 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2019 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2020 def test_decode_rf(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2021 rf = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2022 truth = Image.open(GetDatabasePath('Formats/KarstenHilbertRF.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2023 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2024 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2025 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2026 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2027 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2028 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2029 self.assertEqual('42254d70efd2f4a1b8f3455909689f0e', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % rf))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2030 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2031 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2032 def test_decode_multiframe(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2033 mf = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2034 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2035 # Test the first frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2036 truth = Image.open(GetDatabasePath('Formats/Multiframe0.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2037 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2038 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2039 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2040 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2041 self.assertEqual('9812b99d93bbcd4e7684ded089b5dfb3', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % mf))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2042 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2043 self.AssertSameImages(truth.getdata(), '/instances/%s/frames/0/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2044 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2045 # Test the last frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2046 truth = Image.open(GetDatabasePath('Formats/Multiframe75.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2047 self.AssertSameImages(truth.getdata(), '/instances/%s/frames/75/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2048 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2049 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2050 def test_decode_signed(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2051 signed = UploadInstance(_REMOTE, 'SignedCT.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2052 minValue = -2000 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2053 maxValue = 4042 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2054 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2055 truth = Image.open(GetDatabasePath('Formats/SignedCT.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2056 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2057 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2058 truth2 = map(lambda x: 0 if x >= 32768 else x, truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2059 self.AssertSameImages(truth2, '/instances/%s/image-uint16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2060 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2061 truth3 = map(lambda x: 255 if x >= 256 else x, truth2) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2062 self.AssertSameImages(truth3, '/instances/%s/image-uint8' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2063 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2064 tmp = map(lambda x: x - 65536 if x >= 32768 else x, truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2065 tmp = map(lambda x: (255.0 * (x - minValue)) / (maxValue - minValue), tmp) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2066 self.AssertSameImages(tmp, '/instances/%s/preview' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2067 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2068 self.assertEqual('b57e6c872a3da50877c7da689b03a444', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % signed))) |
22 | 2069 |
2070 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
2071 def test_googlecode_issue_32(self): |
22 | 2072 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
2073 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) | |
2074 self.assertEqual(u'Рентгенография', tags['SeriesDescription']) | |
2075 self.assertEqual(u'Таз', tags['BodyPartExamined']) | |
2076 self.assertEqual(u'Прямая', tags['ViewPosition']) | |
2077 | |
2078 | |
2079 def test_encodings(self): | |
23 | 2080 # Latin-1 (ISO_IR 100) |
22 | 2081 brainix = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2082 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % brainix) | |
2083 self.assertEqual(u'IRM cérébrale, neuro-crâne', tags['StudyDescription']) | |
23 | 2084 |
2085 # Latin-2 (ISO_IR 101) | |
2086 a = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] | |
2087 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % a) | |
2088 # dcm2xml MarekLatin2.dcm | iconv -f latin2 -t utf-8 | xmllint --format - | |
2089 self.assertEqual('Imię i Nazwisko osoby opisującej', | |
2090 i['ContentSequence'][4]['ConceptNameCodeSequence'][0]['CodeMeaning'].encode('utf-8')) | |
2091 | |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2092 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2093 def test_storescu_custom_aet(self): |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2094 # This tests a feature introduced in Orthanc 0.9.1: "Custom |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2095 # setting of the local AET during C-Store SCU (both in Lua and |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2096 # in the REST API)." |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2097 # https://groups.google.com/forum/#!msg/orthanc-users/o5qMULformU/wZjW2iSaMcAJ |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2098 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2099 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2100 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2101 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2102 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2103 c = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0003.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2104 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2105 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2106 'LocalAet' : 'YOP', |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2107 'Resources' : [ a['ID'], b['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2108 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2109 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2110 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2111 self.assertEqual('YOP', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % a['ID'])) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2112 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2113 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2114 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2115 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2116 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2117 'Resources' : [ c['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2118 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2119 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2120 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2121 self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % c['ID'])) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2122 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2123 DropOrthanc(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2124 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2125 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2126 InstallLuaScript('Lua/AutoroutingChangeAet.lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2127 DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2128 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2129 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2130 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2131 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2132 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2133 self.assertEqual('HELLO', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % a['ID'])) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2134 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2135 DoPost(_REMOTE, '/tools/execute-script', 'aet = nill', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2136 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2137 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2138 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2139 self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % b['ID'])) |
34
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2140 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2141 def test_resources_since_limit(self): |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2142 # Upload 16 instances |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2143 for i in range(4): |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2144 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2145 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2146 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2147 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2148 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2149 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2150 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2151 self.assertEqual(4, len(DoGet(_REMOTE, '/series'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2152 self.assertEqual(16, len(DoGet(_REMOTE, '/instances'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2153 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2154 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/patients&since=10' % i)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2155 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/patients&limit=10' % i)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2156 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2157 self.assertEqual(0, len(DoGet(_REMOTE, '/patients?since=0&limit=0'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2158 self.assertEqual(2, len(DoGet(_REMOTE, '/patients?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2159 self.assertEqual(2, len(DoGet(_REMOTE, '/studies?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2160 self.assertEqual(4, len(DoGet(_REMOTE, '/series?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2161 self.assertEqual(16, len(DoGet(_REMOTE, '/instances?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2162 self.assertEqual(1, len(DoGet(_REMOTE, '/patients?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2163 self.assertEqual(0, len(DoGet(_REMOTE, '/patients?since=2&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2164 self.assertEqual(0, len(DoGet(_REMOTE, '/patients?since=3&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2165 self.assertEqual(1, len(DoGet(_REMOTE, '/studies?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2166 self.assertEqual(3, len(DoGet(_REMOTE, '/series?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2167 self.assertEqual(2, len(DoGet(_REMOTE, '/series?since=2&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2168 self.assertEqual(1, len(DoGet(_REMOTE, '/series?since=3&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2169 self.assertEqual(0, len(DoGet(_REMOTE, '/series?since=4&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2170 self.assertEqual(0, len(DoGet(_REMOTE, '/series?since=100&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2171 self.assertEqual(15, len(DoGet(_REMOTE, '/instances?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2172 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2173 for limit in [ 1, 2, 3, 7, 16, 17 ]: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2174 s = {} |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2175 since = 0 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2176 while True: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2177 t = DoGet(_REMOTE, '/instances?since=%d&limit=%d' % (since, limit)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2178 if len(t) == 0: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2179 break |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2180 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2181 since += len(t) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2182 for i in t: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2183 s[i] = None |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2184 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2185 self.assertEqual(16, len(s)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2186 for instance in DoGet(_REMOTE, '/instances'): |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2187 self.assertTrue(instance in s) |
36 | 2188 |
2189 | |
2190 def test_create_pdf(self): | |
2191 # Upload 4 instances | |
2192 brainixInstance = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
2193 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2194 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2195 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2196 | |
2197 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
2198 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
2199 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
2200 | |
2201 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: | |
2202 pdf = f.read() | |
2203 | |
2204 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2205 json.dumps({ | |
2206 'Tags' : { | |
2207 'PatientName' : 'Jodogne', | |
2208 'Modality' : 'CT', | |
2209 }, | |
2210 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2211 })) | |
2212 | |
2213 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2214 self.assertEqual('OT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
2215 | |
2216 b = DoGet(_REMOTE, '/instances/%s/content/0042-0011' % i['ID']) | |
2217 self.assertEqual(len(b), len(pdf) + 1) | |
2218 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf + '\0')) | |
2219 | |
2220 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/tools/create-dicom', | |
2221 json.dumps({ | |
2222 'Parent' : brainixPatient, | |
2223 'Tags' : { | |
2224 'PatientName' : 'Jodogne', | |
2225 } | |
2226 }))) | |
2227 | |
2228 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2229 json.dumps({ | |
2230 'Parent' : brainixPatient, | |
2231 'Tags' : { 'StudyDescription' : 'PDF^Patient' }, | |
2232 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2233 })) | |
2234 | |
2235 self.assertEqual(brainixPatient, DoGet(_REMOTE, '/instances/%s/patient' % i['ID'])['ID']) | |
2236 | |
2237 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2238 json.dumps({ | |
2239 'Parent' : brainixStudy, | |
2240 'Tags' : { 'SeriesDescription' : 'PDF^Study' }, | |
2241 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2242 })) | |
2243 | |
2244 self.assertEqual(brainixStudy, DoGet(_REMOTE, '/instances/%s/study' % i['ID'])['ID']) | |
2245 | |
2246 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2247 json.dumps({ | |
2248 'Parent' : brainixEpi, | |
37 | 2249 'Tags' : { 'SpecificCharacterSet' : 'ISO_IR 13' }, |
36 | 2250 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
2251 })) | |
2252 | |
2253 self.assertEqual(brainixEpi, DoGet(_REMOTE, '/instances/%s/series' % i['ID'])['ID']) | |
2254 | |
2255 b = DoGet(_REMOTE, '/instances/%s/pdf' % i['ID']) | |
2256 self.assertEqual(len(b), len(pdf)) | |
2257 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf)) | |
2258 | |
2259 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/pdf' % brainixInstance)) | |
38 | 2260 |
2261 | |
2262 def test_create_series(self): | |
2263 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2264 json.dumps({ | |
2265 'Tags' : { | |
40 | 2266 'SpecificCharacterSet' : 'ISO_IR 100', |
2267 'PatientName' : 'Sébastien Jodogne', | |
38 | 2268 'Modality' : 'CT', |
2269 }, | |
2270 'Content' : [ | |
40 | 2271 { |
2272 'Content': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', # red dot in RGBA | |
2273 'Tags' : { 'ImageComments' : 'Tutu' } | |
2274 }, | |
38 | 2275 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAoUlEQVQ4jZ2SWw3EIBREjwUsYAELa2EtoAULFUCyXAtroRZqoRbox254BdLC/DZnZjoXWJFgCDg8egW2CBEhEnDzyRk+Ecxz2KP/0AL8S99T+jQccAVs22qKwAuPuq0uyNg9cPLh3am+pe/dkHLZtqJHj6vXJrZ7nvzvxxgemXgUwnGfXqpee09mUwp8m022OYP6bLF7mVuVe0y/umxinsAXRd9z0k1ubWsAAAAASUVORK5CYII=', |
2276 ] | |
2277 })) | |
2278 | |
2279 s = DoGet(_REMOTE, i['Path']) | |
2280 self.assertEqual('Series', s['Type']) | |
2281 self.assertEqual(s['ID'], i['ID']) | |
2282 self.assertEqual(2, len(s['Instances'])) | |
39 | 2283 self.assertEqual(2, s['ExpectedNumberOfInstances']) |
2284 self.assertEqual('Complete', s['Status']) | |
40 | 2285 |
2286 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][0]) | |
2287 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][1]) | |
2288 self.assertTrue('ImageComments' in a or 'ImageComments' in b) | |
2289 if 'ImageComments' in a: | |
2290 self.assertEqual('Tutu', a['ImageComments']) | |
2291 else: | |
2292 self.assertEqual('Tutu', b['ImageComments']) | |
2293 | |
2294 patient = DoGet(_REMOTE, '/instances/%s/patient' % s['Instances'][0]) | |
2295 self.assertEqual(patient['MainDicomTags']['PatientName'].encode('utf-8'), | |
2296 'Sébastien Jodogne') | |
47 | 2297 |
2298 | |
2299 def test_create_binary(self): | |
2300 binary = ''.join(map(chr, range(256))) | |
2301 encoded = 'data:application/octet-stream;base64,' + base64.b64encode(binary) | |
2302 tags = { | |
2303 'PatientName' : 'Jodogne', | |
2304 '8899-8899' : encoded | |
2305 } | |
2306 | |
2307 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2308 json.dumps({ | |
2309 'Tags' : tags | |
2310 })) | |
2311 | |
2312 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2313 self.assertEqual(binary, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID']).strip()) | |
2314 | |
2315 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2316 json.dumps({ | |
2317 'InterpretBinaryTags' : False, | |
2318 'Tags' : tags | |
2319 })) | |
2320 | |
2321 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2322 self.assertEqual(encoded, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID'])[0:-1]) | |
48
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2323 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2324 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2325 def test_patient_ids_collision(self): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2326 # Upload 3 instances from 3 different studies, but with the |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2327 # same PatientID |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2328 for i in range(3): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2329 UploadInstance(_REMOTE, 'PatientIdsCollision/Image%d.dcm' % (i + 1)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2330 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2331 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2332 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2333 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2334 self.assertEqual('COMMON', DoGet(_REMOTE, '/patients/%s' % a[0]) ['MainDicomTags']['PatientID']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2335 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2336 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2337 'CaseSensitive' : True, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2338 'Query' : { 'PatientName' : 'FOO\\HELLO' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2339 self.assertEqual(2, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2340 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2341 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2342 'CaseSensitive' : False, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2343 'Query' : { 'PatientName' : 'Foo' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2344 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2345 self.assertEqual('FOO^SERIES', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['MainDicomTags']['StudyDescription']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2346 self.assertEqual('FOO', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['PatientMainDicomTags']['PatientName']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2347 self.assertEqual('COMMON', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['PatientMainDicomTags']['PatientID']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2348 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2349 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2350 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2351 self.assertEqual(3, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2352 d = map(lambda x: DoGet(_REMOTE, '/studies/%s' % x) ['MainDicomTags']['StudyDescription'], a) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2353 self.assertTrue('FOO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2354 self.assertTrue('HELLO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2355 self.assertTrue('WORLD^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2356 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2357 d = map(lambda x: DoGet(_REMOTE, '/studies/%s' % x) ['PatientMainDicomTags']['PatientID'], a) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2358 self.assertEqual(1, len(set(d))) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2359 self.assertEqual('COMMON', d[0]) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2360 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2361 for i in a: |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2362 d = DoGet(_REMOTE, '/studies/%s' % i) ['MainDicomTags']['StudyDescription'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2363 p = DoGet(_REMOTE, '/studies/%s' % i) ['PatientMainDicomTags']['PatientName'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2364 self.assertEqual('%s^SERIES' % p, d) |
49
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2365 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2366 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2367 def test_bitbucket_issue_4(self): |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2368 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2369 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2370 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2371 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2372 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2373 UploadInstance(_REMOTE, 'Formats/Rle.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2374 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2375 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2376 self.assertEqual(6, len(DoGet(_REMOTE, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2377 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2378 p = DoGet(_REMOTE, '/patients') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2379 self.assertEqual(2, len(p)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2380 i1 = map(lambda x: x['ID'], DoGet(_REMOTE, '/patients/%s/instances' % p[0])) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2381 i2 = map(lambda x: x['ID'], DoGet(_REMOTE, '/patients/%s/instances' % p[1])) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2382 self.assertEqual(3, len(i1)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2383 self.assertEqual(3, len(i2)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2384 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2385 j = DoPost(_REMOTE, '/modalities/orthanctest/store', i2[0:1] + i1 + i2[1:3]) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2386 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2387 self.assertEqual(6, len(DoGet(_LOCAL, '/instances'))) |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2388 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2389 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2390 def test_create_sequence(self): |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2391 i = DoPost(_REMOTE, '/tools/create-dicom', |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2392 json.dumps({ |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2393 'Tags' : { |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2394 'SpecificCharacterSet': 'ISO_IR 100', # Encode using Latin1 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2395 'PatientName': 'Jodogne^', |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2396 'ReferencedStudySequence': GenerateTestSequence(), |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2397 } |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2398 }))['ID'] |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2399 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2400 self.assertEqual('Jodogne^', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2401 self.assertEqual('Hello^', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/StudyDescription' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2402 self.assertEqual('Toto', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/ReferencedStudySequence/0/StudyDescription' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2403 self.assertEqual('Tata', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/ReferencedStudySequence/1/StudyDescription' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2404 self.assertEqual(u'Sébastien^'.encode('latin-1'), |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2405 DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/1/StudyDescription' % i)) |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2406 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2407 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2408 def test_modify_sequence(self): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2409 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2410 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % i)) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2411 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2412 j = DoPost(_REMOTE, '/instances/%s/modify' % i, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2413 json.dumps({ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2414 "Replace" : { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2415 "PatientName" : "hello", |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2416 'ReferencedStudySequence': GenerateTestSequence(), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2417 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2418 }), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2419 'application/json') |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2420 j = DoPost(_REMOTE, '/instances', j, 'application/dicom')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2421 DoDelete(_REMOTE, '/instances/%s' % i) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2422 |
52 | 2423 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % j))) |
2424 | |
2425 | |
2426 def test_compression(self): | |
2427 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
2428 | |
2429 data = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % i)[1] | |
2430 | |
2431 # "StorageCompression" is enabled in the Orthanc to be tested, | |
2432 # uncompress the data before running the test | |
2433 if DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i) != 0: | |
2434 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2435 | |
2436 cs = DoGet(_REMOTE, '/statistics')['TotalDiskSize'] | |
2437 us = DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'] | |
2438 size = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i) | |
2439 md5 = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i) | |
2440 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2441 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2442 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2443 | |
2444 ops = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % i) | |
2445 self.assertTrue('compress' in ops) | |
2446 self.assertTrue('uncompress' in ops) | |
2447 self.assertTrue('is-compressed' in ops) | |
2448 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2449 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2450 | |
2451 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/compress' % i) | |
2452 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2453 self.assertEqual(1, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2454 self.assertLess(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2455 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
2456 self.assertGreater(len(data), len(DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1])) | |
2457 self.assertGreater(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2458 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2459 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2460 self.assertNotEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2461 | |
2462 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2463 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2464 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2465 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2466 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2467 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2468 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2469 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2470 self.assertEqual(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2471 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
53 | 2472 |
2473 | |
2474 def test_ordered_slices(self): | |
2475 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
2476 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2477 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2478 self.assertEqual('Sequence', o['Type']) | |
2479 self.assertEqual(1, len(o['Dicom'])) | |
2480 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/file', o['Dicom'][0]) | |
2481 self.assertEqual(76, len(o['Slices'])) | |
2482 for j in range(76): | |
2483 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/frames/%d' % j, o['Slices'][j]) | |
2484 | |
68 | 2485 self.assertEqual(1, len(o['SlicesShort'])) |
2486 self.assertEqual('9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02', o['SlicesShort'][0][0]) | |
2487 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2488 self.assertEqual(76, o['SlicesShort'][0][2]) | |
2489 | |
53 | 2490 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2491 j = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm')['ID'] | |
2492 k = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm')['ID'] | |
2493 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2494 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2495 | |
2496 self.assertEqual('Volume', o['Type']) | |
2497 self.assertEqual(3, len(o['Dicom'])) | |
2498 self.assertEqual(3, len(o['Slices'])) | |
2499 self.assertEqual('/instances/%s/file' % i, o['Dicom'][2]) | |
2500 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2501 self.assertEqual('/instances/%s/file' % k, o['Dicom'][0]) | |
2502 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][2]) | |
2503 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
2504 self.assertEqual('/instances/%s/frames/0' % k, o['Slices'][0]) | |
2505 | |
68 | 2506 self.assertEqual(3, len(o['SlicesShort'])) |
2507 self.assertEqual(k, o['SlicesShort'][0][0]) | |
2508 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2509 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2510 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2511 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2512 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2513 self.assertEqual(i, o['SlicesShort'][2][0]) | |
2514 self.assertEqual(0, o['SlicesShort'][2][1]) | |
2515 self.assertEqual(1, o['SlicesShort'][2][2]) | |
2516 | |
53 | 2517 i = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] |
2518 j = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0002.dcm')['ID'] | |
2519 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2520 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2521 | |
2522 self.assertEqual('Sequence', o['Type']) | |
2523 self.assertEqual(2, len(o['Dicom'])) | |
2524 self.assertEqual(2, len(o['Slices'])) | |
2525 self.assertEqual('/instances/%s/file' % i, o['Dicom'][0]) | |
2526 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2527 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][0]) | |
2528 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2529 |
68 | 2530 self.assertEqual(2, len(o['SlicesShort'])) |
2531 self.assertEqual(i, o['SlicesShort'][0][0]) | |
2532 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2533 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2534 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2535 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2536 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2537 | |
2538 | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2539 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2540 def test_incoming_movescu_accession(self): |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2541 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2542 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2543 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2544 CallMoveScu([ '--study', '-k', '0008,0052=STUDY', '-k', 'AccessionNumber=nope' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2545 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2546 CallMoveScu([ '--study', '-k', '0008,0052=PATIENT', '-k', 'AccessionNumber=A10003245599' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2547 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2548 CallMoveScu([ '--study', '-k', '0008,0052=STUDY', '-k', 'AccessionNumber=A10003245599' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2549 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2550 |
55 | 2551 |
2552 def test_dicom_to_json(self): | |
2553 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2554 j = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2555 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2556 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2557 with open(GetDatabasePath('PrivateMDNTagsSimplify.json'), 'r') as f: |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2558 self.assertEqual(json.loads(f.read()), t) |
55 | 2559 |
2560 t = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
2561 with open(GetDatabasePath('PrivateMDNTagsFull.json'), 'r') as f: | |
2562 self.assertEqual(json.loads(f.read()), t) | |
2563 | |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2564 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % j) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2565 with open(GetDatabasePath('PrivateTagsSimplify.json'), 'r') as f: |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2566 a = json.loads(f.read()) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2567 self.assertEqual(a, t) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2568 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2569 t = DoGet(_REMOTE, '/instances/%s/tags' % j) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2570 with open(GetDatabasePath('PrivateTagsFull.json'), 'r') as f: |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2571 a = json.loads(f.read()) |
65
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2572 |
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2573 aa = json.dumps(a).replace('2e+022', '2e+22') |
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2574 tt = json.dumps(t).replace('2e+022', '2e+22') |
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2575 self.assertEqual(aa, tt) |
57 | 2576 |
2577 | |
2578 def test_batch_archive(self): | |
2579 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2580 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') | |
2581 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2582 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0002.dcm') | |
2583 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2584 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') | |
2585 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
2586 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
2587 | |
2588 s = DoPost(_REMOTE, '/tools/create-archive', [ ]) | |
2589 z = zipfile.ZipFile(StringIO(s), "r") | |
2590 self.assertEqual(0, len(z.namelist())) | |
2591 | |
2592 # One patient | |
2593 s = DoPost(_REMOTE, '/tools/create-archive', [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ]) | |
2594 z = zipfile.ZipFile(StringIO(s), "r") | |
2595 self.assertEqual(4, len(z.namelist())) | |
2596 | |
2597 # One patient + twice its study + one series from other patient | |
2598 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2599 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2600 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918', | |
2601 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
2602 ]) | |
2603 z = zipfile.ZipFile(StringIO(s), "r") | |
2604 self.assertEqual(6, len(z.namelist())) | |
2605 | |
2606 # One patient + one series + one instance | |
2607 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2608 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2609 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0', | |
2610 '1d429ccb-bdcc78a1-7d129d6a-ba4966ed-fe4dbd87' | |
2611 ]) | |
2612 z = zipfile.ZipFile(StringIO(s), "r") | |
2613 self.assertEqual(7, len(z.namelist())) | |
59
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2614 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2615 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2616 def test_decode_brainix_as_jpeg(self): |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2617 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2618 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2619 j = GetImage(_REMOTE, '/instances/%s/preview' % i) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2620 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2621 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2622 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2623 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2624 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : '*/*' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2625 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2626 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2627 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/*' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2628 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2629 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2630 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/png' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2631 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2632 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2633 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/jpeg' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2634 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2635 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2636 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2637 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2638 a = len(DoGet(_REMOTE, '/instances/%s/preview?quality=50' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2639 b = len(DoGet(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2640 self.assertLess(a, b) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2641 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2642 j = GetImage(_REMOTE, '/instances/%s/image-uint8' % i, headers = { 'Accept' : 'image/jpeg' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2643 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2644 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2645 # 16bit encoding is not supported with JPEG |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2646 self.assertRaises(Exception, lambda: GetImage(_REMOTE, '/instances/%s/image-uint16' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2647 self.assertRaises(Exception, lambda: GetImage(_REMOTE, '/instances/%s/image-int16' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2648 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2649 # No matching content type |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2650 self.assertRaises(Exception, lambda: GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'application/pdf' })) |
69
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2651 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2652 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2653 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2654 def test_media_encodings(self): |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2655 ascii = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2656 latin1 = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2657 latin2 = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2658 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2659 tmp = DoPost(_REMOTE, '/tools/create-media', [ascii,latin1,latin2]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2660 z = zipfile.ZipFile(StringIO(tmp), "r") |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2661 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2662 self.assertEqual(4, len(z.namelist())) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2663 self.assertTrue('IMAGES/IM0' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2664 self.assertTrue('IMAGES/IM1' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2665 self.assertTrue('IMAGES/IM2' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2666 self.assertTrue('DICOMDIR' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2667 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2668 try: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2669 os.remove('/tmp/DICOMDIR') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2670 except: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2671 # The file does not exist |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2672 pass |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2673 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2674 z.extract('DICOMDIR', '/tmp') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2675 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2676 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2677 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2678 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2679 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2680 self.assertEqual(1, len(a)) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2681 self.assertEqual('', a[0]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2682 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2683 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2684 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', a) != None) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2685 self.assertTrue(re.search('1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114333648576', a) != None) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2686 self.assertTrue(re.search('1.2.826.0.1.3680043.2.1569.1.4.323026757.1700.1399452091.57', a) != None) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2687 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2688 os.remove('/tmp/DICOMDIR') |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2689 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2690 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2691 def test_findscu_counters(self): |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2692 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2693 UploadInstance(_REMOTE, 'Comunix/Pet/IM-0001-0001.dcm') |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2694 UploadInstance(_REMOTE, 'Comunix/Pet/IM-0001-0002.dcm') |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2695 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2696 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', 'NumberOfPatientRelatedStudies' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2697 s = re.findall('\(0020,1200\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2698 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2699 self.assertTrue('1 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2700 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2701 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', 'NumberOfPatientRelatedSeries' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2702 s = re.findall('\(0020,1202\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2703 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2704 self.assertTrue('2 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2705 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2706 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', 'NumberOfPatientRelatedInstances' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2707 s = re.findall('\(0020,1204\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2708 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2709 self.assertTrue('3 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2710 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2711 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'NumberOfStudyRelatedSeries' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2712 s = re.findall('\(0020,1206\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2713 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2714 self.assertTrue('2 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2715 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2716 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'NumberOfStudyRelatedInstances' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2717 s = re.findall('\(0020,1208\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2718 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2719 self.assertTrue('3 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2720 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2721 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'NumberOfSeriesRelatedInstances' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2722 s = re.findall('\(0020,1209\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2723 self.assertEqual(2, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2724 self.assertTrue('1 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2725 self.assertTrue('2 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2726 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2727 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'ModalitiesInStudy' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2728 s = re.findall('\(0008,0061\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2729 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2730 t = map(lambda x: x.strip(), s[0].split('\\')) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2731 self.assertTrue('PT' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2732 self.assertTrue('CT' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2733 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2734 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'SOPClassesInStudy' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2735 s = re.findall('\(0008,0062\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2736 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2737 t = map(lambda x: x.strip(), s[0].split('\\')) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2738 self.assertTrue('1.2.840.10008.5.1.4.1.1.2' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2739 self.assertTrue('1.2.840.10008.5.1.4.1.1.128' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2740 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2741 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2742 def test_decode_transfer_syntax(self): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2743 def Check(t, md5): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2744 i = UploadInstance(_REMOTE, 'TransferSyntaxes/%s.dcm' % t)['ID'] |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2745 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2746 if md5 == None: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2747 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2748 else: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2749 m = ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2750 self.assertEqual(m, md5) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2751 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2752 Check('1.2.840.10008.1.2.1', 'fae08d5415c4c0cd2cdbae4522408631') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2753 Check('1.2.840.10008.1.2.2', 'f3d9784768b8feb54d6a50b6d5c37682') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2754 Check('1.2.840.10008.1.2.4.50', '496326046974eea718dbc16b997c646b') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2755 Check('1.2.840.10008.1.2.4.51', 'ccbe75909fe5c9f7361b48416a53fc41') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2756 Check('1.2.840.10008.1.2.4.57', '7bbefe11d976b1be4e568915c6a82fc3') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2757 Check('1.2.840.10008.1.2.4.70', '7132cfbc457305b04b59787030c785d2') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2758 Check('1.2.840.10008.1.2.4.80', '6ff51ae525d362e0d04f550a64075a0e') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2759 Check('1.2.840.10008.1.2.4.81', '801579ae7cbf28e604ea74f2c99fa2ca') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2760 Check('1.2.840.10008.1.2.5', '6ff51ae525d362e0d04f550a64075a0e') # RLE, supported since Orthanc 1.0.1 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2761 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2762 Check('1.2.840.10008.1.2.4.90', None) # JPEG-2000 image, not supported |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2763 Check('1.2.840.10008.1.2.4.91', None) # JPEG-2000 image, not supported |