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