Mercurial > hg > orthanc-tests
annotate Tests/Tests.py @ 138:0682740fcfcb
cleanup
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 May 2018 11:08:58 +0200 |
parents | 412d5f70447e |
children | 5de178abe4d8 |
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 |
130
50cd127e5330
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
128
diff
changeset
|
8 # Copyright (C) 2017-2018 Osimis S.A., Belgium |
3 | 9 # |
10 # This program is free software: you can redistribute it and/or | |
11 # modify it under the terms of the GNU General Public License as | |
12 # published by the Free Software Foundation, either version 3 of the | |
13 # License, or (at your option) any later version. | |
14 # | |
15 # This program is distributed in the hope that it will be useful, but | |
16 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 # General Public License for more details. | |
19 # | |
20 # You should have received a copy of the GNU General Public License | |
21 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
22 | |
23 | |
14 | 24 import tempfile |
3 | 25 import unittest |
36 | 26 import base64 |
3 | 27 |
11 | 28 from PIL import ImageChops |
3 | 29 from Toolbox import * |
13 | 30 from xml.dom import minidom |
3 | 31 |
32 _LOCAL = None | |
33 _REMOTE = None | |
34 | |
35 | |
36 def SetOrthancParameters(local, remote): | |
37 global _LOCAL, _REMOTE | |
38 _LOCAL = local | |
39 _REMOTE = remote | |
40 | |
41 | |
14 | 42 def ExtractDicomTags(rawDicom, tags): |
43 with tempfile.NamedTemporaryFile(delete = True) as f: | |
44 f.write(rawDicom) | |
45 f.flush() | |
45 | 46 data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
14 | 47 |
48 result = [] | |
49 for tag in tags: | |
50 match = re.search('<element[^>]+name="%s">([^>]*)</element>' % tag, data) | |
51 if match == None: | |
52 result.append('') | |
53 else: | |
54 result.append(match.group(1)) | |
55 | |
56 return result | |
57 | |
58 | |
15 | 59 def InstallLuaScript(path): |
60 with open(GetDatabasePath(path), 'r') as f: | |
61 DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua') | |
62 | |
63 | |
64 def UninstallLuaCallbacks(): | |
65 DoPost(_REMOTE, '/tools/execute-script', 'function OnStoredInstance() end', 'application/lua') | |
43 | 66 InstallLuaScript('Lua/TransferSyntaxEnable.lua') |
15 | 67 |
68 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
69 def CompareLists(a, b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
70 if len(a) != len(b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
71 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
72 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
73 for i in range(len(a)): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
74 d = a[i] - b[i] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
75 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
|
76 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
77 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
78 return True |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
79 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
80 |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
81 def CompareTags(a, b, tagsToIgnore): |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
82 for i in tagsToIgnore: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
83 if i in a: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
84 del a[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
85 if i in b: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
86 del b[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
87 |
123 | 88 if a.keys() == b.keys(): |
89 return True | |
90 else: | |
91 print('Mismatch in tags: %s' % str(set(a.keys()) ^ set(b.keys()))) | |
92 return False | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
93 |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
94 |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
95 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
|
96 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
|
97 '-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
|
98 _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
|
99 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
|
100 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
|
101 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
102 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
103 def CallMoveScu(args): |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
104 subprocess.check_call([ FindExecutable('movescu'), |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
105 '--move', _LOCAL['DicomAet'], # Target AET (i.e. storescp) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
106 '--call', _REMOTE['DicomAet'], # Called AET (i.e. Orthanc) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
107 '--aetitle', _LOCAL['DicomAet'], # Calling AET (i.e. storescp) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
108 _REMOTE['Server'], str(_REMOTE['DicomPort']) ] + args, |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
109 stderr=subprocess.PIPE) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
110 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
111 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
112 |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
113 def GenerateTestSequence(): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
114 return [ |
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 'StudyDescription': 'Hello^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
117 'ReferencedStudySequence' : [ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
118 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
119 'StudyDescription': 'Toto', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
120 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
121 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
122 'StudyDescription': 'Tata', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
123 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
124 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
125 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
126 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
127 'StudyDescription': 'Sébastien^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
128 'StudyDate' : '19700202', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
129 } |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
130 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
131 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
132 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
133 |
15 | 134 |
3 | 135 class Orthanc(unittest.TestCase): |
136 def setUp(self): | |
83 | 137 if (sys.version_info >= (3, 0)): |
138 # Remove annoying warnings about unclosed socket in Python 3 | |
139 import warnings | |
140 warnings.simplefilter("ignore", ResourceWarning) | |
141 | |
3 | 142 DropOrthanc(_LOCAL) |
143 DropOrthanc(_REMOTE) | |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
144 UninstallLuaCallbacks() |
45 | 145 #print "In test", self._testMethodName |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
146 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
147 def AssertSameImages(self, truth, url): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
148 im = GetImage(_REMOTE, url) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
149 self.assertTrue(CompareLists(truth, im.getdata())) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
150 |
3 | 151 |
152 def test_system(self): | |
153 self.assertTrue('Version' in DoGet(_REMOTE, '/system')) | |
154 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
155 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
156 | |
157 def test_upload(self): | |
158 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
159 self.assertEqual('Success', u['Status']) | |
160 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
161 self.assertEqual('AlreadyStored', u['Status']) | |
162 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
163 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
164 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
165 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
166 | |
167 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % u['ID']) | |
168 self.assertEqual('20070101', i['StudyDate']) | |
169 | |
170 | |
5 | 171 def test_upload_2(self): |
3 | 172 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
173 instance = DoGet(_REMOTE, '/instances/%s' % i) | |
174 self.assertEqual(i, instance['ID']) | |
175 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', | |
176 instance['MainDicomTags']['SOPInstanceUID']) | |
177 | |
178 series = DoGet(_REMOTE, '/series/%s' % instance['ParentSeries']) | |
179 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
180 series['MainDicomTags']['SeriesInstanceUID']) | |
181 | |
182 study = DoGet(_REMOTE, '/studies/%s' % series['ParentStudy']) | |
183 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
184 study['MainDicomTags']['StudyInstanceUID']) | |
185 | |
186 patient = DoGet(_REMOTE, '/patients/%s' % study['ParentPatient']) | |
187 self.assertEqual('ozp00SjY2xG', | |
188 patient['MainDicomTags']['PatientID']) | |
189 | |
190 dicom = DoGet(_REMOTE, '/instances/%s/file' % instance['ID']) | |
191 self.assertEqual(2472, len(dicom)) | |
192 self.assertEqual('3e29b869978b6db4886355a2b1132124', ComputeMD5(dicom)) | |
193 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
194 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/simplified-tags' % i)['StationName']) | |
195 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags' % i)['0008,1010']['Value']) | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
196 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['StationName']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
197 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags?short' % i)['0008,1010']) |
3 | 198 |
199 | |
5 | 200 def test_images(self): |
201 i = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] | |
202 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
3 | 203 |
5 | 204 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
205 self.assertEqual("L", im.mode) | |
206 self.assertEqual(512, im.size[0]) | |
207 self.assertEqual(358, im.size[1]) | |
208 | |
209 im = GetImage(_REMOTE, '/instances/%s/image-uint8' % i) | |
210 self.assertEqual("L", im.mode) | |
211 self.assertEqual(512, im.size[0]) | |
212 self.assertEqual(358, im.size[1]) | |
213 | |
214 im = GetImage(_REMOTE, '/instances/%s/image-uint16' % i) | |
215 self.assertEqual(512, im.size[0]) | |
216 self.assertEqual(358, im.size[1]) | |
217 | |
218 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
219 self.assertEqual("L", im.mode) | |
220 self.assertEqual(512, im.size[0]) | |
221 self.assertEqual(358, im.size[1]) | |
222 | |
223 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
224 self.assertEqual("L", im.mode) | |
225 self.assertEqual(512, im.size[0]) | |
226 self.assertEqual(358, im.size[1]) | |
227 | |
228 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
229 self.assertEqual(512, im.size[0]) | |
230 self.assertEqual(358, im.size[1]) | |
64 | 231 |
232 # This is Little Endian Explicit | |
233 self.assertEqual('1.2.840.10008.1.2.1', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) | |
234 | |
6 | 235 |
236 def test_hierarchy(self): | |
237 UploadFolder(_REMOTE, 'Brainix/Epi') | |
238 UploadFolder(_REMOTE, 'Brainix/Flair') | |
239 UploadFolder(_REMOTE, 'Knee/T1') | |
240 UploadFolder(_REMOTE, 'Knee/T2') | |
241 | |
242 p = DoGet(_REMOTE, '/patients') | |
243 s = DoGet(_REMOTE, '/studies') | |
244 t = DoGet(_REMOTE, '/series') | |
245 self.assertEqual(2, len(p)) | |
246 self.assertEqual(2, len(s)) | |
247 self.assertEqual(4, len(t)) | |
248 self.assertEqual(94, len(DoGet(_REMOTE, '/instances'))) | |
249 | |
250 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
251 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
252 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
253 brainixFlair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
254 | |
255 kneePatient = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
256 kneeStudy = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
257 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
258 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
259 | |
260 self.assertTrue(brainixPatient in p) | |
261 self.assertTrue(kneePatient in p) | |
262 self.assertTrue(brainixStudy in s) | |
263 self.assertTrue(kneeStudy in s) | |
264 self.assertTrue(brainixEpi in t) | |
265 self.assertTrue(brainixFlair in t) | |
266 self.assertTrue(kneeT1 in t) | |
267 self.assertTrue(kneeT2 in t) | |
268 | |
269 self.assertEqual(44, len(DoGet(_REMOTE, '/patients/%s/instances' % brainixPatient))) | |
270 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % brainixPatient))) | |
271 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % brainixPatient))) | |
272 | |
273 self.assertEqual(50, len(DoGet(_REMOTE, '/patients/%s/instances' % kneePatient))) | |
274 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % kneePatient))) | |
275 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % kneePatient))) | |
276 | |
277 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % brainixStudy))) | |
278 self.assertEqual(44, len(DoGet(_REMOTE, '/studies/%s/instances' % brainixStudy))) | |
279 | |
280 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % kneeStudy))) | |
281 self.assertEqual(50, len(DoGet(_REMOTE, '/studies/%s/instances' % kneeStudy))) | |
282 | |
283 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixEpi))) | |
284 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixFlair))) | |
285 self.assertEqual(24, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT1))) | |
286 self.assertEqual(26, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT2))) | |
287 | |
288 for patient in p: | |
289 for study in DoGet(_REMOTE, '/patients/%s/studies' % patient): | |
290 self.assertEqual(patient, study['ParentPatient']) | |
291 for series in DoGet(_REMOTE, '/studies/%s/series' % study['ID']): | |
292 self.assertEqual(study['ID'], series['ParentStudy']) | |
293 for instance in DoGet(_REMOTE, '/series/%s/instances' % series['ID']): | |
294 self.assertEqual(series['ID'], instance['ParentSeries']) | |
295 | |
296 self.assertEqual(json.dumps(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance['ID'])), | |
297 json.dumps(DoGet(_REMOTE, '/instances/%s/tags' % instance['ID']))) | |
298 | |
299 | |
300 r = DoDelete(_REMOTE, "/studies/%s" % brainixStudy)['RemainingAncestor'] | |
301 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
302 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
303 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
304 self.assertEqual(50, len(DoGet(_REMOTE, '/instances'))) | |
305 self.assertEqual(None, r) | |
306 | |
307 r = DoDelete(_REMOTE, "/series/%s" % kneeT2)['RemainingAncestor'] | |
308 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
309 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
310 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
311 self.assertEqual(24, len(DoGet(_REMOTE, '/instances'))) | |
312 self.assertEqual('Study', r['Type']) | |
313 self.assertEqual(kneeStudy, r['ID']) | |
314 | |
315 r = DoDelete(_REMOTE, "/instances/%s" % DoGet(_REMOTE, '/instances')[0])['RemainingAncestor'] | |
316 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
317 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
318 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
319 self.assertEqual(23, len(DoGet(_REMOTE, '/instances'))) | |
320 self.assertEqual('Series', r['Type']) | |
321 self.assertEqual(kneeT1, r['ID']) | |
322 | |
323 r = DoDelete(_REMOTE, "/patients/%s" % kneePatient)['RemainingAncestor'] | |
324 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
325 self.assertEqual(0, len(DoGet(_REMOTE, '/studies'))) | |
326 self.assertEqual(0, len(DoGet(_REMOTE, '/series'))) | |
327 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
328 self.assertEqual(None, r) | |
329 | |
330 DropOrthanc(_REMOTE) | |
331 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
332 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
7 | 333 |
334 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
335 def test_multiframe(self): |
7 | 336 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
337 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
338 | |
339 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
340 self.assertEqual("L", im.mode) | |
341 self.assertEqual(512, im.size[0]) | |
342 self.assertEqual(512, im.size[1]) | |
343 | |
344 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
345 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
346 DoGet(_REMOTE, '/instances/%s/frames/75/preview' % i) | |
347 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/aaa/preview' % i)) | |
348 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/preview' % i)) | |
349 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
350 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
351 def test_changes(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
352 # Check emptiness |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
353 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
354 self.assertEqual(0, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
355 self.assertEqual(0, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
356 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
357 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
358 self.assertEqual(0, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
359 self.assertEqual(0, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
360 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
361 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
362 # Add 1 instance |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
363 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
|
364 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
365 begin = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
366 self.assertEqual(4, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
367 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
368 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
|
369 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
370 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
371 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
372 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
373 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
374 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
|
375 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
376 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
377 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
378 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
|
379 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
380 self.assertEqual(begin - 1, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
381 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
382 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
|
383 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
384 self.assertEqual(begin - 2, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
385 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
386 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
387 UploadFolder(_REMOTE, 'Knee/T1') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
388 UploadFolder(_REMOTE, 'Knee/T2') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
389 since = begin |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
390 countPatients = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
391 countStudies = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
392 countSeries = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
393 countInstances = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
394 completed = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
395 while True: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
396 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
|
397 since = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
398 for i in c['Changes']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
399 if i['ResourceType'] == 'Instance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
400 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
401 if i['ResourceType'] == 'Patient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
402 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
403 if i['ResourceType'] == 'Study': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
404 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
405 if i['ResourceType'] == 'Series': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
406 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
407 if i['ChangeType'] == 'NewInstance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
408 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
409 if i['ChangeType'] == 'NewPatient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
410 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
411 if i['ChangeType'] == 'NewStudy': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
412 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
413 if i['ChangeType'] == 'NewSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
414 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
415 if i['ChangeType'] == 'CompletedSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
416 completed += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
417 self.assertTrue('ID' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
418 self.assertTrue('Path' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
419 self.assertTrue('Seq' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
420 if c['Done']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
421 break |
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 self.assertEqual(2 * 50, countInstances) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
424 self.assertEqual(2 * 1, countPatients) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
425 self.assertEqual(2 * 1, countStudies) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
426 self.assertEqual(2 * 2, countSeries) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
427 self.assertEqual(0, completed) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
428 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
429 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
430 def test_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
431 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
|
432 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
|
433 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
434 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
|
435 self.assertEqual(2, len(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 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
|
438 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
439 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
440 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
|
441 self.assertEqual(1, len(z.namelist())) |
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 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
|
444 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
445 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
|
446 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
447 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
448 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
449 def test_media_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
450 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
|
451 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
|
452 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
453 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
|
454 self.assertEqual(3, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
455 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
|
456 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
|
457 self.assertTrue('DICOMDIR' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
458 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
459 try: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
460 os.remove('/tmp/DICOMDIR') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
461 except: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
462 # The file does not exist |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
463 pass |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
464 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
465 z.extract('DICOMDIR', '/tmp') |
45 | 466 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
|
467 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
468 self.assertEqual(3, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
469 self.assertTrue(a[0].startswith('Warning')) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
470 self.assertEqual('BasicDirectory', a[1]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
471 self.assertEqual('', a[2]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
472 |
45 | 473 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
|
474 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
475 self.assertEqual(1, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
476 self.assertEqual('', a[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
477 |
45 | 478 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
|
479 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
|
480 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
|
481 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
482 os.remove('/tmp/DICOMDIR') |
10 | 483 |
484 | |
485 def test_protection(self): | |
486 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
487 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
488 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
489 a = DoGet(_REMOTE, '/patients')[0] | |
490 b = DoGet(_REMOTE, '/patients')[1] | |
491 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
492 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
493 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
494 DoPut(_REMOTE, '/patients/%s/protected' % a, '1', 'text/plain') | |
495 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
496 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
497 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
498 | |
499 | |
12 | 500 def test_raw_tags(self): |
10 | 501 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
502 | |
503 dicom = DoGet(_REMOTE, '/instances/%s/file' % i) | |
504 self.assertEqual('1a7c56cb02d6e742cc9c856a8ac182e3', ComputeMD5(dicom)) | |
505 | |
506 s = '/instances/%s/content/' % i | |
507 | |
508 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, s + '0008-1010').strip()) | |
509 self.assertRaises(Exception, lambda: DoGet(_REMOTE, s + '0008-1011')) | |
510 | |
511 self.assertEqual('Abdomen', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/0/7fe1-1057').strip()) | |
512 self.assertEqual('cla_3c', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/8/7fe1-1057').strip()) | |
513 | |
514 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
515 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
516 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
517 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
518 | |
519 for i in DoGet(_REMOTE, '/instances'): | |
520 aid = DoGet(_REMOTE, '/instances/%s' % i)['MainDicomTags']['SOPInstanceUID'] | |
521 self.assertEqual(aid, DoGet(_REMOTE, '/instances/%s/content/0008-0018' % i).replace(chr(0), '')) | |
522 | |
523 | |
524 def test_raw_tags_mdn(self): | |
525 # Bug reported by Cyril Paulus | |
526 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
527 self.assertAlmostEqual(0.000027, DoGet(_REMOTE, '/instances/%s/content/7053-1000' % i)) | |
528 | |
529 | |
530 def test_modify_instance(self): | |
531 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] | |
532 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, | |
533 json.dumps({ | |
534 "Replace" : { | |
535 "PatientName" : "hello", | |
536 #"PatientID" : "world" | |
537 }, | |
538 "Remove" : [ "StationName" ], | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
539 "RemovePrivateTags" : True |
10 | 540 }), |
541 'application/json') | |
542 j = DoPost(_REMOTE, '/instances', modified, 'application/dicom')['ID'] | |
543 | |
544 self.assertNotEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
545 #self.assertNotEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % i).strip()) | |
83 | 546 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i).strip()) |
10 | 547 DoGet(_REMOTE, '/instances/%s/content/6003-1010' % i) # Some private tag |
548 | |
549 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
550 #self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % j).strip()) | |
551 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j)) | |
552 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/6003-1010' % j)) | |
553 | |
554 | |
555 def test_modify_series(self): | |
556 # Upload 4 images from the same series | |
557 for i in range(4): | |
558 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
559 | |
560 origSeries = DoGet(_REMOTE, '/series')[0] | |
561 newSeries = DoPost(_REMOTE, '/series/%s/modify' % origSeries, | |
562 '{"Replace":{"PatientName":"Jodogne"}}', | |
563 'application/json')['ID'] | |
564 | |
565 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['ModifiedFrom']) | |
566 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
567 self.assertEqual(4, len(instances)) | |
568 for i in instances: | |
569 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
570 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
571 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
572 | |
573 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
574 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
575 | |
576 | |
577 def test_modify_study(self): | |
578 # Upload 4 images from the 2 series of the same study | |
579 for i in range(4): | |
580 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
581 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
582 | |
583 origStudy = DoGet(_REMOTE, '/studies')[0] | |
584 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, | |
585 '{"Replace":{"PatientName":"Jodogne"}}', | |
586 'application/json')['ID'] | |
587 | |
588 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['ModifiedFrom']) | |
589 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
590 self.assertEqual(2, len(series)) | |
591 for s in series: | |
592 ss = DoGet(_REMOTE, '/series/%s' % s)['ModifiedFrom'] | |
593 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
594 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
595 | |
596 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
597 for i in instances: | |
598 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
599 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
600 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
601 | |
602 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
603 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
604 | |
605 | |
606 def test_anonymize_series(self): | |
607 # Upload 4 images from the same series | |
608 for i in range(4): | |
609 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
610 | |
611 origSeries = DoGet(_REMOTE, '/series')[0] | |
612 newSeries = DoPost(_REMOTE, '/series/%s/anonymize' % origSeries, | |
613 '{}', | |
614 'application/json')['ID'] | |
615 | |
616 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['AnonymizedFrom']) | |
617 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
618 self.assertEqual(4, len(instances)) | |
619 for i in instances: | |
620 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
621 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
622 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
623 | |
624 DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j) | |
625 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i)) | |
626 | |
627 | |
628 def test_anonymize_study(self): | |
629 # Upload 4 images from the 2 series of the same study | |
630 for i in range(4): | |
631 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
632 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
633 | |
634 origStudy = DoGet(_REMOTE, '/studies')[0] | |
635 newStudy = DoPost(_REMOTE,'/studies/%s/anonymize' % origStudy, | |
636 '{"Replace":{"PatientName":"Jodogne"}}', | |
637 'application/json')['ID'] | |
638 | |
639 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['AnonymizedFrom']) | |
640 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
641 self.assertEqual(2, len(series)) | |
642 for s in series: | |
643 ss = DoGet(_REMOTE, '/series/%s' % s)['AnonymizedFrom'] | |
644 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
645 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
646 | |
647 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
648 for i in instances: | |
649 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
650 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
651 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
652 | |
653 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
654 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
11 | 655 |
656 | |
657 | |
658 def test_storescu(self): | |
659 # Check emptiness | |
660 e = DoGet(_REMOTE, '/exports') | |
661 self.assertEqual(0, len(e['Exports'])) | |
662 self.assertEqual(0, e['Last']) | |
663 self.assertTrue(e['Done']) | |
664 e = DoGet(_REMOTE, '/exports?last') | |
665 self.assertEqual(0, len(e['Exports'])) | |
666 self.assertEqual(0, e['Last']) | |
667 self.assertTrue(e['Done']) | |
668 | |
669 # Add 1 instance | |
670 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
671 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
672 | |
673 # Export the instance | |
674 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') # instance | |
675 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
676 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
677 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
678 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
679 | |
680 e = DoGet(_REMOTE, '/exports') | |
681 self.assertEqual(1, len(e['Exports'])) | |
682 self.assertTrue(e['Done']) | |
683 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
684 e = DoGet(_REMOTE, '/exports?limit=1') | |
685 self.assertEqual(1, len(e['Exports'])) | |
686 self.assertTrue(e['Done']) | |
687 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
688 e = DoGet(_REMOTE, '/exports?last') | |
689 self.assertEqual(1, len(e['Exports'])) | |
690 self.assertTrue(e['Done']) | |
691 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
692 seqInstance = e['Last'] | |
693 | |
694 # Export the series | |
695 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', 'text/plain') | |
696 | |
697 e = DoGet(_REMOTE, '/exports') | |
698 self.assertEqual(2, len(e['Exports'])) | |
699 self.assertTrue(e['Done']) | |
700 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
701 seqSeries = e['Last'] | |
702 self.assertNotEqual(seqInstance, seqSeries) | |
703 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
704 self.assertEqual(1, len(e['Exports'])) | |
705 self.assertFalse(e['Done']) | |
706 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
707 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
708 self.assertEqual(1, len(e['Exports'])) | |
709 self.assertTrue(e['Done']) | |
710 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
711 e = DoGet(_REMOTE, '/exports?last') | |
712 self.assertEqual(1, len(e['Exports'])) | |
713 self.assertTrue(e['Done']) | |
714 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
715 | |
716 # Export the study | |
717 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', 'text/plain') | |
718 seqStudy = DoGet(_REMOTE, '/exports')['Last'] | |
719 | |
720 # Export the patient | |
721 j = DoPost(_REMOTE, '/modalities/orthanctest/store', '6816cb19-844d5aee-85245eba-28e841e6-2414fae2', 'text/plain') | |
722 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
723 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
724 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
725 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
726 | |
727 e = DoGet(_REMOTE, '/exports') | |
728 self.assertEqual(4, len(e['Exports'])) | |
729 self.assertTrue(e['Done']) | |
730 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
731 seqPatient = e['Last'] | |
732 self.assertNotEqual(seqInstance, seqSeries) | |
733 self.assertNotEqual(seqSeries, seqStudy) | |
734 self.assertNotEqual(seqStudy, seqPatient) | |
735 self.assertTrue(seqInstance < seqSeries) | |
736 self.assertTrue(seqSeries < seqStudy) | |
737 self.assertTrue(seqStudy < seqPatient) | |
738 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
739 self.assertEqual(1, len(e['Exports'])) | |
740 self.assertFalse(e['Done']) | |
741 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
742 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
743 self.assertEqual(1, len(e['Exports'])) | |
744 self.assertFalse(e['Done']) | |
745 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
746 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqSeries)) | |
747 self.assertEqual(1, len(e['Exports'])) | |
748 self.assertFalse(e['Done']) | |
749 self.assertEqual(e['Exports'][-1]['Seq'], seqStudy) | |
750 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqStudy)) | |
751 self.assertEqual(1, len(e['Exports'])) | |
752 self.assertTrue(e['Done']) | |
753 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
754 e = DoGet(_REMOTE, '/exports?last') | |
755 self.assertEqual(1, len(e['Exports'])) | |
756 self.assertTrue(e['Done']) | |
757 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
758 | |
759 | |
760 # Check the content of the logged information | |
761 e = DoGet(_REMOTE, '/exports')['Exports'] | |
762 | |
763 if 'PatientID' in e[0]: | |
764 # Since Orthanc 0.8.6 | |
765 patient = 'PatientID' | |
766 study = 'StudyInstanceUID' | |
767 series = 'SeriesInstanceUID' | |
768 instance = 'SOPInstanceUID' | |
769 else: | |
770 # Up to Orthanc 0.8.5 | |
771 patient = 'PatientId' | |
772 study = 'StudyInstanceUid' | |
773 series = 'SeriesInstanceUid' | |
774 instance = 'SopInstanceUid' | |
775 | |
776 for k in range(4): | |
777 self.assertTrue('Date' in e[k]) | |
778 self.assertTrue('Seq' in e[k]) | |
779 self.assertEqual('orthanctest', e[k]['RemoteModality']) | |
780 | |
781 self.assertEqual(10, len(e[0])) | |
782 self.assertEqual('Instance', e[0]['ResourceType']) | |
783 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['ID']) | |
784 self.assertEqual('/instances/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['Path']) | |
785 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', e[0][instance]) | |
786 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[0][series]) | |
787 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[0][study]) | |
788 self.assertEqual('ozp00SjY2xG', e[0][patient]) | |
789 | |
790 self.assertEqual(9, len(e[1])) | |
791 self.assertEqual('Series', e[1]['ResourceType']) | |
792 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['ID']) | |
793 self.assertEqual('/series/f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['Path']) | |
794 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[1][series]) | |
795 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[1][study]) | |
796 self.assertEqual('ozp00SjY2xG', e[1][patient]) | |
797 | |
798 self.assertEqual(8, len(e[2])) | |
799 self.assertEqual('Study', e[2]['ResourceType']) | |
800 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['ID']) | |
801 self.assertEqual('/studies/b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['Path']) | |
802 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[2][study]) | |
803 self.assertEqual('ozp00SjY2xG', e[2][patient]) | |
804 | |
805 self.assertEqual(7, len(e[3])) | |
806 self.assertEqual('Patient', e[3]['ResourceType']) | |
807 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['ID']) | |
808 self.assertEqual('/patients/6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['Path']) | |
809 self.assertEqual('ozp00SjY2xG', e[3][patient]) | |
810 | |
811 DropOrthanc(_REMOTE) | |
812 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
813 | |
814 | |
815 def test_store_peer(self): | |
816 self.assertEqual(0, len(DoGet(_LOCAL, '/exports')['Exports'])) | |
817 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
818 | |
819 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
820 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
821 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
822 | |
823 j = DoPost(_REMOTE, '/peers/peer/store', str(i), 'text/plain') | |
824 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
825 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
826 | |
827 self.assertEqual(1, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
828 | |
829 DropOrthanc(_REMOTE) | |
830 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
831 | |
832 | |
833 def test_bulk_storescu(self): | |
834 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
835 | |
836 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
837 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
838 | |
839 j = DoPost(_REMOTE, '/modalities/orthanctest/store', [ a['ID'], b['ID'] ], 'application/json') | |
840 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
841 | |
842 DropOrthanc(_LOCAL) | |
843 | |
844 # Send using patient's UUID | |
845 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
846 j = DoPost(_REMOTE, '/modalities/orthanctest/store', | |
847 [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ], 'application/json') | |
848 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
849 | |
850 | |
851 def test_color(self): | |
852 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
853 im = GetImage(_REMOTE, '/instances/%s/preview' % i) | |
854 self.assertEqual("RGB", im.mode) | |
855 self.assertEqual(41, im.size[0]) | |
856 self.assertEqual(41, im.size[1]) | |
857 | |
858 # http://effbot.org/zone/pil-comparing-images.htm | |
13 | 859 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) |
11 | 860 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) |
861 | |
862 | |
12 | 863 def test_faking_ruby_put(self): |
864 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
865 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
866 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
867 a = DoGet(_REMOTE, '/patients')[0] | |
868 b = DoGet(_REMOTE, '/patients')[1] | |
869 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
870 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
871 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
872 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '1') | |
873 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
874 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
875 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
876 | |
877 | |
878 def test_faking_ruby_delete(self): | |
879 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
880 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
881 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
882 a = DoGet(_REMOTE, '/patients')[0] | |
883 b = DoGet(_REMOTE, '/patients')[1] | |
884 DoGet(_REMOTE, '/patients/%s' % a, data = { '_method' : 'DELETE' }) | |
885 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
886 DoGet(_REMOTE, '/patients/%s' % b, data = { '_method' : 'DELETE' }) | |
887 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
888 | |
889 | |
890 def test_faking_google_put(self): | |
891 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
892 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
893 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
894 a = DoGet(_REMOTE, '/patients')[0] | |
895 b = DoGet(_REMOTE, '/patients')[1] | |
896 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
897 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
898 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
899 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '1') | |
900 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
901 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
902 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
903 | |
904 | |
905 def test_faking_google_delete(self): | |
906 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
907 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
908 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
909 a = DoGet(_REMOTE, '/patients')[0] | |
910 b = DoGet(_REMOTE, '/patients')[1] | |
911 DoPost(_REMOTE, '/patients/%s' % a, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
912 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
913 DoPost(_REMOTE, '/patients/%s' % b, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
914 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
915 | |
916 | |
917 def test_lua(self): | |
918 self.assertEqual(42, DoPost(_REMOTE, '/tools/execute-script', 'print(42)')) | |
919 self.assertTrue(IsDefinedInLua(_REMOTE, 'PrintRecursive')) | |
920 self.assertFalse(IsDefinedInLua(_REMOTE, 'HelloWorld')) | |
921 | |
922 | |
923 def test_metadata(self): | |
924 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
925 p = DoGet(_REMOTE, '/patients')[0] | |
926 i = DoGet(_REMOTE, '/instances')[0] | |
927 | |
928 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
929 self.assertEqual(1, len(m)) | |
930 self.assertEqual('LastUpdate', m[0]) | |
931 | |
932 m = DoGet(_REMOTE, '/instances/%s/metadata' % i) | |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
933 self.assertEqual(6, len(m)) |
12 | 934 self.assertTrue('IndexInSeries' in m) |
935 self.assertTrue('ReceptionDate' in m) | |
936 self.assertTrue('RemoteAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
937 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
938 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
939 self.assertTrue('SopClassUid' in m) |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
940 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
|
941 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
|
942 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i), '') # None, received by REST API |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
943 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i), '1.2.840.10008.1.2.4.91') # JPEG2k |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
944 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % i), '1.2.840.10008.5.1.4.1.1.4') |
12 | 945 |
946 # Play with custom metadata | |
947 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'coucou') | |
948 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
949 self.assertEqual(2, len(m)) | |
950 self.assertTrue('LastUpdate' in m) | |
951 self.assertTrue('5555' in m) | |
952 self.assertEqual('coucou', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
953 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'hello') | |
954 self.assertEqual('hello', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
955 DoDelete(_REMOTE, '/patients/%s/metadata/5555' % p) | |
956 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
957 self.assertEqual(1, len(m)) | |
958 self.assertTrue('LastUpdate' in m) | |
13 | 959 |
960 | |
961 def test_statistics(self): | |
962 # Upload 16 instances | |
963 for i in range(4): | |
964 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
965 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
966 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
967 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
968 | |
969 s = DoGet(_REMOTE, '/statistics') | |
970 self.assertEqual(16, s['CountInstances']) | |
971 self.assertEqual(2, s['CountPatients']) | |
972 self.assertEqual(2, s['CountStudies']) | |
973 self.assertEqual(4, s['CountSeries']) | |
974 d = int(s['TotalUncompressedSize']) | |
975 | |
976 e = 0 | |
977 for patient in DoGet(_REMOTE, '/patients'): | |
978 s = DoGet(_REMOTE, '/patients/%s/statistics' % patient) | |
979 self.assertEqual(8, s['CountInstances']) | |
980 self.assertEqual(1, s['CountStudies']) | |
981 self.assertEqual(2, s['CountSeries']) | |
982 e += int(s['UncompressedSize']) | |
983 | |
984 for study in DoGet(_REMOTE, '/studies'): | |
985 s = DoGet(_REMOTE, '/studies/%s/statistics' % study) | |
986 self.assertEqual(8, s['CountInstances']) | |
987 self.assertEqual(2, s['CountSeries']) | |
988 e += int(s['UncompressedSize']) | |
989 | |
990 for series in DoGet(_REMOTE, '/series'): | |
991 s = DoGet(_REMOTE, '/series/%s/statistics' % series) | |
992 self.assertEqual(4, s['CountInstances']) | |
993 e += int(s['UncompressedSize']) | |
994 | |
995 self.assertEqual(3 * d, e) | |
996 | |
997 | |
998 def test_custom_attachment(self): | |
999 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1000 patient = DoGet(_REMOTE, '/patients')[0] | |
1001 instance = DoGet(_REMOTE, '/instances')[0] | |
1002 size = int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']) | |
1003 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1004 | |
1005 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1006 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) | |
1007 self.assertTrue('dicom' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1008 self.assertTrue('dicom-as-json' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1009 | |
1010 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/22' % patient, 'hello')) | |
1011 hello = 'hellohellohellohellohellohellohellohellohello' | |
1012 DoPut(_REMOTE, '/patients/%s/attachments/1025' % patient, hello) | |
1013 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1014 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1015 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1016 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient))) | |
1017 | |
1018 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world') | |
1019 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1020 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1021 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1022 size + | |
1023 int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient)) + | |
1024 int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1025 | |
1026 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1027 self.assertEqual(hello, DoGet(_REMOTE, '/patients/%s/attachments/1025/data' % patient)) | |
1028 self.assertEqual('world', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1029 DoPost(_REMOTE, '/patients/%s/attachments/1025/verify-md5' % patient) | |
1030 DoPost(_REMOTE, '/patients/%s/attachments/1026/verify-md5' % patient) | |
1031 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world2') | |
1032 self.assertEqual('world2', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1033 | |
1034 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) | |
1035 DoDelete(_REMOTE, '/patients/%s/attachments/1025' % patient) | |
1036 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1037 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1038 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1039 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1040 | |
1041 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1042 DoDelete(_REMOTE, '/patients/%s/attachments/1026' % patient) | |
1043 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1044 | |
1045 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), size) | |
1046 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1047 | |
1048 | |
1049 def test_incoming_storescu(self): | |
1050 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
45 | 1051 subprocess.check_call([ FindExecutable('storescu'), |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
1052 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
13 | 1053 GetDatabasePath('ColorTestImageJ.dcm') ]) |
1054 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1055 | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1056 i = DoGet(_REMOTE, '/instances') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1057 self.assertEqual(1, len(i)) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1058 m = DoGet(_REMOTE, '/instances/%s/metadata' % i[0]) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1059 self.assertEqual(6, len(m)) |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1060 self.assertTrue('IndexInSeries' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1061 self.assertTrue('ReceptionDate' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1062 self.assertTrue('RemoteAET' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1063 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1064 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1065 self.assertTrue('SopClassUid' in m) |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1066 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
|
1067 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
|
1068 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i[0]), 'STORESCU') |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1069 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i[0]), '1.2.840.10008.1.2.1') |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1070 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % i[0]), '1.2.840.10008.5.1.4.1.1.7') |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1071 |
13 | 1072 |
1073 def test_incoming_findscu(self): | |
1074 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
1075 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') | |
1076 | |
1077 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', '0010,0010' ]) | |
1078 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) | |
1079 self.assertEqual(2, len(patientNames)) | |
1080 self.assertTrue('Test Patient BG ' in patientNames) | |
1081 self.assertTrue('Anonymized' in patientNames) | |
1082 | |
1083 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021' ]) | |
1084 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) | |
1085 self.assertEqual(2, len(series)) | |
1086 self.assertTrue('20070208' in series) | |
1087 self.assertTrue('19980312' in series) | |
1088 | |
56
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1089 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
|
1090 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1091 self.assertEqual(1, len(series)) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1092 self.assertTrue('19980312' in series) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1093 |
13 | 1094 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=Anonymized' ]) |
1095 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1096 self.assertEqual(1, len(series)) | |
1097 | |
1098 # Test the "CaseSentitivePN" flag (false by default) | |
1099 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=anonymized' ]) | |
1100 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1101 self.assertEqual(1, len(series)) | |
66
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1102 |
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1103 # 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
|
1104 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
|
1105 sequences = re.findall('\(0008,2112\)', i) |
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1106 self.assertEqual(1, len(sequences)) |
70 | 1107 |
1108 # Test range search (buggy if Orthanc <= 0.9.6) | |
1109 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-' ]) | |
1110 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1111 self.assertEqual(2, len(studies)) | |
1112 self.assertTrue('20070208' in studies) | |
1113 self.assertTrue('19980312' in studies) | |
1114 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-19980312' ]) | |
1115 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1116 self.assertEqual(1, len(studies)) | |
1117 self.assertTrue('19980312' in studies) | |
1118 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=-19980312' ]) | |
1119 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1120 self.assertEqual(1, len(studies)) | |
1121 self.assertTrue('19980312' in studies) | |
13 | 1122 |
1123 | |
1124 def test_incoming_movescu(self): | |
1125 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1126 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1127 # No matching patient, so no job is created |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1128 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1129 CallMoveScu([ '--patient', '-k', '0008,0052=PATIENT', '-k', 'PatientID=none' ]) |
13 | 1130 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1131 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1132 # 1 Matching patient, track the job |
138 | 1133 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
1134 '--patient', | |
1135 '-k', '0008,0052=PATIENT', | |
1136 '-k', 'PatientID=12345678' | |
1137 ]))) | |
13 | 1138 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
1139 | |
1140 | |
1141 def test_findscu(self): | |
1142 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1143 j = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
1144 k = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] | |
1145 DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1146 | |
1147 # Test the "find-patient" level | |
1148 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1149 self.assertEqual(1, len(p)) | |
1150 self.assertEqual('ozp00SjY2xG', p[0]['PatientID']) | |
1151 | |
1152 # Test wildcards constraints. The "LO" value representation | |
1153 # for PatientID is always case-sensitive, but the "PN" for | |
1154 # PatientName might depend on the implementation: | |
1155 # "GenerateConfigurationForTests.py" will force it to be case | |
1156 # insensitive (which was the default until Orthanc 0.8.6). | |
1157 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'K*' }) | |
1158 self.assertEqual(1, len(p)) | |
1159 | |
1160 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'k*' }) | |
1161 self.assertEqual(1, len(p)) | |
1162 | |
1163 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'ozp*' }) | |
1164 self.assertEqual(1, len(p)) | |
1165 | |
1166 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'o?p*' }) | |
1167 self.assertEqual(1, len(p)) | |
1168 | |
1169 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : '0?q*' }) | |
1170 self.assertEqual(0, len(p)) | |
1171 | |
1172 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'B*' }) | |
1173 self.assertEqual(0, len(p)) | |
1174 | |
1175 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'b*' }) | |
1176 self.assertEqual(0, len(p)) | |
1177 | |
1178 DoPost(_REMOTE, '/modalities/orthanctest/store', str(j), 'text/plain') | |
1179 DoPost(_REMOTE, '/modalities/orthanctest/store', str(k), 'text/plain') | |
1180 DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1181 self.assertEqual(3, len(DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }))) | |
1182 | |
1183 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'A*' }) | |
1184 self.assertEqual(2, len(p)) | |
1185 | |
1186 # Test the "find-study" level. This is the instance "ColorTestImageJ.dcm" | |
1187 s = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ' }) | |
1188 self.assertEqual(1, len(s)) | |
1189 self.assertEqual('20070208', s[0]['StudyDate']) | |
1190 | |
1191 # Test range searches | |
1192 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1193 'StudyDate' : '-20070101' }) | |
1194 self.assertEqual(0, len(t)) | |
1195 | |
1196 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1197 'StudyDate' : '20090101-' }) | |
1198 self.assertEqual(0, len(t)) | |
1199 | |
1200 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1201 'StudyDate' : '20070101-' }) | |
1202 self.assertEqual(1, len(t)) | |
1203 | |
1204 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1205 'StudyDate' : '-20090101' }) | |
1206 self.assertEqual(1, len(t)) | |
1207 | |
1208 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1209 'StudyDate' : '20070207-20070207' }) | |
1210 self.assertEqual(0, len(t)) | |
1211 | |
1212 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1213 'StudyDate' : '20070208-20070208' }) | |
1214 self.assertEqual(1, len(t)) | |
1215 | |
1216 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1217 'StudyDate' : '20070209-20070209' }) | |
1218 self.assertEqual(0, len(t)) | |
1219 | |
1220 # Test the ModalitiesInStudy tag | |
1221 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1222 'PatientID' : 'B9uTHKOZ', | |
1223 'ModalitiesInStudy' : 'US' }) | |
1224 self.assertEqual(0, len(t)) | |
1225 | |
1226 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1227 'PatientID' : 'B9uTHKOZ', | |
1228 'ModalitiesInStudy' : 'CT' }) | |
1229 self.assertEqual(1, len(t)) | |
1230 | |
1231 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1232 'PatientID' : 'B9uTHKOZ', | |
1233 'ModalitiesInStudy' : 'US\\CT' }) | |
1234 self.assertEqual(1, len(t)) | |
1235 | |
1236 # Test the "find-series" level | |
1237 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1238 'PatientID' : 'B9uTHKOZ', | |
1239 'StudyInstanceUID' : s[0]['StudyInstanceUID'] }) | |
1240 self.assertEqual(1, len(t)) | |
1241 | |
1242 # Test "\" separator | |
1243 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1244 'PatientID' : 'B9uTHKOZ', | |
1245 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1246 'Modality' : 'MR\\CT\\US' }) | |
1247 self.assertEqual(1, len(t)) | |
1248 | |
1249 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1250 'PatientID' : 'B9uTHKOZ', | |
1251 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1252 'Modality' : 'MR\\US' }) | |
1253 self.assertEqual(0, len(t)) | |
1254 | |
1255 | |
1256 def test_update_modalities(self): | |
1257 try: | |
1258 DoDelete(_REMOTE, '/modalities/toto') | |
1259 except: | |
1260 pass | |
1261 try: | |
1262 DoDelete(_REMOTE, '/modalities/tata') | |
1263 except: | |
1264 pass | |
1265 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1266 DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000 ]) | |
116 | 1267 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'MedInria' ]) # check backward compatiblity with obsolete manufacturer |
1268 DoDelete(_REMOTE, '/modalities/tata') | |
124 | 1269 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoUniversalWildcard' ]) |
121
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1270 DoDelete(_REMOTE, '/modalities/tata') |
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1271 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoWildcardInDates' ]) |
128 | 1272 modalitiesReadback = DoGet(_REMOTE, '/modalities?expand') |
1273 self.assertEqual([ "STORESCP", "localhost", 2000, 'GenericNoWildcardInDates' ], modalitiesReadback['tata']) | |
116 | 1274 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000, 'InvalidManufacturerName' ])) |
13 | 1275 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/toto')) |
1276 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/tata')) | |
1277 DoDelete(_REMOTE, '/modalities/toto') | |
1278 DoDelete(_REMOTE, '/modalities/tata') | |
1279 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1280 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/tata')) | |
1281 | |
1282 | |
1283 def test_update_peers(self): | |
1284 # curl -X PUT http://localhost:8042/peers/toto -d '["http://localhost:8042/"]' -v | |
1285 try: | |
1286 DoDelete(_REMOTE, '/peers/toto') | |
1287 except: | |
1288 pass | |
1289 try: | |
1290 DoDelete(_REMOTE, '/peers/tata') | |
1291 except: | |
1292 pass | |
1293 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1294 DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/' ]) | |
1295 DoPut(_REMOTE, '/peers/tata', [ 'http://localhost:8042/', 'user', 'pass' ]) | |
128 | 1296 self.assertTrue('tata' in DoGet(_REMOTE, '/peers')) |
1297 peersReadback = DoGet(_REMOTE, '/peers?expand') | |
1298 self.assertEqual('http://localhost:8042/', peersReadback['tata']['Url']) | |
1299 self.assertEqual('user', peersReadback['tata']['Username']) | |
1300 self.assertFalse('Password' in peersReadback['tata']) # make sure no sensitive data is included | |
1301 self.assertFalse('CertificateFile' in peersReadback['tata']) # make sure no sensitive data is included | |
1302 self.assertFalse('CertificateKeyFile' in peersReadback['tata']) # make sure no sensitive data is included | |
1303 self.assertFalse('CertificateKeyPassword' in peersReadback['tata']) # make sure no sensitive data is included | |
1304 self.assertFalse('Pkcs11' in peersReadback['tata']) # make sure no sensitive data is included | |
13 | 1305 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a' ])) |
1306 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a', 'b', 'c' ])) | |
1307 self.assertTrue('store' in DoGet(_REMOTE, '/peers/toto')) | |
1308 self.assertTrue('store' in DoGet(_REMOTE, '/peers/tata')) | |
1309 DoDelete(_REMOTE, '/peers/toto') | |
1310 DoDelete(_REMOTE, '/peers/tata') | |
1311 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1312 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/tata')) | |
1313 | |
1314 | |
1315 def test_mesterhazy_modification(self): | |
1316 # When I modify a series ( eg. curl | |
1317 # http://localhost:8042/series/uidhere/modify -X POST -d | |
1318 # '{"Replace":{"SeriesDate":"19990101"}}' ) the modified | |
1319 # series is added to a new Study, instead of the existing | |
1320 # Study. Fixed in Orthanc 0.7.5 | |
1321 | |
1322 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1323 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1324 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1325 | |
1326 modified = DoPost(_REMOTE, '/series/%s/modify' % series, | |
1327 json.dumps({ "Replace" : { "SeriesDate" : "19990101" }})) | |
1328 | |
1329 self.assertEqual(study, DoGet(_REMOTE, '/series/%s' % modified['ID']) ['ParentStudy']) | |
1330 | |
1331 | |
1332 def test_create(self): | |
1333 i = DoPost(_REMOTE, '/tools/create-dicom', | |
1334 json.dumps({ | |
1335 'PatientName' : 'Jodogne', | |
1336 'Modality' : 'CT', | |
58 | 1337 'SOPClassUID' : '1.2.840.10008.5.1.4.1.1.1', |
13 | 1338 'PixelData' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' # red dot in RGBA |
1339 })) | |
1340 | |
1341 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
1342 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
1343 | |
1344 png = GetImage(_REMOTE, '/instances/%s/preview' % i['ID']) | |
1345 self.assertEqual((5, 5), png.size) | |
1346 | |
38 | 1347 j = DoGet(_REMOTE, i['Path']) |
1348 self.assertEqual('Instance', j['Type']) | |
1349 self.assertEqual(j['ID'], i['ID']) | |
1350 | |
13 | 1351 |
1352 def test_pilates(self): | |
1353 # "SCU failed error when accessing orthanc with osirix" by | |
1354 # Pilates Agentur (Mar 10, 2014 at 9:33 PM) | |
1355 i = UploadInstance(_REMOTE, 'PilatesArgenturGEUltrasoundOsiriX.dcm')['ID'] | |
1356 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
1357 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1358 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
1359 | |
1360 | |
1361 def test_shared_tags(self): | |
1362 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1363 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm')['ID'] | |
1364 p = DoGet(_REMOTE, '/patients')[0] | |
1365 | |
1366 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1367 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1368 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags?short' % p)) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1369 |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1370 self.assertEqual('KNEE', DoGet(_REMOTE, '/patients/%s/shared-tags' % p)['0010,0010']['Value']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1371 self.assertEqual('KNEE', DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)['PatientName']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1372 self.assertEqual('KNEE', DoGet(_REMOTE, '/patients/%s/shared-tags?short' % p)['0010,0010']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1373 |
13 | 1374 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) |
1375 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1376 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1377 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1378 self.assertFalse('0008,0018' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1379 self.assertFalse('SOPInstanceUID' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1380 | |
1381 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/tags' % a)) | |
1382 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)) | |
1383 | |
1384 | |
1385 def test_modules(self): | |
1386 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1387 p = DoGet(_REMOTE, '/patients')[0] | |
1388 s = DoGet(_REMOTE, '/studies')[0] | |
1389 t = DoGet(_REMOTE, '/series')[0] | |
1390 | |
1391 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/module' % p)) | |
1392 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/module?simplify' % p)) | |
1393 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/studies/%s/module-patient' % p)) | |
1394 self.assertTrue('PatientName' in DoGet(_REMOTE, '/studies/%s/module-patient?simplify' % p)) | |
1395 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/studies/%s/module' % s)) | |
1396 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/studies/%s/module?simplify' % s)) | |
1397 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/series/%s/module' % p)) | |
1398 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/series/%s/module?simplify' % p)) | |
1399 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/module' % a)) | |
1400 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/module?simplify' % a)) | |
1401 | |
1402 | |
1403 def test_auto_directory(self): | |
1404 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1405 self.assertTrue('now' in DoGet(_REMOTE, '/tools')) | |
1406 self.assertTrue('dicom-conformance' in DoGet(_REMOTE, '/tools')) | |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
1407 self.assertTrue('invalidate-tags' in DoGet(_REMOTE, '/tools')) |
13 | 1408 self.assertTrue(len(DoGet(_REMOTE, '/tools/dicom-conformance')) > 1000) |
1409 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
1410 self.assertTrue('echo' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1411 self.assertTrue('find' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1412 self.assertTrue('find-instance' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1413 self.assertTrue('find-patient' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1414 self.assertTrue('find-series' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1415 self.assertTrue('find-study' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1416 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1417 self.assertTrue('store' in DoGet(_REMOTE, '/peers/peer')) | |
1418 self.assertTrue('matlab' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) | |
79 | 1419 self.assertTrue('raw' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) |
13 | 1420 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/tools/nope')) |
28 | 1421 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope')) |
1422 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope/nope.html')) | |
1423 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope')[0].status) | |
1424 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope/nope.html')[0].status) | |
13 | 1425 |
1426 | |
1427 def test_echo(self): | |
1428 DoPost(_REMOTE, '/modalities/orthanctest/echo') | |
1429 | |
1430 | |
1431 def test_xml(self): | |
1432 json = DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/json' }) | |
1433 xml = minidom.parseString(DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/xml' })) | |
1434 items = xml.getElementsByTagName('root')[0].getElementsByTagName('item') | |
1435 self.assertEqual(len(items), len(json)) | |
1436 | |
1437 self.assertTrue('dicom-conformance' in json) | |
1438 | |
1439 ok = False | |
1440 for i in items: | |
1441 if i.childNodes[0].data == 'dicom-conformance': | |
1442 ok = True | |
1443 self.assertTrue(ok) | |
1444 | |
1445 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1446 def test_googlecode_issue_16(self): |
13 | 1447 i = UploadInstance(_REMOTE, 'Issue16.dcm')['ID'] |
1448 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['FrameIncrementPointer'] | |
1449 self.assertEqual('0018,1063', t) | |
1450 | |
1451 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1452 def test_googlecode_issue_22(self): |
13 | 1453 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] |
1454 a = [ | |
1455 "f804691f62197040438f4627c6b994f1", # Frame 0 | |
1456 "c69eee9a51eea3e8611e82e578897254", | |
1457 "315666be83e2d0111c77bc0996d84901", | |
1458 "3e27aa959d911172c48a1436443c72b1", | |
1459 "958642c9e7e9d232d3869faff546058c", | |
1460 "5e7ea8e3e4230cae707d143481355c59", | |
1461 "eda37f83558d858a596175aed8b2ad47", | |
1462 "486713bd2895c4ecbe0e97715ac7f80a", | |
1463 "091ef729eb169e67da8a0faa9631f9a8", | |
1464 "5aa2b8c7ffe0a483efaa8e12417686ca", | |
1465 "e2f39e85896fe58876654b94cd0b5013", | |
1466 "6fd2129e4950abbe1be053bc814d5da8", | |
1467 "c3331a8ba7a757f3d423735ab7fa81f9", | |
1468 "746f808582156734dd6b6fdfd3a0b72c", | |
1469 "8075ea2b227a70c60ea6b7b75a6bb190", | |
1470 "806b8b3e300c615099c11a5ec23465aa", | |
1471 "7c836aa298ba6eef96434579af631a11", | |
1472 "a0357dc9f4f72d73a885c33d7c287446", | |
1473 "f25ba3be1cc7d7fad95706adc199ea7d", | |
1474 "8b114c526b8cbed6cad8a3248b7b480c", | |
1475 "44e6670f127e612a2b4aa60a0d207698", | |
1476 "b8945f90fe02facf2ace24ca1ecbe0a5", | |
1477 "95c796c2fa8f59018b15cf2987b1f79b", | |
1478 "ce0a51ab30224205b44920221dc27351", # Frame 23 | |
1479 ] | |
1480 | |
1481 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
1482 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/preview' % s)) | |
1483 | |
1484 for i in range(len(a)): | |
1485 self.assertEqual(a[i], ComputeMD5(DoGet(_REMOTE, '/instances/%s/frames/%d/preview' % (s, i)))) | |
1486 | |
1487 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1488 def test_googlecode_issue_19(self): |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1489 # This is an image with "YBR_FULL" photometric interpretation, it is not supported by Orthanc |
13 | 1490 # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm |
1491 | |
1492 a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID'] | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1493 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) |
13 | 1494 |
1495 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1496 def test_googlecode_issue_37(self): |
13 | 1497 # Same test for issues 35 and 37. Fixed in Orthanc 0.9.1 |
1498 u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] | |
1499 | |
1500 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1501 'CaseSensitive' : True, | |
1502 'Query' : { 'StationName' : 'SMR4-MP3' }}) | |
1503 self.assertEqual(1, len(a)) | |
14 | 1504 |
1505 | |
1506 def test_rest_find(self): | |
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 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1515 'CaseSensitive' : False, | |
1516 'Query' : { 'PatientName' : '*n*' }}) | |
1517 self.assertEqual(2, len(a)) | |
1518 | |
1519 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1520 'CaseSensitive' : True, | |
1521 'Query' : { 'PatientName' : '*n*' }}) | |
1522 self.assertEqual(0, len(a)) | |
1523 | |
1524 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, | |
1525 'Level' : 'Patient', | |
1526 'CaseSensitive' : False, | |
1527 'Query' : { 'PatientName' : '*ne*' }}) | |
1528 self.assertEqual(1, len(a)) | |
1529 self.assertEqual('20080822', a[0]['MainDicomTags']['PatientBirthDate']) | |
1530 | |
1531 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1532 'CaseSensitive' : True, | |
1533 'Query' : { 'PatientName' : '*ne*' }}) | |
1534 self.assertEqual(0, len(a)) | |
1535 | |
1536 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', | |
1537 'CaseSensitive' : True, | |
1538 'Query' : { 'PatientName' : '*NE*' }}) | |
1539 self.assertEqual(1, len(a)) | |
1540 | |
1541 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1542 'CaseSensitive' : True, | |
1543 'Query' : { 'PatientName' : '*NE*' }}) | |
1544 self.assertEqual(2, len(a)) | |
1545 | |
1546 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
1547 'CaseSensitive' : True, | |
1548 'Query' : { 'PatientName' : '*NE*' }}) | |
1549 self.assertEqual(4, len(a)) | |
1550 | |
1551 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', 'Query' : { }}) | |
1552 self.assertEqual(2, len(a)) | |
1553 | |
1554 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', 'Query' : { }}) | |
1555 self.assertEqual(2, len(a)) | |
1556 | |
1557 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', 'Query' : { }}) | |
1558 self.assertEqual(4, len(a)) | |
1559 | |
1560 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', 'Query' : { }}) | |
1561 self.assertEqual(8, len(a)) | |
1562 | |
1563 | |
1564 def test_rest_query_retrieve(self): | |
1565 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1566 | |
1567 # Upload 8 instances | |
1568 for i in range(2): | |
1569 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1570 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1571 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1572 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1573 | |
1574 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1575 for p in DoGet(_REMOTE, '/patients'): | |
1576 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
1577 DoDelete(_REMOTE, '/patients/%s' % p) | |
1578 | |
1579 for q in DoGet(_REMOTE, '/queries'): | |
1580 DoDelete(_REMOTE, '/queries/%s' % q) | |
1581 | |
1582 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1583 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1584 a = DoPost(_REMOTE, '/modalities/orthanctest/query', { 'Level' : 'Series', | |
27 | 1585 'Query' : { |
1586 'PatientName' : '*NE*', | |
1587 'StudyDate' : '*', | |
1588 }})['ID'] | |
14 | 1589 self.assertEqual(1, len(DoGet(_REMOTE, '/queries'))) |
1590 | |
1591 b = DoGet(_REMOTE, '/queries/%s' % a) | |
1592 self.assertTrue('answers' in b) | |
1593 self.assertTrue('level' in b) | |
1594 self.assertTrue('modality' in b) | |
1595 self.assertTrue('query' in b) | |
1596 self.assertTrue('retrieve' in b) | |
1597 self.assertEqual('Series', DoGet(_REMOTE, '/queries/%s/level' % a)) | |
1598 self.assertEqual('orthanctest', DoGet(_REMOTE, '/queries/%s/modality' % a)) | |
1599 | |
1600 q = DoGet(_REMOTE, '/queries/%s/query?simplify' % a) | |
27 | 1601 self.assertEqual(2, len(q)) |
14 | 1602 self.assertTrue('PatientName' in q) |
27 | 1603 self.assertTrue('StudyDate' in q) |
14 | 1604 self.assertEqual('*NE*', q['PatientName']) |
27 | 1605 self.assertEqual('*', q['StudyDate']) |
14 | 1606 |
1607 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) | |
1608 | |
1609 s = DoGet(_REMOTE, '/queries/%s/answers/0' % a) | |
1610 self.assertTrue('content' in s) | |
1611 self.assertTrue('retrieve' in s) | |
1612 | |
1613 s = DoGet(_REMOTE, '/queries/%s/answers/0/content?simplify' % a) | |
1614 self.assertEqual('887', s['PatientID']) | |
1615 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s['StudyInstanceUID']) | |
1616 | |
1617 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1618 DoPost(_REMOTE, '/queries/%s/answers/0/retrieve' % a, 'ORTHANC') | |
1619 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1620 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1621 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
1622 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
1623 | |
112 | 1624 DoPost(_REMOTE, '/queries/%s/answers/1/retrieve' % a, 'ORTHANC', 'application/json') # make sure the issue #36 is fixed (query/retrieve Rest API: /retrieve route shall accept application/json content type) |
14 | 1625 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
1626 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1627 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1628 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
1629 | |
1630 DoDelete(_REMOTE, '/queries/%s' % a) | |
1631 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1632 | |
1633 | |
1634 def test_parent(self): | |
1635 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1636 patient = '6816cb19-844d5aee-85245eba-28e841e6-2414fae2' | |
1637 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1638 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1639 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
1640 self.assertEqual(instance, u) |
14 | 1641 |
1642 a = DoGet(_REMOTE, '/studies/%s/patient' % study) | |
1643 self.assertEqual('Patient', a['Type']) | |
1644 self.assertEqual(patient, a['ID']) | |
1645 | |
1646 a = DoGet(_REMOTE, '/series/%s/patient' % series) | |
1647 self.assertEqual('Patient', a['Type']) | |
1648 self.assertEqual(patient, a['ID']) | |
1649 | |
1650 a = DoGet(_REMOTE, '/series/%s/study' % series) | |
1651 self.assertEqual('Study', a['Type']) | |
1652 self.assertEqual(study, a['ID']) | |
1653 | |
1654 a = DoGet(_REMOTE, '/instances/%s/patient' % instance) | |
1655 self.assertEqual('Patient', a['Type']) | |
1656 self.assertEqual(patient, a['ID']) | |
1657 | |
1658 a = DoGet(_REMOTE, '/instances/%s/study' % instance) | |
1659 self.assertEqual('Study', a['Type']) | |
1660 self.assertEqual(study, a['ID']) | |
1661 | |
1662 a = DoGet(_REMOTE, '/instances/%s/series' % instance) | |
1663 self.assertEqual('Series', a['Type']) | |
1664 self.assertEqual(series, a['ID']) | |
1665 | |
1666 | |
1667 def test_shanon(self): | |
1668 def Anonymize(instance, replacements = {}): | |
119 | 1669 return DoPost(_REMOTE, '/instances/%s/anonymize' % instance, { |
1670 'Replace' : replacements, | |
1671 'Force' : True, | |
1672 }, 'application/json') | |
14 | 1673 |
1674 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1675 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1676 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1677 | |
1678 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1679 ids = [ 'ozp00SjY2xG', | |
1680 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1681 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1682 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1683 | |
1684 a = ExtractDicomTags(Anonymize(u), tags) | |
1685 for i in range(4): | |
1686 self.assertNotEqual(ids[i], a[i]) | |
1687 self.assertTrue(a[4].startswith('Orthanc')) | |
1688 | |
1689 a = ExtractDicomTags(Anonymize(u, { 'PatientName' : 'toto' }), tags) | |
1690 for i in range(4): | |
1691 self.assertNotEqual(ids[i], a[i]) | |
1692 self.assertFalse(a[4].startswith('Orthanc')) | |
1693 | |
1694 a = ExtractDicomTags(Anonymize(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1695 self.assertEqual('instance', a[3]) | |
1696 self.assertFalse(a[4].startswith('Orthanc')) | |
1697 | |
1698 a = ExtractDicomTags(Anonymize(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1699 self.assertEqual('series', a[2]) | |
1700 self.assertFalse(a[4].startswith('Orthanc')) | |
1701 | |
1702 a = ExtractDicomTags(Anonymize(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1703 self.assertEqual('study', a[1]) | |
1704 self.assertFalse(a[4].startswith('Orthanc')) | |
1705 | |
1706 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient' }), tags) | |
1707 self.assertEqual('patient', a[0]) | |
1708 self.assertFalse(a[4].startswith('Orthanc')) | |
1709 | |
1710 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient', | |
1711 'StudyInstanceUID' : 'study', | |
1712 'SeriesInstanceUID' : 'series', | |
1713 'SOPInstanceUID' : 'instance' }), tags) | |
1714 self.assertEqual('patient', a[0]) | |
1715 self.assertFalse(a[4].startswith('Orthanc')) | |
1716 | |
1717 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1718 | |
1719 | |
1720 def test_shanon_2(self): | |
1721 def Modify(instance, replacements = {}): | |
119 | 1722 return DoPost(_REMOTE, '/instances/%s/modify' % instance, { |
1723 'Replace' : replacements, | |
1724 'Force': True, | |
1725 }, 'application/json') | |
14 | 1726 |
1727 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1728 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1729 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1730 | |
1731 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1732 ids = [ 'ozp00SjY2xG', | |
1733 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1734 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1735 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1736 | |
1737 a = ExtractDicomTags(Modify(u), tags) | |
1738 self.assertEqual(ids[0], a[0]) | |
1739 self.assertEqual(ids[1], a[1]) | |
1740 self.assertEqual(ids[2], a[2]) | |
1741 self.assertNotEqual(ids[3], a[3]) | |
1742 self.assertEqual(0, len(a[4])) | |
1743 | |
1744 a = ExtractDicomTags(Modify(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1745 self.assertEqual(ids[0], a[0]) | |
1746 self.assertEqual(ids[1], a[1]) | |
1747 self.assertEqual(ids[2], a[2]) | |
1748 self.assertEqual('instance', a[3]) | |
1749 | |
1750 a = ExtractDicomTags(Modify(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1751 self.assertEqual(ids[0], a[0]) | |
1752 self.assertEqual(ids[1], a[1]) | |
1753 self.assertEqual('series', a[2]) | |
1754 self.assertNotEqual(ids[3], a[3]) | |
1755 | |
1756 a = ExtractDicomTags(Modify(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1757 self.assertEqual(ids[0], a[0]) | |
1758 self.assertEqual('study', a[1]) | |
1759 self.assertNotEqual(ids[2], a[2]) | |
1760 self.assertNotEqual(ids[3], a[3]) | |
1761 | |
1762 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient' }), tags) | |
1763 self.assertEqual('patient', a[0]) | |
1764 self.assertNotEqual(ids[1], a[1]) | |
1765 self.assertNotEqual(ids[2], a[2]) | |
1766 self.assertNotEqual(ids[3], a[3]) | |
1767 | |
1768 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient', | |
1769 'StudyInstanceUID' : 'study', | |
1770 'SeriesInstanceUID' : 'series', | |
1771 'SOPInstanceUID' : 'instance' }), tags) | |
1772 self.assertEqual('patient', a[0]) | |
1773 self.assertEqual('study', a[1]) | |
1774 self.assertEqual('series', a[2]) | |
1775 self.assertEqual('instance', a[3]) | |
1776 | |
1777 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1778 | |
1779 | |
1780 def test_instances_tags(self): | |
1781 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1782 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] | |
1783 #a = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386937.676343')['ID'] | |
1784 #b = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386925.676329')['ID'] | |
1785 | |
1786 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/patients')[0]) | |
1787 self.assertEqual(2, len(i)) | |
1788 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1789 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1790 | |
1791 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/studies')[0]) | |
1792 self.assertEqual(2, len(i)) | |
1793 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1794 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1795 | |
1796 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1797 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[0]) | |
1798 self.assertEqual(1, len(i)) | |
1799 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1800 | |
1801 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[1]) | |
1802 self.assertEqual(1, len(i)) | |
1803 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1804 | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1805 i = DoGet(_REMOTE, '/patients/%s/instances-tags?short' % DoGet(_REMOTE, '/series')[1]) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1806 self.assertEqual(1, len(i)) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1807 self.assertEqual('887', i[i.keys()[0]]['0010,0020']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1808 |
14 | 1809 |
1810 def test_lookup(self): | |
1811 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
1812 self.assertEqual(0, len(a)) | |
1813 | |
1814 UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1815 | |
1816 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
1817 self.assertEqual(1, len(a)) | |
1818 self.assertEqual('Patient', a[0]['Type']) | |
1819 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', a[0]['ID']) | |
1820 self.assertEqual('/patients/%s' % a[0]['ID'], a[0]['Path']) | |
1821 | |
1822 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390') | |
1823 self.assertEqual(1, len(a)) | |
1824 self.assertEqual('Study', a[0]['Type']) | |
1825 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', a[0]['ID']) | |
1826 self.assertEqual('/studies/%s' % a[0]['ID'], a[0]['Path']) | |
1827 | |
1828 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394') | |
1829 self.assertEqual(1, len(a)) | |
1830 self.assertEqual('Series', a[0]['Type']) | |
1831 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', a[0]['ID']) | |
1832 self.assertEqual('/series/%s' % a[0]['ID'], a[0]['Path']) | |
1833 | |
1834 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109') | |
1835 self.assertEqual(1, len(a)) | |
1836 self.assertEqual('Instance', a[0]['Type']) | |
1837 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a[0]['ID']) | |
1838 self.assertEqual('/instances/%s' % a[0]['ID'], a[0]['Path']) | |
1839 | |
1840 DropOrthanc(_REMOTE) | |
1841 a = DoPost(_REMOTE, '/tools/lookup', '3113719P') | |
1842 self.assertEqual(0, len(a)) | |
1843 | |
15 | 1844 |
1845 def test_autorouting(self): | |
1846 knee1 = 'Knee/T1/IM-0001-0001.dcm' | |
1847 knee2 = 'Knee/T2/IM-0001-0002.dcm' | |
1848 other = 'Brainix/Flair/IM-0001-0001.dcm' | |
1849 | |
1850 # Check that this version is >= 0.8.0 | |
1851 self.assertTrue(IsDefinedInLua(_REMOTE, '_InitializeJob')) | |
1852 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
1853 | |
1854 UploadInstance(_REMOTE, knee1) | |
1855 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
1856 | |
1857 DropOrthanc(_REMOTE) | |
1858 DropOrthanc(_LOCAL) | |
1859 InstallLuaScript('Lua/Autorouting.lua') | |
1860 UploadInstance(_REMOTE, knee1) | |
1861 UploadInstance(_REMOTE, knee2) | |
1862 UploadInstance(_REMOTE, other) | |
1863 WaitEmpty(_REMOTE) | |
1864 UninstallLuaCallbacks() | |
1865 self.assertEqual(3, len(DoGet(_LOCAL, '/instances'))) | |
1866 | |
1867 DropOrthanc(_REMOTE) | |
1868 DropOrthanc(_LOCAL) | |
1869 InstallLuaScript('Lua/AutoroutingConditional.lua') | |
1870 UploadInstance(_REMOTE, knee1) | |
1871 UploadInstance(_REMOTE, knee2) | |
1872 UploadInstance(_REMOTE, other) | |
1873 WaitEmpty(_REMOTE) | |
1874 UninstallLuaCallbacks() | |
1875 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
1876 | |
1877 DropOrthanc(_REMOTE) | |
1878 DropOrthanc(_LOCAL) | |
1879 InstallLuaScript('Lua/AutoroutingModification.lua') | |
1880 UploadInstance(_REMOTE, knee1) | |
1881 WaitEmpty(_REMOTE) | |
1882 UninstallLuaCallbacks() | |
1883 i = DoGet(_LOCAL, '/instances') | |
1884 self.assertEqual(1, len(i)) | |
1885 | |
1886 with tempfile.NamedTemporaryFile(delete = True) as f: | |
1887 f.write(DoGet(_LOCAL, '/instances/%s/file' % i[0])) | |
1888 f.flush() | |
45 | 1889 routed = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
15 | 1890 self.assertEqual('My Medical Device', re.search('"StationName">(.*?)<', routed).group(1).strip()) |
1891 self.assertEqual(None, re.search('"MilitaryRank"', routed)) | |
1892 self.assertEqual(None, re.search('"0051,0010"', routed)) # A private tag | |
17 | 1893 |
1894 | |
1895 def test_storescu_rf(self): | |
1896 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] | |
1897 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
1898 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1899 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
18 | 1900 |
1901 | |
1902 def test_anonymize_instance(self): | |
1903 def AnonymizeAndUpload(instanceId, parameters): | |
1904 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/anonymize' % instanceId, parameters, | |
1905 'application/json'), 'application/dicom')['ID'] | |
1906 | |
1907 def ModifyAndUpload(instanceId, parameters): | |
1908 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/modify' % instanceId, parameters, | |
1909 'application/json'), 'application/dicom')['ID'] | |
1910 | |
1911 a = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
1912 s1 = DoGet(_REMOTE, '/instances/%s/content/PatientName' % a) | |
1913 s2 = DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % a) # Some private tag | |
1914 s3 = DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % a) | |
1915 s4 = DoGet(_REMOTE, '/instances/%s/content/SeriesDescription' % a) | |
1916 s5 = DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
1917 | |
1918 b = AnonymizeAndUpload(a, '{}') | |
1919 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
1920 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1921 | |
1922 # Keep private tag (only OK since Orthanc 0.8.0) | |
1923 b = AnonymizeAndUpload(a, '{"Keep":["00e1-10c2"]}') | |
1924 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
1925 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1926 | |
1927 b = AnonymizeAndUpload(a, '{"Keep":["00e1,10c2","PatientName"]}') | |
1928 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
1929 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1930 | |
1931 b = AnonymizeAndUpload(a, '{"Keep":["PatientName"],"Replace":{"00e1,10c2":"Hello"}}') | |
1932 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
1933 self.assertTrue(DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b).startswith('Hello')) | |
1934 | |
1935 # Examples from the Wiki | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
1936 b = AnonymizeAndUpload(a, '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": true,"Force":true}') |
18 | 1937 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
1938 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
1939 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
1940 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
1941 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
1942 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1943 DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
1944 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
1945 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
1946 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Remove":["InstitutionName"],"RemovePrivateTags": true,"Force":true}') |
18 | 1947 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
1948 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
1949 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
1950 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
1951 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
1952 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
1953 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
1954 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Force":true}') |
18 | 1955 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
1956 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
1957 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1,10c2' % b)) | |
1958 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
1959 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
1960 self.assertEqual(s5, DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
1961 | |
1962 | |
1963 # Test modify non-existing | |
1964 i = DoPost(_REMOTE, '/tools/create-dicom', | |
1965 json.dumps({ | |
1966 'PatientName' : 'Jodogne', | |
1967 'Modality' : 'CT', | |
1968 }))['ID'] | |
1969 | |
1970 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i).strip()) | |
1971 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % i)) | |
1972 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i).strip()) | |
1973 | |
1974 b = ModifyAndUpload(i, '{"Replace":{"StudyDescription":"hello","Modality":"world"}}') | |
1975 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % b).strip()) | |
1976 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % b).strip()) | |
1977 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/Modality' % b).strip()) | |
1978 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1979 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1980 def test_incoming_jpeg(self): |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1981 def storescu(image, acceptUnknownSopClassUid): |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1982 if acceptUnknownSopClassUid: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1983 tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1984 else: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1985 tmp = [ '-xs' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1986 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1987 with open(os.devnull, 'w') as FNULL: |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1988 subprocess.check_call([ FindExecutable('storescu') ] + tmp + |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1989 [ _REMOTE['Server'], str(_REMOTE['DicomPort']), |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1990 GetDatabasePath(image) ], |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1991 stderr = FNULL) |
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 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1994 InstallLuaScript('Lua/TransferSyntaxDisable.lua') |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
1995 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
|
1996 self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True)) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1997 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1998 InstallLuaScript('Lua/TransferSyntaxEnable.lua') |
62
f9c4ce95756f
removal of useless information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
61
diff
changeset
|
1999 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
|
2000 storescu('Knix/Loc/IM-0001-0001.dcm', False) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2001 storescu('UnknownSopClassUid.dcm', True) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2002 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
21
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_storescu_jpeg(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2006 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2007 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2008 knixStudy = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
64 | 2009 i = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
2010 | |
2011 # This is JPEG lossless | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2012 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header' % i)['0002,0010']['Value']) |
64 | 2013 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2014 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?short' % i)['0002,0010']) |
64 | 2015 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2016 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0002.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2017 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0003.dcm') |
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 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
|
2020 b = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2021 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2022 DoPost(_REMOTE, '/modalities/orthanctest/store', [ knixStudy, a, b ]) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2023 self.assertEqual(5, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2024 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2025 self.assertEqual(3, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2026 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2027 DropOrthanc(_REMOTE) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2028 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2029 |
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 def test_pixel_data(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2032 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
|
2033 color = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2034 phenix = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2035 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2036 phenixSize = 358 * 512 * 2 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2037 colorSize = 1000 * 1000 * 3 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2038 jpegSize = 51918 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2039 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2040 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
|
2041 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
|
2042 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
|
2043 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2044 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
|
2045 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
|
2046 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2047 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
|
2048 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
|
2049 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2050 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2051 def test_decode_brainix(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2052 brainix = [ |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2053 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'], # (*) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2054 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
|
2055 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
|
2056 ] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2057 h = '6fb11b932d535c2be04beabd99793ff8' |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2058 maxValue = 426.0 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2059 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2060 truth = Image.open(GetDatabasePath('Formats/Brainix.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2061 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2062 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2063 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2064 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2065 truth2 = map(lambda x: min(255, x), truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2066 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2067 self.AssertSameImages(truth2, '/instances/%s/image-uint8' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2068 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2069 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
|
2070 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2071 self.AssertSameImages(truth2, '/instances/%s/preview' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2072 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2073 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2074 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
|
2075 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2076 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2077 def test_decode_color(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2078 imagej = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2079 color = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2080 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2081 for i in [ imagej, color ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2082 for j in [ 'image-uint8', 'image-uint16', 'image-int16' ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2083 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
|
2084 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2085 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
|
2086 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
|
2087 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2088 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
|
2089 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
|
2090 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2091 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2092 def test_decode_rf(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2093 rf = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2094 truth = Image.open(GetDatabasePath('Formats/KarstenHilbertRF.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2095 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2096 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2097 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2098 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2099 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2100 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2101 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
|
2102 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2103 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2104 def test_decode_multiframe(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2105 mf = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2106 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2107 # Test the first frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2108 truth = Image.open(GetDatabasePath('Formats/Multiframe0.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2109 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2110 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2111 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2112 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2113 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
|
2114 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2115 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
|
2116 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2117 # Test the last frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2118 truth = Image.open(GetDatabasePath('Formats/Multiframe75.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2119 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
|
2120 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2121 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2122 def test_decode_signed(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2123 signed = UploadInstance(_REMOTE, 'SignedCT.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2124 minValue = -2000 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2125 maxValue = 4042 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2126 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2127 truth = Image.open(GetDatabasePath('Formats/SignedCT.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2128 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2129 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2130 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
|
2131 self.AssertSameImages(truth2, '/instances/%s/image-uint16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2132 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2133 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
|
2134 self.AssertSameImages(truth3, '/instances/%s/image-uint8' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2135 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2136 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
|
2137 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
|
2138 self.AssertSameImages(tmp, '/instances/%s/preview' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2139 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2140 self.assertEqual('b57e6c872a3da50877c7da689b03a444', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % signed))) |
22 | 2141 |
2142 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
2143 def test_googlecode_issue_32(self): |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2144 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/default-encoding', 'nope')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2145 self.assertEqual('Windows1251', DoPut(_REMOTE, '/tools/default-encoding', 'Windows1251')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2146 self.assertEqual('Windows1251', DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2147 |
22 | 2148 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
2149 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) | |
2150 self.assertEqual(u'Рентгенография', tags['SeriesDescription']) | |
2151 self.assertEqual(u'Таз', tags['BodyPartExamined']) | |
2152 self.assertEqual(u'Прямая', tags['ViewPosition']) | |
2153 | |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2154 # Replay the same test using Latin1 as default encoding: This must fail |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2155 self.assertEqual('Latin1', DoPut(_REMOTE, '/tools/default-encoding', 'Latin1')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2156 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2157 DoDelete(_REMOTE, '/instances/%s' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2158 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2159 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2160 self.assertNotEqual(u'Рентгенография', tags['SeriesDescription']) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2161 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2162 |
22 | 2163 def test_encodings(self): |
23 | 2164 # Latin-1 (ISO_IR 100) |
22 | 2165 brainix = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2166 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % brainix) | |
2167 self.assertEqual(u'IRM cérébrale, neuro-crâne', tags['StudyDescription']) | |
23 | 2168 |
2169 # Latin-2 (ISO_IR 101) | |
2170 a = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] | |
2171 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % a) | |
2172 # dcm2xml MarekLatin2.dcm | iconv -f latin2 -t utf-8 | xmllint --format - | |
2173 self.assertEqual('Imię i Nazwisko osoby opisującej', | |
2174 i['ContentSequence'][4]['ConceptNameCodeSequence'][0]['CodeMeaning'].encode('utf-8')) | |
2175 | |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2176 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2177 def test_storescu_custom_aet(self): |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2178 # 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
|
2179 # 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
|
2180 # in the REST API)." |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2181 # 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
|
2182 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2183 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2184 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2185 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2186 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2187 c = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0003.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2188 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2189 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2190 'LocalAet' : 'YOP', |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2191 'Resources' : [ a['ID'], b['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2192 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2193 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2194 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2195 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
|
2196 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2197 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2198 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2199 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2200 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2201 'Resources' : [ c['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2202 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2203 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2204 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2205 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
|
2206 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2207 DropOrthanc(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2208 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2209 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2210 InstallLuaScript('Lua/AutoroutingChangeAet.lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2211 DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2212 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2213 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2214 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2215 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2216 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2217 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
|
2218 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2219 DoPost(_REMOTE, '/tools/execute-script', 'aet = nill', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2220 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2221 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2222 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2223 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
|
2224 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2225 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
|
2226 # 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
|
2227 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
|
2228 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
|
2229 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
|
2230 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
|
2231 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
|
2232 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2233 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
|
2234 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
|
2235 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
|
2236 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
|
2237 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2238 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
|
2239 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
|
2240 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2241 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
|
2242 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
|
2243 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
|
2244 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
|
2245 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
|
2246 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
|
2247 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
|
2248 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
|
2249 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
|
2250 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
|
2251 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
|
2252 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
|
2253 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
|
2254 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
|
2255 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
|
2256 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2257 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
|
2258 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
|
2259 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
|
2260 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
|
2261 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
|
2262 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
|
2263 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
|
2264 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2265 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
|
2266 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
|
2267 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
|
2268 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2269 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
|
2270 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
|
2271 self.assertTrue(instance in s) |
36 | 2272 |
2273 | |
2274 def test_create_pdf(self): | |
2275 # Upload 4 instances | |
2276 brainixInstance = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
2277 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2278 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2279 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2280 | |
2281 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
2282 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
2283 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
2284 | |
2285 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: | |
2286 pdf = f.read() | |
2287 | |
2288 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2289 json.dumps({ | |
2290 'Tags' : { | |
2291 'PatientName' : 'Jodogne', | |
2292 'Modality' : 'CT', | |
2293 }, | |
2294 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2295 })) | |
2296 | |
2297 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2298 self.assertEqual('OT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
2299 | |
2300 b = DoGet(_REMOTE, '/instances/%s/content/0042-0011' % i['ID']) | |
2301 self.assertEqual(len(b), len(pdf) + 1) | |
2302 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf + '\0')) | |
2303 | |
2304 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/tools/create-dicom', | |
2305 json.dumps({ | |
2306 'Parent' : brainixPatient, | |
2307 'Tags' : { | |
2308 'PatientName' : 'Jodogne', | |
2309 } | |
2310 }))) | |
2311 | |
2312 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2313 json.dumps({ | |
2314 'Parent' : brainixPatient, | |
2315 'Tags' : { 'StudyDescription' : 'PDF^Patient' }, | |
2316 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2317 })) | |
2318 | |
2319 self.assertEqual(brainixPatient, DoGet(_REMOTE, '/instances/%s/patient' % i['ID'])['ID']) | |
2320 | |
2321 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2322 json.dumps({ | |
2323 'Parent' : brainixStudy, | |
2324 'Tags' : { 'SeriesDescription' : 'PDF^Study' }, | |
2325 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2326 })) | |
2327 | |
2328 self.assertEqual(brainixStudy, DoGet(_REMOTE, '/instances/%s/study' % i['ID'])['ID']) | |
2329 | |
2330 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2331 json.dumps({ | |
2332 'Parent' : brainixEpi, | |
37 | 2333 'Tags' : { 'SpecificCharacterSet' : 'ISO_IR 13' }, |
36 | 2334 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
2335 })) | |
2336 | |
2337 self.assertEqual(brainixEpi, DoGet(_REMOTE, '/instances/%s/series' % i['ID'])['ID']) | |
2338 | |
2339 b = DoGet(_REMOTE, '/instances/%s/pdf' % i['ID']) | |
2340 self.assertEqual(len(b), len(pdf)) | |
2341 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf)) | |
2342 | |
2343 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/pdf' % brainixInstance)) | |
38 | 2344 |
2345 | |
2346 def test_create_series(self): | |
2347 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2348 json.dumps({ | |
2349 'Tags' : { | |
40 | 2350 'SpecificCharacterSet' : 'ISO_IR 100', |
2351 'PatientName' : 'Sébastien Jodogne', | |
38 | 2352 'Modality' : 'CT', |
2353 }, | |
2354 'Content' : [ | |
40 | 2355 { |
2356 'Content': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', # red dot in RGBA | |
2357 'Tags' : { 'ImageComments' : 'Tutu' } | |
2358 }, | |
38 | 2359 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAoUlEQVQ4jZ2SWw3EIBREjwUsYAELa2EtoAULFUCyXAtroRZqoRbox254BdLC/DZnZjoXWJFgCDg8egW2CBEhEnDzyRk+Ecxz2KP/0AL8S99T+jQccAVs22qKwAuPuq0uyNg9cPLh3am+pe/dkHLZtqJHj6vXJrZ7nvzvxxgemXgUwnGfXqpee09mUwp8m022OYP6bLF7mVuVe0y/umxinsAXRd9z0k1ubWsAAAAASUVORK5CYII=', |
2360 ] | |
2361 })) | |
2362 | |
2363 s = DoGet(_REMOTE, i['Path']) | |
2364 self.assertEqual('Series', s['Type']) | |
2365 self.assertEqual(s['ID'], i['ID']) | |
2366 self.assertEqual(2, len(s['Instances'])) | |
39 | 2367 self.assertEqual(2, s['ExpectedNumberOfInstances']) |
2368 self.assertEqual('Complete', s['Status']) | |
40 | 2369 |
2370 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][0]) | |
2371 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][1]) | |
2372 self.assertTrue('ImageComments' in a or 'ImageComments' in b) | |
2373 if 'ImageComments' in a: | |
2374 self.assertEqual('Tutu', a['ImageComments']) | |
2375 else: | |
2376 self.assertEqual('Tutu', b['ImageComments']) | |
2377 | |
2378 patient = DoGet(_REMOTE, '/instances/%s/patient' % s['Instances'][0]) | |
2379 self.assertEqual(patient['MainDicomTags']['PatientName'].encode('utf-8'), | |
2380 'Sébastien Jodogne') | |
47 | 2381 |
2382 | |
2383 def test_create_binary(self): | |
2384 binary = ''.join(map(chr, range(256))) | |
2385 encoded = 'data:application/octet-stream;base64,' + base64.b64encode(binary) | |
2386 tags = { | |
2387 'PatientName' : 'Jodogne', | |
2388 '8899-8899' : encoded | |
2389 } | |
2390 | |
2391 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2392 json.dumps({ | |
2393 'Tags' : tags | |
2394 })) | |
2395 | |
2396 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2397 self.assertEqual(binary, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID']).strip()) | |
2398 | |
2399 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2400 json.dumps({ | |
2401 'InterpretBinaryTags' : False, | |
2402 'Tags' : tags | |
2403 })) | |
2404 | |
2405 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2406 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
|
2407 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2408 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2409 def test_patient_ids_collision(self): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2410 # 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
|
2411 # same PatientID |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2412 for i in range(3): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2413 UploadInstance(_REMOTE, 'PatientIdsCollision/Image%d.dcm' % (i + 1)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2414 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2415 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2416 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2417 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2418 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
|
2419 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2420 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2421 'CaseSensitive' : True, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2422 'Query' : { 'PatientName' : 'FOO\\HELLO' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2423 self.assertEqual(2, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2424 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2425 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2426 'CaseSensitive' : False, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2427 'Query' : { 'PatientName' : 'Foo' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2428 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2429 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
|
2430 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
|
2431 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
|
2432 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2433 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2434 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2435 self.assertEqual(3, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2436 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
|
2437 self.assertTrue('FOO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2438 self.assertTrue('HELLO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2439 self.assertTrue('WORLD^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2440 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2441 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
|
2442 self.assertEqual(1, len(set(d))) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2443 self.assertEqual('COMMON', d[0]) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2444 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2445 for i in a: |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2446 d = DoGet(_REMOTE, '/studies/%s' % i) ['MainDicomTags']['StudyDescription'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2447 p = DoGet(_REMOTE, '/studies/%s' % i) ['PatientMainDicomTags']['PatientName'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2448 self.assertEqual('%s^SERIES' % p, d) |
49
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2449 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2450 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2451 def test_bitbucket_issue_4(self): |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2452 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2453 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2454 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2455 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2456 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2457 UploadInstance(_REMOTE, 'Formats/Rle.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2458 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2459 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2460 self.assertEqual(6, len(DoGet(_REMOTE, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2461 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2462 p = DoGet(_REMOTE, '/patients') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2463 self.assertEqual(2, len(p)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2464 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
|
2465 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
|
2466 self.assertEqual(3, len(i1)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2467 self.assertEqual(3, len(i2)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2468 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2469 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
|
2470 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2471 self.assertEqual(6, len(DoGet(_LOCAL, '/instances'))) |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2472 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2473 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2474 def test_create_sequence(self): |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2475 i = DoPost(_REMOTE, '/tools/create-dicom', |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2476 json.dumps({ |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2477 'Tags' : { |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2478 'SpecificCharacterSet': 'ISO_IR 100', # Encode using Latin1 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2479 'PatientName': 'Jodogne^', |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2480 'ReferencedStudySequence': GenerateTestSequence(), |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2481 } |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2482 }))['ID'] |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2483 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2484 self.assertEqual('Jodogne^', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2485 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
|
2486 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
|
2487 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
|
2488 self.assertEqual(u'Sébastien^'.encode('latin-1'), |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2489 DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/1/StudyDescription' % i)) |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2490 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2491 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2492 def test_modify_sequence(self): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2493 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2494 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
|
2495 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2496 j = DoPost(_REMOTE, '/instances/%s/modify' % i, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2497 json.dumps({ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2498 "Replace" : { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2499 "PatientName" : "hello", |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2500 'ReferencedStudySequence': GenerateTestSequence(), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2501 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2502 }), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2503 'application/json') |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2504 j = DoPost(_REMOTE, '/instances', j, 'application/dicom')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2505 DoDelete(_REMOTE, '/instances/%s' % i) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2506 |
52 | 2507 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % j))) |
2508 | |
2509 | |
2510 def test_compression(self): | |
2511 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
2512 | |
2513 data = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % i)[1] | |
2514 | |
2515 # "StorageCompression" is enabled in the Orthanc to be tested, | |
2516 # uncompress the data before running the test | |
2517 if DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i) != 0: | |
2518 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2519 | |
2520 cs = DoGet(_REMOTE, '/statistics')['TotalDiskSize'] | |
2521 us = DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'] | |
2522 size = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i) | |
2523 md5 = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i) | |
2524 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2525 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2526 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2527 | |
2528 ops = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % i) | |
2529 self.assertTrue('compress' in ops) | |
2530 self.assertTrue('uncompress' in ops) | |
2531 self.assertTrue('is-compressed' in ops) | |
2532 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2533 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2534 | |
2535 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/compress' % i) | |
2536 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2537 self.assertEqual(1, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2538 self.assertLess(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2539 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
2540 self.assertGreater(len(data), len(DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1])) | |
2541 self.assertGreater(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2542 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2543 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2544 self.assertNotEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2545 | |
2546 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2547 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2548 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2549 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2550 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2551 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2552 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2553 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2554 self.assertEqual(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2555 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
53 | 2556 |
2557 | |
2558 def test_ordered_slices(self): | |
2559 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
2560 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2561 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2562 self.assertEqual('Sequence', o['Type']) | |
2563 self.assertEqual(1, len(o['Dicom'])) | |
2564 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/file', o['Dicom'][0]) | |
2565 self.assertEqual(76, len(o['Slices'])) | |
2566 for j in range(76): | |
2567 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/frames/%d' % j, o['Slices'][j]) | |
2568 | |
68 | 2569 self.assertEqual(1, len(o['SlicesShort'])) |
2570 self.assertEqual('9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02', o['SlicesShort'][0][0]) | |
2571 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2572 self.assertEqual(76, o['SlicesShort'][0][2]) | |
2573 | |
53 | 2574 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2575 j = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm')['ID'] | |
2576 k = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm')['ID'] | |
2577 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2578 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2579 | |
2580 self.assertEqual('Volume', o['Type']) | |
2581 self.assertEqual(3, len(o['Dicom'])) | |
2582 self.assertEqual(3, len(o['Slices'])) | |
2583 self.assertEqual('/instances/%s/file' % i, o['Dicom'][2]) | |
2584 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2585 self.assertEqual('/instances/%s/file' % k, o['Dicom'][0]) | |
2586 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][2]) | |
2587 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
2588 self.assertEqual('/instances/%s/frames/0' % k, o['Slices'][0]) | |
2589 | |
68 | 2590 self.assertEqual(3, len(o['SlicesShort'])) |
2591 self.assertEqual(k, o['SlicesShort'][0][0]) | |
2592 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2593 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2594 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2595 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2596 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2597 self.assertEqual(i, o['SlicesShort'][2][0]) | |
2598 self.assertEqual(0, o['SlicesShort'][2][1]) | |
2599 self.assertEqual(1, o['SlicesShort'][2][2]) | |
2600 | |
53 | 2601 i = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] |
2602 j = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0002.dcm')['ID'] | |
2603 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2604 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2605 | |
2606 self.assertEqual('Sequence', o['Type']) | |
2607 self.assertEqual(2, len(o['Dicom'])) | |
2608 self.assertEqual(2, len(o['Slices'])) | |
2609 self.assertEqual('/instances/%s/file' % i, o['Dicom'][0]) | |
2610 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2611 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][0]) | |
2612 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
|
2613 |
68 | 2614 self.assertEqual(2, len(o['SlicesShort'])) |
2615 self.assertEqual(i, o['SlicesShort'][0][0]) | |
2616 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2617 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2618 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2619 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2620 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2621 | |
2622 | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2623 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2624 def test_incoming_movescu_accession(self): |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2625 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2626 |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2627 # No matching patient, so no job is created |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2628 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2629 CallMoveScu([ '--study', '-k', '0008,0052=STUDY', '-k', 'AccessionNumber=nope' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2630 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2631 CallMoveScu([ '--study', '-k', '0008,0052=PATIENT', '-k', 'AccessionNumber=A10003245599' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2632 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2633 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2634 # 1 Matching patient, track the job |
138 | 2635 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
2636 '--study', | |
2637 '-k', '0008,0052=STUDY', | |
2638 '-k', 'AccessionNumber=A10003245599' | |
2639 ]))) | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2640 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2641 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2642 |
55 | 2643 |
2644 def test_dicom_to_json(self): | |
2645 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
|
2646 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
|
2647 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2648 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
|
2649 with open(GetDatabasePath('PrivateMDNTagsSimplify.json'), 'r') as f: |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2650 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
123 | 2651 # Tags for compatibility with DCMTK 3.6.0 |
2652 'RETIRED_OtherPatientIDs', | |
2653 'OtherPatientIDs', | |
2654 'ACR_NEMA_2C_VariablePixelDataGroupLength', | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2655 ])) |
55 | 2656 |
2657 t = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
2658 with open(GetDatabasePath('PrivateMDNTagsFull.json'), 'r') as f: | |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
2659 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
2660 ])) |
55 | 2661 |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2662 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
|
2663 with open(GetDatabasePath('PrivateTagsSimplify.json'), 'r') as f: |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2664 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2665 ])) |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2666 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2667 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
|
2668 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
|
2669 a = json.loads(f.read()) |
65
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2670 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
|
2671 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
|
2672 self.assertEqual(aa, tt) |
57 | 2673 |
2674 | |
2675 def test_batch_archive(self): | |
2676 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2677 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') | |
2678 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2679 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0002.dcm') | |
2680 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2681 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') | |
2682 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
2683 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
2684 | |
2685 s = DoPost(_REMOTE, '/tools/create-archive', [ ]) | |
2686 z = zipfile.ZipFile(StringIO(s), "r") | |
2687 self.assertEqual(0, len(z.namelist())) | |
2688 | |
2689 # One patient | |
2690 s = DoPost(_REMOTE, '/tools/create-archive', [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ]) | |
2691 z = zipfile.ZipFile(StringIO(s), "r") | |
2692 self.assertEqual(4, len(z.namelist())) | |
2693 | |
2694 # One patient + twice its study + one series from other patient | |
2695 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2696 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2697 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918', | |
2698 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
2699 ]) | |
2700 z = zipfile.ZipFile(StringIO(s), "r") | |
2701 self.assertEqual(6, len(z.namelist())) | |
2702 | |
2703 # One patient + one series + one instance | |
2704 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2705 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2706 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0', | |
2707 '1d429ccb-bdcc78a1-7d129d6a-ba4966ed-fe4dbd87' | |
2708 ]) | |
2709 z = zipfile.ZipFile(StringIO(s), "r") | |
2710 self.assertEqual(7, len(z.namelist())) | |
59
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2711 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2712 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2713 def test_decode_brainix_as_jpeg(self): |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2714 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
|
2715 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2716 j = GetImage(_REMOTE, '/instances/%s/preview' % i) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2717 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2718 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2719 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2720 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2721 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
|
2722 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2723 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2724 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
|
2725 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2726 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2727 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
|
2728 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2729 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2730 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
|
2731 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2732 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2733 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2734 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2735 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
|
2736 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
|
2737 self.assertLess(a, b) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2738 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2739 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
|
2740 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2741 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2742 # 16bit encoding is not supported with JPEG |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2743 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
|
2744 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
|
2745 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2746 # No matching content type |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2747 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
|
2748 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2749 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2750 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2751 def test_media_encodings(self): |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2752 ascii = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2753 latin1 = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2754 latin2 = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2755 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2756 tmp = DoPost(_REMOTE, '/tools/create-media', [ascii,latin1,latin2]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2757 z = zipfile.ZipFile(StringIO(tmp), "r") |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2758 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2759 self.assertEqual(4, len(z.namelist())) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2760 self.assertTrue('IMAGES/IM0' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2761 self.assertTrue('IMAGES/IM1' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2762 self.assertTrue('IMAGES/IM2' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2763 self.assertTrue('DICOMDIR' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2764 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2765 try: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2766 os.remove('/tmp/DICOMDIR') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2767 except: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2768 # The file does not exist |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2769 pass |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2770 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2771 z.extract('DICOMDIR', '/tmp') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2772 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2773 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2774 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2775 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2776 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2777 self.assertEqual(1, len(a)) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2778 self.assertEqual('', a[0]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2779 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2780 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2781 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
|
2782 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
|
2783 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
|
2784 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2785 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
|
2786 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2787 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2788 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
|
2789 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
|
2790 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
|
2791 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
|
2792 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2793 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
|
2794 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
|
2795 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
|
2796 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
|
2797 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2798 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
|
2799 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
|
2800 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
|
2801 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
|
2802 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2803 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
|
2804 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
|
2805 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
|
2806 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
|
2807 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2808 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
|
2809 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
|
2810 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
|
2811 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
|
2812 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2813 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
|
2814 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
|
2815 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
|
2816 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
|
2817 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2818 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
|
2819 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
|
2820 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
|
2821 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
|
2822 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
|
2823 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2824 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
|
2825 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
|
2826 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
|
2827 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
|
2828 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
|
2829 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
|
2830 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2831 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
|
2832 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
|
2833 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
|
2834 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
|
2835 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
|
2836 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
|
2837 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2838 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2839 def test_decode_transfer_syntax(self): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2840 def Check(t, md5): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2841 i = UploadInstance(_REMOTE, 'TransferSyntaxes/%s.dcm' % t)['ID'] |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2842 |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
2843 if t != '1.2.840.10008.1.2': # This file has no meta header |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
2844 transferSyntax = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
2845 self.assertEqual(t, transferSyntax) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
2846 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2847 if md5 == None: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2848 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
|
2849 else: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2850 m = ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2851 self.assertEqual(m, md5) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2852 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2853 Check('1.2.840.10008.1.2.1', 'fae08d5415c4c0cd2cdbae4522408631') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2854 Check('1.2.840.10008.1.2.2', 'f3d9784768b8feb54d6a50b6d5c37682') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2855 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
|
2856 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
|
2857 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
|
2858 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
|
2859 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
|
2860 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
|
2861 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
|
2862 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2863 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
|
2864 Check('1.2.840.10008.1.2.4.91', None) # JPEG-2000 image, not supported |
79 | 2865 |
2866 | |
2867 def test_raw_frame(self): | |
2868 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
2869 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
2870 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
2871 self.assertEqual(512 * 512 * 2, len(a)) | |
2872 self.assertEqual(512 * 512 * 2, len(DoGet(_REMOTE, '/instances/%s/frames/23/raw' % s))) | |
2873 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/raw' % s)) | |
2874 self.assertEqual('1914287dc4d958eca21fdaacfb3482fa', ComputeMD5(a)) | |
2875 | |
2876 s = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
2877 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
2878 self.assertEqual(186274, len(DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s))) | |
2879 self.assertEqual(189424, len(DoGet(_REMOTE, '/instances/%s/frames/75/raw' % s))) | |
2880 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/raw' % s)) | |
2881 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
2882 self.assertEqual("L", im.mode) | |
2883 self.assertEqual(512, im.size[0]) | |
2884 self.assertEqual(512, im.size[1]) | |
2885 | |
2886 # Test an image with 2 JPEG frames spread over multiple fragments | |
2887 s = UploadInstance(_REMOTE, 'LenaTwiceWithFragments.dcm')['ID'] | |
2888 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
2889 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
2890 b = DoGet(_REMOTE, '/instances/%s/frames/1/raw' % s) | |
2891 self.assertEqual(69214, len(a)) | |
2892 self.assertEqual(ComputeMD5(a), ComputeMD5(b)) | |
2893 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/2/raw' % s)) | |
2894 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
2895 self.assertEqual("RGB", im.mode) | |
2896 self.assertEqual(512, im.size[0]) | |
2897 self.assertEqual(512, im.size[1]) | |
2898 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % s) | |
2899 self.assertEqual("RGB", im.mode) | |
2900 self.assertEqual(512, im.size[0]) | |
2901 self.assertEqual(512, im.size[1]) | |
81 | 2902 |
2903 | |
2904 | |
2905 def test_rest_movescu(self): | |
2906 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
2907 | |
2908 # Upload 4 instances | |
2909 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
2910 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
2911 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2912 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2913 | |
2914 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
2915 for p in DoGet(_REMOTE, '/patients'): | |
2916 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
2917 DoDelete(_REMOTE, '/patients/%s' % p) | |
2918 | |
2919 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
2920 | |
2921 # Upload instance Brainix/Flair/IM-0001-0001.dcm | |
2922 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Instance', | |
2923 'Resources' : [ | |
2924 { | |
2925 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
2926 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
2927 'SOPInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549', | |
2928 } | |
2929 ]}) | |
2930 | |
2931 # Upload series Brainix/Flair/* | |
2932 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
2933 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
2934 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
2935 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
2936 | |
2937 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
2938 'Resources' : [ | |
2939 { | |
2940 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
2941 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
2942 } | |
2943 ]}) | |
2944 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
2945 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
2946 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
2947 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
2948 | |
2949 # Upload series Brainix/Epi/* | |
2950 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
2951 'Resources' : [ | |
2952 { | |
2953 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
2954 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314125550', | |
2955 } | |
2956 ]}) | |
2957 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
2958 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
2959 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
2960 self.assertEqual(3, len(DoGet(_REMOTE, '/instances'))) | |
2961 | |
2962 # Upload study Knee/* | |
2963 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
2964 'Resources' : [ | |
2965 { | |
2966 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
2967 } | |
2968 ]}) | |
2969 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
2970 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
2971 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
2972 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
2973 | |
2974 # Reset | |
2975 for p in DoGet(_REMOTE, '/patients'): | |
2976 DoDelete(_REMOTE, '/patients/%s' % p) | |
2977 | |
2978 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
2979 | |
2980 | |
2981 # Upload all at once | |
2982 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
2983 'Resources' : [ | |
2984 { | |
2985 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
2986 }, | |
2987 { | |
2988 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
2989 } | |
2990 ]}) | |
2991 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
2992 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
2993 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
2994 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
2995 | |
86
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
2996 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
2997 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
2998 def test_reconstruct_json(self): |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
2999 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3000 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3001 instance = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3002 first = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3003 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3004 self.assertEqual('TWINOW', first['0008,1010']['Value']) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3005 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3006 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3007 # Cannot delete the "DICOM" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3008 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3009 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3010 # Can delete the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3011 r = DoDelete(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3012 self.assertTrue(type(r) is dict and len(r) == 0) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3013 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3014 # Only the "DICOM" attachment subsists |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3015 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3016 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3017 # Cannot manually reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3018 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/dicom-as-json' % patient, 'hello')) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3019 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3020 # Transparently reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3021 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3022 second = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3023 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3024 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3025 third = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3026 self.assertEqual(str(first), str(second)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3027 self.assertEqual(str(first), str(third)) |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3028 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3029 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3030 def test_reconstruct_json2(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3031 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3032 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3033 a = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3034 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3035 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3036 self.assertEqual('BRAINIX', DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3037 self.assertEqual('KNEE', DoGet(_REMOTE, '/instances/%s/tags?simplify' % b)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3038 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3039 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3040 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3041 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3042 DoPost(_REMOTE, '/tools/invalidate-tags', '', 'text/plain') |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3043 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3044 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3045 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3046 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3047 self.assertEqual('BRAINIX', DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3048 self.assertEqual('KNEE', DoGet(_REMOTE, '/instances/%s/tags?simplify' % b)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3049 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3050 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3051 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3052 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3053 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3054 def test_private_tags(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3055 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3056 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3057 self.assertEqual('1.2.840.113704.1.111.6320.1342451261.21', t['PET-CT Multi Modality Name']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3058 self.assertEqual('p37s0_na_ctac.img', t['Original Image Filename']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3059 |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3060 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3061 def test_findscu_encoding(self): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3062 # Check out ../Database/Encodings/Generate.sh |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3063 TEST = u'Test-éüäöòДΘĝדصķћ๛ネİ' |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3064 ENCODINGS = { |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3065 'Arabic' : [ 'ISO_IR 127' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3066 'Ascii' : [ 'ISO_IR 6' ], # More accurately, ISO 646 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3067 'Cyrillic' : [ 'ISO_IR 144' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3068 'Greek' : [ 'ISO_IR 126' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3069 'Hebrew' : [ 'ISO_IR 138' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3070 'Japanese' : [ 'ISO_IR 13', 'shift-jis' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3071 'Latin1' : [ 'ISO_IR 100' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3072 'Latin2' : [ 'ISO_IR 101' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3073 'Latin3' : [ 'ISO_IR 109' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3074 'Latin4' : [ 'ISO_IR 110' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3075 'Latin5' : [ 'ISO_IR 148' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3076 'Thai' : [ 'ISO_IR 166', 'tis-620' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3077 'Utf8' : [ 'ISO_IR 192' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3078 } |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3079 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3080 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3081 if len(ENCODINGS[name]) == 1: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3082 ENCODINGS[name].append(name.lower()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3083 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3084 UploadInstance(_REMOTE, 'Encodings/Lena-utf8.dcm') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3085 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3086 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3087 self.assertEqual(name, DoPut(_REMOTE, '/tools/default-encoding', name)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3088 self.assertEqual(name, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3089 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3090 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3091 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3092 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3093 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3094 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3095 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3096 self.assertEqual(ENCODINGS[name][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3097 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3098 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3099 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3100 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3101 expected = TEST.encode(ENCODINGS[name][1], 'ignore') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3102 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3103 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3104 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3105 #for master in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3106 for master in [ 'Latin1', 'Utf8', 'Cyrillic' ]: # Shortcut to speedup tests |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3107 self.assertEqual(master, DoPut(_REMOTE, '/tools/default-encoding', master)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3108 self.assertEqual(master, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3109 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3110 for name in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3111 DropOrthanc(_REMOTE) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3112 UploadInstance(_REMOTE, 'Encodings/Lena-%s.dcm' % ENCODINGS[name][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3113 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3114 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3115 '-k', 'PatientID', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3116 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3117 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3118 i = i.decode(ENCODINGS[master][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3119 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3120 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3121 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3122 self.assertEqual(ENCODINGS[master][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3123 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3124 patientId = re.findall('\(0010,0020\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3125 self.assertEqual(1, len(patientId)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3126 self.assertEqual(ENCODINGS[name][1], patientId[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3127 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3128 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3129 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3130 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3131 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3132 expected = TEST.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3133 tmp = ENCODINGS[master][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3134 expected = expected.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3135 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3136 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3137 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3138 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3139 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3140 'Level' : 'Study', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3141 'Query' : { }}) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3142 self.assertEqual(1, len(a)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3143 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3144 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3145 self.assertEqual(TEST.encode(tmp, 'ignore').decode(tmp), a[0]["PatientMainDicomTags"]["PatientName"]) |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3146 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3147 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3148 def test_reconstruct(self): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3149 def CompareMainDicomTag(expected, instance, level, tag): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3150 self.assertEqual(expected, DoGet(_REMOTE, '/instances/%s/%s' % (instance, level))['MainDicomTags'][tag].strip()) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3151 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3152 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3153 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3154 studies = DoGet(_REMOTE, '/studies/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3155 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3156 self.assertEqual(1, len(studies)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3157 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3158 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3159 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3160 modified = DoPost(_REMOTE, '/studies/%s/modify' % studies[0], { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3161 "Replace" : { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3162 "StudyDescription" : "hello", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3163 "SeriesDescription" : "world", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3164 "SOPClassUID" : "test", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3165 "SOPInstanceUID" : "myid", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3166 }, |
119 | 3167 "Keep" : [ "StudyInstanceUID", "SeriesInstanceUID" ], |
3168 "Force" : True | |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3169 }) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3170 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3171 instances = DoGet(_REMOTE, '/instances/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3172 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3173 self.assertEqual(1, len(DoGet(_REMOTE, '/studies/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3174 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3175 self.assertEqual(2, len(instances)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3176 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3177 b = instances[0] if instances[1] == a else instances[1] |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3178 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3179 CompareMainDicomTag('Knee (R)', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3180 CompareMainDicomTag('AX. FSE PD', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3181 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3182 CompareMainDicomTag('myid', b, '', 'SOPInstanceUID') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3183 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % a).strip()) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3184 self.assertEqual('test', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % b).strip()) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3185 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3186 DoPost(_REMOTE, '/instances/%s/reconstruct' % b, {}) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3187 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3188 CompareMainDicomTag('hello', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3189 CompareMainDicomTag('world', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3190 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') |
102 | 3191 |
104 | 3192 def test_httpClient_lua(self): |
3193 with open(GetDatabasePath('Lua/HttpClient.lua'), 'r') as f: | |
102 | 3194 result = DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua') |
3195 | |
3196 self.assertIn('OK', result) | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3197 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3198 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3199 def test_bitbucket_issue_44(self): |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3200 # https://bitbucket.org/sjodogne/orthanc/issues/44/bad-interpretation-of-photometric |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3201 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3202 UploadInstance(_REMOTE, 'Issue44/Monochrome2.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3203 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3204 # dcmcjpeg +ua +eb Monochrome1.dcm Monochrome1-Jpeg.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3205 UploadInstance(_REMOTE, 'Issue44/Monochrome1-Jpeg.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3206 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3207 # dcmcjpeg +ua Monochrome1.dcm Monochrome1-JpegLS.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3208 UploadInstance(_REMOTE, 'Issue44/Monochrome1-JpegLS.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3209 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3210 monochrome1 = 'bcdd600a-a6a9c522-5f0a6e84-8657c9f3-b76e59b7' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3211 monochrome1_jpeg = '9df82121-208a2da8-0038674a-3d7a773b-b7008cd2' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3212 monochrome1_jpegls = '0486d1a2-9165573f-b1976b20-e927b016-6b8d67ab' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3213 monochrome2 = 'f00947b7-f61f7164-c93414d1-c6fbda6a-9e92ed20' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3214 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3215 for i in [ monochrome1, monochrome1_jpeg, monochrome1_jpegls ]: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3216 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3217 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3218 self.assertEqual(2010, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3219 self.assertEqual(2446, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3220 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3221 # This is the chest image, with MONOCHROME1. Raw background is |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3222 # white (255), should be rendered as black (0) => invert |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3223 if i == monochrome1_jpeg: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3224 # Add some tolerance because of JPEG destructive compression |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3225 self.assertGreater(10, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3226 else: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3227 self.assertEqual(0, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3228 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3229 im = GetImage(_REMOTE, '/instances/%s/preview' % monochrome2) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3230 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3231 self.assertEqual(1572, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3232 self.assertEqual(2010, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3233 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3234 # This is the key image, with MONOCHROME2. Raw background is |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3235 # white (255), should be rendered as white (255) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3236 self.assertEqual(255, im.getpixel((0,0))) |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3237 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3238 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3239 def test_bitbucket_issue_42(self): |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3240 # https://bitbucket.org/sjodogne/orthanc/issues/42/fails-to-modify-a-dicom-video-file |
123 | 3241 # This test fails on DCMTK 3.6.0, but succeeds in DCMTK 3.6.1 snapshots and DCMTK 3.6.2 |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3242 UploadInstance(_REMOTE, 'Issue42.dcm')['ID'] |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3243 modified = DoPost(_REMOTE, |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3244 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify', |
119 | 3245 '{"Replace":{"PatientID":"Hello","PatientName":"Sample patient name"},"Force":true}', |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3246 'application/json') |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3247 self.assertTrue('PatientID' in modified) |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3248 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3249 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3250 def test_rest_find_limit(self): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3251 # Check the "Since" and "Limit" parameters in URI "/tools/find" |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3252 # Related to issue 53: https://bitbucket.org/sjodogne/orthanc/issues/53 |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3253 |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3254 # Upload 6 instances |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3255 brainix = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3256 knee = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3257 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3258 brainix.append(UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) ['ID']) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3259 brainix.append(UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) ['ID']) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3260 knee.append(UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) ['ID']) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3261 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3262 # Check using BRAINIX |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3263 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3264 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3265 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3266 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3267 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3268 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3269 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3270 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3271 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3272 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3273 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3274 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3275 'Since' : 2, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3276 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3277 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3278 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3279 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3280 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3281 'Limit' : 3 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3282 self.assertEqual(3, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3283 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3284 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3285 for i in range(4): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3286 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3287 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3288 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3289 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3290 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3291 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3292 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3293 # Check whether the two sets are equal through symmetric difference |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3294 self.assertEqual(0, len(set(b) ^ set(brainix))) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3295 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3296 # Check using KNEE |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3297 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3298 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3299 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3300 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3301 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3302 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3303 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3304 'Limit' : 2 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3305 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3306 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3307 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3308 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3309 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3310 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3311 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3312 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3313 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3314 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3315 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3316 self.assertEqual(0, len(set(b) ^ set(knee))) |
115
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3317 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3318 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3319 def test_bitbucket_issue_46(self): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3320 # "PHI remaining after anonymization" |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3321 # https://bitbucket.org/sjodogne/orthanc/issues/46 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3322 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3323 def GetAnonymizedTags(study, version): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3324 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3325 { 'DicomVersion' : version }, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3326 'application/json') ['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3327 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3328 self.assertEqual(1, len(a)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3329 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3330 instance = a[0]['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3331 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3332 return (instance, DoGet(_REMOTE, '/instances/%s/tags' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3333 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3334 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3335 origStudy = '6068a14b-d4df27af-9ec22145-538772d8-74f228ff' |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3336 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3337 # Add the 0032,1033 (Requesting Service) and the 0010,1060 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3338 # (Patient's Mother's Birth Name) tags |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3339 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3340 '{"Replace":{"0010,1060":"OSIMIS","0032,1033":"MOTHER"}}', |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3341 'application/json')['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3342 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3343 # Use Table E.1-1 from PS 3.15-2008 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3344 # https://raw.githubusercontent.com/jodogne/dicom-specification/master/2008/08_15pu.pdf |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3345 (instance, tags) = GetAnonymizedTags(newStudy, "2008") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3346 self.assertTrue('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3347 self.assertTrue('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3348 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3349 # Use Table E.1-1 from PS 3.15-2011 (only if Orthanc >= 1.2.1) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3350 # https://raw.githubusercontent.com/jodogne/dicom-specification/master/2008/08_15pu.pdf |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3351 (instance, tags) = GetAnonymizedTags(newStudy, "2017c") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3352 self.assertFalse('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3353 self.assertFalse('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3354 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3355 t = {} |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3356 for (key, value) in tags.iteritems(): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3357 t[value['Name']] = value['Value'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3358 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3359 self.assertEqual('', t['StudyDate']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3360 self.assertEqual('', t['StudyTime']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3361 self.assertEqual('', t['PatientSex']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3362 self.assertFalse('SeriesDate' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3363 self.assertFalse('SeriesTime' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3364 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3365 with tempfile.NamedTemporaryFile(delete = True) as f: |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3366 # Run "dciodvfy" on the anonymized file to be sure it is still valid |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3367 f.write(DoGet(_REMOTE, '/instances/%s/file' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3368 f.flush() |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3369 subprocess.check_output([ FindExecutable('dciodvfy'), f.name ], |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3370 stderr = subprocess.STDOUT).split('\n') |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3371 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3372 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3373 def test_bitbucket_issue_55(self): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3374 def Run(modify, query): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3375 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3376 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3377 operation = 'modify' if modify else 'anonymize' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3378 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3379 self.assertRaises(Exception, lambda: DoPost( |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3380 _REMOTE, '/studies/%s/%s' % (study, operation), query)) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3381 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3382 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3383 query["Force"] = True |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3384 a = DoPost(_REMOTE, '/studies/%s/%s' % (study, operation), query)['Path'] |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3385 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3386 DoDelete(_REMOTE, a) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3387 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3388 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3389 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3390 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3391 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3392 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3393 Run(True, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3394 Run(True, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3395 Run(True, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3396 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3397 Run(False, { "Keep" : [ "StudyInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3398 Run(False, { "Keep" : [ "SeriesInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3399 Run(False, { "Keep" : [ "SOPInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3400 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3401 Run(False, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3402 Run(False, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3403 Run(False, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3404 |
120
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3405 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3406 def test_bitbucket_issue_56(self): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3407 # Case-insensitive matching over accents. This test assumes |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3408 # that the "CaseSensitivePN" configuration option of Orthanc |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3409 # is set to "false" (default value). |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3410 # https://bitbucket.org/sjodogne/orthanc/issues/56 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3411 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3412 def Check(name, expected, expectedSensitive): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3413 a = CallFindScu([ '-k', '0008,0005=ISO_IR 192', # Use UTF-8 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3414 '-k', '0008,0052=PATIENT', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3415 '-k', 'PatientName=%s' % name ]) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3416 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', a) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3417 self.assertEqual(expected, len(patientNames)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3418 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3419 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3420 'CaseSensitive' : False, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3421 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3422 self.assertEqual(expected, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3423 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3424 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3425 'CaseSensitive' : True, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3426 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3427 self.assertEqual(expectedSensitive, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3428 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3429 UploadInstance(_REMOTE, 'Encodings/Lena-latin1.dcm') |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3430 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3431 # WildcardConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3432 Check('TeSt*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3433 Check('TeSt-a*', 0, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3434 Check('TeSt-É*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3435 Check('TeSt-é*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3436 Check('Test-é*', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3437 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3438 # ListConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3439 Check('Test-éüäöò\\nope', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3440 Check('Test-ÉÜÄÖÒ\\nope', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3441 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3442 # ValueConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3443 Check('Test-éüäöò', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3444 Check('Test-ÉÜÄÖÒ', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3445 |
125 | 3446 |
3447 def test_gbk_alias(self): | |
3448 # https://groups.google.com/d/msg/orthanc-users/WMM8LMbjpUc/02-1f_yFCgAJ | |
3449 # This test fails on Orthanc <= 1.3.0 | |
3450 i = UploadInstance(_REMOTE, '2017-09-19-GBK-Tumashu.dcm')['ID'] | |
3451 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3452 self.assertEqual(tags['PatientName'], u'徐浩凯') | |
3453 self.assertEqual(tags['InstitutionName'], u'灌云县疾病预防控制中心') | |
126 | 3454 |
3455 | |
3456 def test_long_tag(self): | |
3457 i = UploadInstance(_REMOTE, 'DummyCTWithLongTag.dcm')['ID'] | |
3458 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
3459 | |
3460 tags = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
3461 self.assertTrue('0018,1020' in tags) | |
3462 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3463 self.assertEqual('TooLong', tags['0018,1020']['Type']) | |
3464 self.assertEqual(None, tags['0018,1020']['Value']) | |
3465 | |
3466 tags = DoGet(_REMOTE, '/instances/%s/tags?ignore-length=0018-1020' % i) | |
3467 self.assertTrue('0018,1020' in tags) | |
3468 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3469 self.assertEqual('String', tags['0018,1020']['Type']) | |
3470 self.assertTrue(tags['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3471 | |
3472 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3473 self.assertTrue('SoftwareVersions' in tags) | |
3474 self.assertEqual(None, tags['SoftwareVersions']) | |
3475 self.assertTrue('HeartRate' in tags) | |
3476 self.assertEqual(474, int(tags['HeartRate'])) | |
3477 | |
3478 tags = DoGet(_REMOTE, '/instances/%s/simplified-tags' % i) | |
3479 self.assertTrue('SoftwareVersions' in tags) | |
3480 self.assertEqual(None, tags['SoftwareVersions']) | |
3481 | |
3482 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=0018-1020' % i) | |
3483 self.assertTrue('SoftwareVersions' in tags) | |
3484 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3485 | |
3486 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=SoftwareVersions' % i) | |
3487 self.assertTrue('SoftwareVersions' in tags) | |
3488 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3489 | |
3490 tags = DoGet(_REMOTE, '/series/%s/instances-tags' % series) | |
3491 self.assertEqual(1, len(tags)) | |
3492 self.assertTrue(i in tags.keys()) | |
3493 self.assertTrue('0018,1020' in tags[i]) | |
3494 self.assertEqual('TooLong', tags[i]['0018,1020']['Type']) | |
3495 | |
3496 tags = DoGet(_REMOTE, '/series/%s/instances-tags?ignore-length=SoftwareVersions' % series) | |
3497 self.assertEqual(1, len(tags)) | |
3498 self.assertTrue(i in tags.keys()) | |
3499 self.assertTrue('0018,1020' in tags[i]) | |
3500 self.assertEqual('String', tags[i]['0018,1020']['Type']) | |
3501 self.assertTrue(tags[i]['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3502 | |
127
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3503 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3504 def test_extended_media(self): |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3505 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3506 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3507 z = GetArchive(_REMOTE, '/patients/%s/media?extended' % DoGet(_REMOTE, '/patients')[0]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3508 self.assertEqual(2, len(z.namelist())) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3509 self.assertTrue('IMAGES/IM0' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3510 self.assertTrue('DICOMDIR' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3511 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3512 try: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3513 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3514 except: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3515 # The file does not exist |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3516 pass |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3517 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3518 z.extract('DICOMDIR', '/tmp') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3519 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3520 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3521 self.assertEqual(5, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3522 self.assertTrue(a[0].startswith('Warning')) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3523 self.assertEqual('BasicDirectory', a[1]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3524 self.assertTrue('not present in standard DICOM IOD' in a[2]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3525 self.assertTrue('not present in standard DICOM IOD' in a[3]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3526 self.assertEqual('', a[4]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3527 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3528 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3529 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3530 self.assertEqual(1, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3531 self.assertEqual('', a[0]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3532 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3533 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3534 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', a) != None) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3535 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3536 # Check the presence of the series description (extended tag) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3537 self.assertTrue(re.search('T1W_aTSE', a) != None) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3538 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3539 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3540 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3541 |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3542 def test_anonymize_relationships_1(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3543 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3544 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3545 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3546 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3547 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3548 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3549 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3550 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3551 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3552 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3553 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3554 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3555 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3556 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3557 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3558 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3559 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3560 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3561 SEQUENCE = '/instances/%s/content/ReferencedImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3562 SOP = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3563 CLASS = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3564 FRAME = '/instances/%s/content/FrameOfReferenceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3565 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3566 self.assertEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3567 DoGet(_REMOTE, FRAME % a2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3568 self.assertEqual(DoGet(_REMOTE, FRAME % b1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3569 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3570 self.assertNotEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3571 DoGet(_REMOTE, FRAME % b1)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3572 self.assertNotEqual(DoGet(_REMOTE, FRAME % a2), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3573 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3574 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3575 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % a1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3576 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % a2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3577 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % b1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3578 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % b2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3579 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3580 for i in range(3): |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3581 self.assertEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3582 DoGet(_REMOTE, SOP % (a2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3583 self.assertEqual(DoGet(_REMOTE, SOP % (b1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3584 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3585 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3586 DoGet(_REMOTE, SOP % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3587 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3588 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3589 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3590 DoGet(_REMOTE, CLASS % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3591 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3592 DoGet(_REMOTE, CLASS % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3593 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3594 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3595 def test_anonymize_relationships_2(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3596 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3597 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0002.dcm') |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3598 study = '6c65289b-db2fcb71-7eaf73f4-8e12470c-a4d6d7cf' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3599 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3600 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3601 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3602 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3603 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3604 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3605 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3606 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3607 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3608 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3609 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3610 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3611 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3612 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3613 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3614 SEQUENCE = '/instances/%s/content/SourceImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3615 SOP = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3616 CLASS = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3617 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3618 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % a1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3619 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % a2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3620 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % b1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3621 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % b2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3622 self.assertEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3623 DoGet(_REMOTE, SOP % (a2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3624 self.assertEqual(DoGet(_REMOTE, SOP % (b1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3625 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3626 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3627 DoGet(_REMOTE, SOP % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3628 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3629 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3630 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3631 DoGet(_REMOTE, CLASS % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3632 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3633 DoGet(_REMOTE, CLASS % (b2, 0))) |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3634 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3635 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3636 def test_anonymize_relationships_3(self): |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3637 sr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM0')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3638 mr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM631')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3639 study = 'ef351eb2-c1147229-062736b8-35a151e3-e32d526b' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3640 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3641 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3642 { "Keep" : [ "ContentSequence" ] }) ['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3643 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3644 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3645 self.assertEqual(2, len(a)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3646 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3647 if DoGet(_REMOTE, '/instances/%s/content/Modality' % a[0]['ID']) == 'SR': |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3648 sr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3649 mr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3650 else: |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3651 sr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3652 mr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3653 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3654 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % sr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3655 DoGet(_REMOTE, '/instances/%s/content/Modality' % sr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3656 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % mr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3657 DoGet(_REMOTE, '/instances/%s/content/Modality' % mr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3658 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3659 mrUid1 = DoGet(_REMOTE, '/instances/%s' % mr1)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3660 mrUid2 = DoGet(_REMOTE, '/instances/%s' % mr2)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3661 mrSeries1 = DoGet(_REMOTE, '/instances/%s/content/SeriesInstanceUID' % mr1).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3662 mrSeries2 = DoGet(_REMOTE, '/instances/%s/content/SeriesInstanceUID' % mr2).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3663 mrStudy1 = DoGet(_REMOTE, '/instances/%s/content/StudyInstanceUID' % mr1).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3664 mrStudy2 = DoGet(_REMOTE, '/instances/%s/content/StudyInstanceUID' % mr2).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3665 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3666 PATH1 = '/instances/%s/content/CurrentRequestedProcedureEvidenceSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3667 PATH2 = PATH1 + '/0/ReferencedSeriesSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3668 PATH3 = PATH2 + '/0/ReferencedSOPSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3669 PATH4 = PATH3 + '/0/ReferencedSOPInstanceUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3670 PATH5 = PATH3 + '/0/ReferencedSOPClassUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3671 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3672 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3673 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3674 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3675 self.assertEqual(DoGet(_REMOTE, PATH4 % sr1), mrUid1) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3676 self.assertEqual(mrSeries1, DoGet(_REMOTE, (PATH2 + '/0/SeriesInstanceUID') % sr1).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3677 self.assertEqual(mrStudy1, DoGet(_REMOTE, (PATH1 + '/0/StudyInstanceUID') % sr1).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3678 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3679 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3680 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3681 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3682 self.assertEqual(DoGet(_REMOTE, PATH5 % sr1), DoGet(_REMOTE, PATH5 % sr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3683 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3684 self.assertEqual(mrUid2, DoGet(_REMOTE, PATH4 % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3685 self.assertEqual(mrSeries2, DoGet(_REMOTE, (PATH2 + '/0/SeriesInstanceUID') % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3686 self.assertEqual(mrStudy2, DoGet(_REMOTE, (PATH1 + '/0/StudyInstanceUID') % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3687 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3688 content1 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr1) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3689 content2 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr2) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3690 self.assertEqual(str(content1), str(content2)) |