Mercurial > hg > orthanc-tests
annotate Tests/Tests.py @ 265:8d63d035b837
test_rendered
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 25 Feb 2020 13:57:59 +0100 |
parents | 445f498bc1d4 |
children | b105bb2233c6 |
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 |
260
943166deebcb
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
256
diff
changeset
|
8 # Copyright (C) 2017-2020 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 | |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
24 import base64 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
25 import copy |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
26 import pprint |
14 | 27 import tempfile |
3 | 28 import unittest |
29 | |
11 | 30 from PIL import ImageChops |
3 | 31 from Toolbox import * |
13 | 32 from xml.dom import minidom |
3 | 33 |
34 _LOCAL = None | |
35 _REMOTE = None | |
36 | |
37 | |
38 def SetOrthancParameters(local, remote): | |
39 global _LOCAL, _REMOTE | |
40 _LOCAL = local | |
41 _REMOTE = remote | |
42 | |
43 | |
14 | 44 def ExtractDicomTags(rawDicom, tags): |
45 with tempfile.NamedTemporaryFile(delete = True) as f: | |
46 f.write(rawDicom) | |
47 f.flush() | |
45 | 48 data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
14 | 49 |
50 result = [] | |
51 for tag in tags: | |
52 match = re.search('<element[^>]+name="%s">([^>]*)</element>' % tag, data) | |
53 if match == None: | |
54 result.append('') | |
55 else: | |
56 result.append(match.group(1)) | |
57 | |
58 return result | |
59 | |
60 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
61 def CompareLists(a, b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
62 if len(a) != len(b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
63 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
64 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
65 for i in range(len(a)): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
66 d = a[i] - b[i] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
67 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
|
68 return False |
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 return True |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
71 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
72 |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
73 def CompareTags(a, b, tagsToIgnore): |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
74 for i in tagsToIgnore: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
75 if i in a: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
76 del a[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
77 if i in b: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
78 del b[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
79 |
123 | 80 if a.keys() == b.keys(): |
81 return True | |
82 else: | |
83 print('Mismatch in tags: %s' % str(set(a.keys()) ^ set(b.keys()))) | |
84 return False | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
85 |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
86 |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
87 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
|
88 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
|
89 '-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
|
90 _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
|
91 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
|
92 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
|
93 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
94 |
142 | 95 def GetMoveScuCommand(): |
96 return [ | |
97 FindExecutable('movescu'), | |
98 '--move', _LOCAL['DicomAet'], # Target AET (i.e. storescp) | |
99 '--call', _REMOTE['DicomAet'], # Called AET (i.e. Orthanc) | |
100 '--aetitle', _LOCAL['DicomAet'], # Calling AET (i.e. storescp) | |
101 _REMOTE['Server'], | |
102 str(_REMOTE['DicomPort']) | |
103 ] | |
104 | |
231
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
105 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
106 def CallMoveScu(args): |
231
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
107 try: |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
108 subprocess.check_call(GetMoveScuCommand() + args, |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
109 stderr=subprocess.PIPE) |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
110 except subprocess.CalledProcessError as e: |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
111 # The error code "69" corresponds to "EXITCODE_CMOVE_ERROR", |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
112 # that has been introduced in DCMTK 3.6.2. This error code is |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
113 # expected by some tests that try and C-MOVE non-existing |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
114 # DICOM instances. |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
115 # https://groups.google.com/d/msg/orthanc-users/DCRc5NeSCbM/DG-pSWj-BwAJ |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
116 if e.returncode != 69: |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
117 raise e |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
118 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
119 |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
120 def GenerateTestSequence(): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
121 return [ |
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': 'Hello^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
124 'ReferencedStudySequence' : [ |
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 'StudyDescription': 'Toto', |
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 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
129 'StudyDescription': 'Tata', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
130 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
131 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
132 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
133 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
134 'StudyDescription': 'Sébastien^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
135 'StudyDate' : '19700202', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
136 } |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
137 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
138 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
139 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
140 |
15 | 141 |
3 | 142 class Orthanc(unittest.TestCase): |
143 def setUp(self): | |
83 | 144 if (sys.version_info >= (3, 0)): |
145 # Remove annoying warnings about unclosed socket in Python 3 | |
146 import warnings | |
147 warnings.simplefilter("ignore", ResourceWarning) | |
148 | |
3 | 149 DropOrthanc(_LOCAL) |
150 DropOrthanc(_REMOTE) | |
174 | 151 UninstallLuaCallbacks(_REMOTE) |
45 | 152 #print "In test", self._testMethodName |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
153 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
154 def AssertSameImages(self, truth, url): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
155 im = GetImage(_REMOTE, url) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
156 self.assertTrue(CompareLists(truth, im.getdata())) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
157 |
3 | 158 |
159 def test_system(self): | |
177 | 160 self.assertTrue('Version' in DoGet(_REMOTE, '/system')) |
161 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
162 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
163 | |
164 systemInfo = DoGet(_REMOTE, '/system') | |
165 if systemInfo["Version"] == "mainline": | |
166 print "Skipping version checks since you're currently in mainline" | |
167 return | |
168 | |
173 | 169 self.assertTrue(IsOrthancVersionAbove(_LOCAL, 0, 8, 6)) |
170 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 0, 8, 7)) | |
171 self.assertTrue(IsOrthancVersionAbove(_LOCAL, 0, 7, 6)) | |
172 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 0, 9, 6)) | |
173 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 1, 8, 6)) | |
3 | 174 |
175 def test_upload(self): | |
173 | 176 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) |
177 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
178 | |
179 sizeDummyCT = 2472 | |
180 sizeOverwrite = 2476 | |
181 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
182 | |
3 | 183 u = UploadInstance(_REMOTE, 'DummyCT.dcm') |
183 | 184 self.assertEqual(instance, u['ID']) |
3 | 185 self.assertEqual('Success', u['Status']) |
173 | 186 |
183 | 187 if True: |
188 # New test for Orthanc 1.4.3 | |
189 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', u['ParentSeries']) | |
190 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', u['ParentStudy']) | |
191 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', u['ParentPatient']) | |
192 | |
173 | 193 j = int(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % instance)) |
194 s = sizeDummyCT + j | |
195 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
196 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
197 | |
3 | 198 u = UploadInstance(_REMOTE, 'DummyCT.dcm') |
199 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
200 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
201 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
202 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
173 | 203 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) |
204 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
205 | |
206 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % instance) | |
3 | 207 self.assertEqual('20070101', i['StudyDate']) |
173 | 208 self.assertEqual('KNIX', i['PatientName']) |
209 | |
210 if IsOrthancVersionAbove(_REMOTE, 1, 4, 2): | |
211 # Overwriting | |
212 self.assertEqual('Success', u['Status']) | |
213 else: | |
214 self.assertEqual('AlreadyStored', u['Status']) | |
215 | |
216 u = UploadInstance(_REMOTE, 'DummyCT-overwrite.dcm') | |
217 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
218 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
219 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
220 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
221 | |
222 if IsOrthancVersionAbove(_REMOTE, 1, 4, 2): | |
223 # Overwriting | |
224 self.assertEqual('Success', u['Status']) | |
225 j2 = int(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % instance)) | |
226 s2 = sizeOverwrite + j2 | |
227 self.assertNotEqual(s, s2) | |
228 self.assertNotEqual(j, j2) | |
229 self.assertEqual('%d' % s2, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
230 self.assertEqual('%d' % s2, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
231 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % instance) | |
232 self.assertEqual('ANOTHER', i['PatientName']) | |
233 else: | |
234 self.assertEqual('AlreadyStored', u['Status']) | |
235 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
236 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
3 | 237 |
5 | 238 def test_upload_2(self): |
3 | 239 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
240 instance = DoGet(_REMOTE, '/instances/%s' % i) | |
241 self.assertEqual(i, instance['ID']) | |
242 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', | |
243 instance['MainDicomTags']['SOPInstanceUID']) | |
244 | |
245 series = DoGet(_REMOTE, '/series/%s' % instance['ParentSeries']) | |
246 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
247 series['MainDicomTags']['SeriesInstanceUID']) | |
248 | |
249 study = DoGet(_REMOTE, '/studies/%s' % series['ParentStudy']) | |
250 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
251 study['MainDicomTags']['StudyInstanceUID']) | |
252 | |
253 patient = DoGet(_REMOTE, '/patients/%s' % study['ParentPatient']) | |
254 self.assertEqual('ozp00SjY2xG', | |
255 patient['MainDicomTags']['PatientID']) | |
256 | |
257 dicom = DoGet(_REMOTE, '/instances/%s/file' % instance['ID']) | |
258 self.assertEqual(2472, len(dicom)) | |
259 self.assertEqual('3e29b869978b6db4886355a2b1132124', ComputeMD5(dicom)) | |
260 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
261 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/simplified-tags' % i)['StationName']) | |
262 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
|
263 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
|
264 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags?short' % i)['0008,1010']) |
3 | 265 |
266 | |
5 | 267 def test_images(self): |
268 i = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] | |
269 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
3 | 270 |
5 | 271 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
272 self.assertEqual("L", im.mode) | |
273 self.assertEqual(512, im.size[0]) | |
274 self.assertEqual(358, im.size[1]) | |
275 | |
276 im = GetImage(_REMOTE, '/instances/%s/image-uint8' % i) | |
277 self.assertEqual("L", im.mode) | |
278 self.assertEqual(512, im.size[0]) | |
279 self.assertEqual(358, im.size[1]) | |
280 | |
281 im = GetImage(_REMOTE, '/instances/%s/image-uint16' % i) | |
282 self.assertEqual(512, im.size[0]) | |
283 self.assertEqual(358, im.size[1]) | |
284 | |
285 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
286 self.assertEqual("L", im.mode) | |
287 self.assertEqual(512, im.size[0]) | |
288 self.assertEqual(358, im.size[1]) | |
289 | |
290 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
291 self.assertEqual("L", im.mode) | |
292 self.assertEqual(512, im.size[0]) | |
293 self.assertEqual(358, im.size[1]) | |
294 | |
295 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
296 self.assertEqual(512, im.size[0]) | |
297 self.assertEqual(358, im.size[1]) | |
64 | 298 |
299 # This is Little Endian Explicit | |
300 self.assertEqual('1.2.840.10008.1.2.1', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) | |
301 | |
6 | 302 |
303 def test_hierarchy(self): | |
304 UploadFolder(_REMOTE, 'Brainix/Epi') | |
305 UploadFolder(_REMOTE, 'Brainix/Flair') | |
306 UploadFolder(_REMOTE, 'Knee/T1') | |
307 UploadFolder(_REMOTE, 'Knee/T2') | |
308 | |
309 p = DoGet(_REMOTE, '/patients') | |
310 s = DoGet(_REMOTE, '/studies') | |
311 t = DoGet(_REMOTE, '/series') | |
312 self.assertEqual(2, len(p)) | |
313 self.assertEqual(2, len(s)) | |
314 self.assertEqual(4, len(t)) | |
315 self.assertEqual(94, len(DoGet(_REMOTE, '/instances'))) | |
316 | |
317 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
318 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
319 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
320 brainixFlair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
321 | |
322 kneePatient = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
323 kneeStudy = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
324 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
325 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
326 | |
327 self.assertTrue(brainixPatient in p) | |
328 self.assertTrue(kneePatient in p) | |
329 self.assertTrue(brainixStudy in s) | |
330 self.assertTrue(kneeStudy in s) | |
331 self.assertTrue(brainixEpi in t) | |
332 self.assertTrue(brainixFlair in t) | |
333 self.assertTrue(kneeT1 in t) | |
334 self.assertTrue(kneeT2 in t) | |
335 | |
336 self.assertEqual(44, len(DoGet(_REMOTE, '/patients/%s/instances' % brainixPatient))) | |
337 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % brainixPatient))) | |
338 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % brainixPatient))) | |
339 | |
340 self.assertEqual(50, len(DoGet(_REMOTE, '/patients/%s/instances' % kneePatient))) | |
341 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % kneePatient))) | |
342 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % kneePatient))) | |
343 | |
344 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % brainixStudy))) | |
345 self.assertEqual(44, len(DoGet(_REMOTE, '/studies/%s/instances' % brainixStudy))) | |
346 | |
347 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % kneeStudy))) | |
348 self.assertEqual(50, len(DoGet(_REMOTE, '/studies/%s/instances' % kneeStudy))) | |
349 | |
350 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixEpi))) | |
351 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixFlair))) | |
352 self.assertEqual(24, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT1))) | |
353 self.assertEqual(26, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT2))) | |
354 | |
355 for patient in p: | |
356 for study in DoGet(_REMOTE, '/patients/%s/studies' % patient): | |
357 self.assertEqual(patient, study['ParentPatient']) | |
358 for series in DoGet(_REMOTE, '/studies/%s/series' % study['ID']): | |
359 self.assertEqual(study['ID'], series['ParentStudy']) | |
211 | 360 self.assertEqual('Unknown', series['Status']) |
6 | 361 for instance in DoGet(_REMOTE, '/series/%s/instances' % series['ID']): |
362 self.assertEqual(series['ID'], instance['ParentSeries']) | |
363 | |
364 self.assertEqual(json.dumps(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance['ID'])), | |
365 json.dumps(DoGet(_REMOTE, '/instances/%s/tags' % instance['ID']))) | |
366 | |
367 | |
368 r = DoDelete(_REMOTE, "/studies/%s" % brainixStudy)['RemainingAncestor'] | |
369 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
370 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
371 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
372 self.assertEqual(50, len(DoGet(_REMOTE, '/instances'))) | |
373 self.assertEqual(None, r) | |
374 | |
375 r = DoDelete(_REMOTE, "/series/%s" % kneeT2)['RemainingAncestor'] | |
376 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
377 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
378 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
379 self.assertEqual(24, len(DoGet(_REMOTE, '/instances'))) | |
380 self.assertEqual('Study', r['Type']) | |
381 self.assertEqual(kneeStudy, r['ID']) | |
382 | |
383 r = DoDelete(_REMOTE, "/instances/%s" % DoGet(_REMOTE, '/instances')[0])['RemainingAncestor'] | |
384 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
385 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
386 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
387 self.assertEqual(23, len(DoGet(_REMOTE, '/instances'))) | |
388 self.assertEqual('Series', r['Type']) | |
389 self.assertEqual(kneeT1, r['ID']) | |
390 | |
391 r = DoDelete(_REMOTE, "/patients/%s" % kneePatient)['RemainingAncestor'] | |
392 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
393 self.assertEqual(0, len(DoGet(_REMOTE, '/studies'))) | |
394 self.assertEqual(0, len(DoGet(_REMOTE, '/series'))) | |
395 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
396 self.assertEqual(None, r) | |
397 | |
398 DropOrthanc(_REMOTE) | |
399 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
400 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
7 | 401 |
213
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
402 def test_delete_cascade(self): |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
403 # make sure deleting the last instance of a study deletes the series, study and patient |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
404 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
405 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) # make sure orthanc is empty when starting the test |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
406 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
407 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
408 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
409 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
410 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
411 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
412 DoDelete(_REMOTE, '/instances/%s' % a) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
413 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
414 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
415 self.assertEqual(0, len(DoGet(_REMOTE, '/series'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
416 self.assertEqual(0, len(DoGet(_REMOTE, '/studies'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
417 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
418 |
7 | 419 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
420 def test_multiframe(self): |
7 | 421 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
422 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
423 | |
424 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
425 self.assertEqual("L", im.mode) | |
426 self.assertEqual(512, im.size[0]) | |
427 self.assertEqual(512, im.size[1]) | |
428 | |
429 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
430 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
431 DoGet(_REMOTE, '/instances/%s/frames/75/preview' % i) | |
432 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/aaa/preview' % i)) | |
433 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/preview' % i)) | |
434 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
435 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
436 def test_changes(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
437 # Check emptiness |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
438 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
439 self.assertEqual(0, len(c['Changes'])) |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
440 #self.assertEqual(0, c['Last']) # Not true anymore for Orthanc >= 1.5.2 |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
441 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
442 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
443 self.assertEqual(0, len(c['Changes'])) |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
444 #self.assertEqual(0, c['Last']) # Not true anymore for Orthanc >= 1.5.2 |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
445 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
446 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
447 # Add 1 instance |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
448 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
|
449 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
450 begin = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
451 self.assertEqual(4, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
452 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
453 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
|
454 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
455 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
456 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
457 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
458 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
459 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
|
460 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
461 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
462 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
463 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
|
464 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
465 self.assertEqual(begin - 1, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
466 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
467 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
|
468 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
469 self.assertEqual(begin - 2, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
470 self.assertFalse(c['Done']) |
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 UploadFolder(_REMOTE, 'Knee/T1') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
473 UploadFolder(_REMOTE, 'Knee/T2') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
474 since = begin |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
475 countPatients = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
476 countStudies = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
477 countSeries = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
478 countInstances = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
479 completed = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
480 while True: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
481 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
|
482 since = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
483 for i in c['Changes']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
484 if i['ResourceType'] == 'Instance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
485 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
486 if i['ResourceType'] == 'Patient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
487 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
488 if i['ResourceType'] == 'Study': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
489 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
490 if i['ResourceType'] == 'Series': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
491 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
492 if i['ChangeType'] == 'NewInstance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
493 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
494 if i['ChangeType'] == 'NewPatient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
495 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
496 if i['ChangeType'] == 'NewStudy': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
497 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
498 if i['ChangeType'] == 'NewSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
499 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
500 if i['ChangeType'] == 'CompletedSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
501 completed += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
502 self.assertTrue('ID' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
503 self.assertTrue('Path' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
504 self.assertTrue('Seq' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
505 if c['Done']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
506 break |
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 self.assertEqual(2 * 50, countInstances) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
509 self.assertEqual(2 * 1, countPatients) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
510 self.assertEqual(2 * 1, countStudies) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
511 self.assertEqual(2 * 2, countSeries) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
512 self.assertEqual(0, completed) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
513 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
514 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
515 def test_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
516 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
|
517 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
192 | 518 knee = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' |
519 | |
520 z = GetArchive(_REMOTE, '/patients/%s/archive' % knee) | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
521 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
522 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
523 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
|
524 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
525 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
526 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
|
527 self.assertEqual(1, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
528 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
529 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
192 | 530 brainix = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' |
531 | |
532 z = GetArchive(_REMOTE, '/patients/%s/archive' % knee) | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
533 self.assertEqual(2, len(z.namelist())) |
192 | 534 |
535 z = PostArchive(_REMOTE, '/tools/create-archive', { | |
536 'Resources' : [ brainix, knee ] | |
537 }) | |
538 self.assertEqual(3, len(z.namelist())) | |
539 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
540 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
541 def test_media_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
542 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
|
543 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
|
544 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
545 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
|
546 self.assertEqual(3, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
547 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
|
548 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
|
549 self.assertTrue('DICOMDIR' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
550 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
551 try: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
552 os.remove('/tmp/DICOMDIR') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
553 except: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
554 # The file does not exist |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
555 pass |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
556 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
557 z.extract('DICOMDIR', '/tmp') |
45 | 558 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
|
559 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
560 self.assertEqual(3, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
561 self.assertTrue(a[0].startswith('Warning')) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
562 self.assertEqual('BasicDirectory', a[1]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
563 self.assertEqual('', a[2]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
564 |
45 | 565 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
|
566 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
567 self.assertEqual(1, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
568 self.assertEqual('', a[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
569 |
45 | 570 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
|
571 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
|
572 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
|
573 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
574 os.remove('/tmp/DICOMDIR') |
10 | 575 |
576 | |
577 def test_protection(self): | |
578 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
579 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
580 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
581 a = DoGet(_REMOTE, '/patients')[0] | |
582 b = DoGet(_REMOTE, '/patients')[1] | |
583 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
584 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
585 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
586 DoPut(_REMOTE, '/patients/%s/protected' % a, '1', 'text/plain') | |
587 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
588 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
589 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
590 | |
591 | |
12 | 592 def test_raw_tags(self): |
10 | 593 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
594 | |
595 dicom = DoGet(_REMOTE, '/instances/%s/file' % i) | |
596 self.assertEqual('1a7c56cb02d6e742cc9c856a8ac182e3', ComputeMD5(dicom)) | |
597 | |
598 s = '/instances/%s/content/' % i | |
599 | |
600 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, s + '0008-1010').strip()) | |
601 self.assertRaises(Exception, lambda: DoGet(_REMOTE, s + '0008-1011')) | |
602 | |
603 self.assertEqual('Abdomen', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/0/7fe1-1057').strip()) | |
604 self.assertEqual('cla_3c', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/8/7fe1-1057').strip()) | |
605 | |
606 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
607 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
608 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
609 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
610 | |
611 for i in DoGet(_REMOTE, '/instances'): | |
612 aid = DoGet(_REMOTE, '/instances/%s' % i)['MainDicomTags']['SOPInstanceUID'] | |
613 self.assertEqual(aid, DoGet(_REMOTE, '/instances/%s/content/0008-0018' % i).replace(chr(0), '')) | |
614 | |
615 | |
616 def test_raw_tags_mdn(self): | |
617 # Bug reported by Cyril Paulus | |
618 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
619 self.assertAlmostEqual(0.000027, DoGet(_REMOTE, '/instances/%s/content/7053-1000' % i)) | |
620 | |
621 | |
622 def test_modify_instance(self): | |
623 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] | |
624 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, | |
625 json.dumps({ | |
626 "Replace" : { | |
627 "PatientName" : "hello", | |
628 #"PatientID" : "world" | |
629 }, | |
630 "Remove" : [ "StationName" ], | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
631 "RemovePrivateTags" : True |
10 | 632 }), |
633 'application/json') | |
634 j = DoPost(_REMOTE, '/instances', modified, 'application/dicom')['ID'] | |
635 | |
636 self.assertNotEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
637 #self.assertNotEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % i).strip()) | |
83 | 638 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i).strip()) |
10 | 639 DoGet(_REMOTE, '/instances/%s/content/6003-1010' % i) # Some private tag |
640 | |
641 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
642 #self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % j).strip()) | |
643 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j)) | |
644 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/6003-1010' % j)) | |
645 | |
646 | |
647 def test_modify_series(self): | |
648 # Upload 4 images from the same series | |
649 for i in range(4): | |
650 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
651 | |
652 origSeries = DoGet(_REMOTE, '/series')[0] | |
653 newSeries = DoPost(_REMOTE, '/series/%s/modify' % origSeries, | |
654 '{"Replace":{"PatientName":"Jodogne"}}', | |
655 'application/json')['ID'] | |
656 | |
657 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['ModifiedFrom']) | |
658 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
659 self.assertEqual(4, len(instances)) | |
660 for i in instances: | |
661 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
662 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
663 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
664 | |
665 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
666 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
667 | |
668 | |
669 def test_modify_study(self): | |
670 # Upload 4 images from the 2 series of the same study | |
671 for i in range(4): | |
672 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
673 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
674 | |
675 origStudy = DoGet(_REMOTE, '/studies')[0] | |
676 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, | |
677 '{"Replace":{"PatientName":"Jodogne"}}', | |
678 'application/json')['ID'] | |
679 | |
680 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['ModifiedFrom']) | |
681 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
682 self.assertEqual(2, len(series)) | |
683 for s in series: | |
684 ss = DoGet(_REMOTE, '/series/%s' % s)['ModifiedFrom'] | |
685 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
686 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
687 | |
688 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
689 for i in instances: | |
690 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
691 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
692 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
693 | |
694 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
695 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
696 | |
697 | |
698 def test_anonymize_series(self): | |
699 # Upload 4 images from the same series | |
700 for i in range(4): | |
701 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
702 | |
703 origSeries = DoGet(_REMOTE, '/series')[0] | |
704 newSeries = DoPost(_REMOTE, '/series/%s/anonymize' % origSeries, | |
705 '{}', | |
706 'application/json')['ID'] | |
707 | |
708 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['AnonymizedFrom']) | |
709 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
710 self.assertEqual(4, len(instances)) | |
711 for i in instances: | |
712 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
713 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
714 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
715 | |
716 DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j) | |
717 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i)) | |
718 | |
719 | |
720 def test_anonymize_study(self): | |
721 # Upload 4 images from the 2 series of the same study | |
722 for i in range(4): | |
723 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
724 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
725 | |
726 origStudy = DoGet(_REMOTE, '/studies')[0] | |
727 newStudy = DoPost(_REMOTE,'/studies/%s/anonymize' % origStudy, | |
728 '{"Replace":{"PatientName":"Jodogne"}}', | |
729 'application/json')['ID'] | |
730 | |
731 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['AnonymizedFrom']) | |
732 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
733 self.assertEqual(2, len(series)) | |
734 for s in series: | |
735 ss = DoGet(_REMOTE, '/series/%s' % s)['AnonymizedFrom'] | |
736 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
737 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
738 | |
739 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
740 for i in instances: | |
741 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
742 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
743 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
744 | |
745 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
746 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
11 | 747 |
748 | |
749 | |
750 def test_storescu(self): | |
751 # Check emptiness | |
752 e = DoGet(_REMOTE, '/exports') | |
753 self.assertEqual(0, len(e['Exports'])) | |
754 self.assertEqual(0, e['Last']) | |
755 self.assertTrue(e['Done']) | |
756 e = DoGet(_REMOTE, '/exports?last') | |
757 self.assertEqual(0, len(e['Exports'])) | |
758 self.assertEqual(0, e['Last']) | |
759 self.assertTrue(e['Done']) | |
760 | |
761 # Add 1 instance | |
762 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
763 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
764 | |
765 # Export the instance | |
766 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') # instance | |
767 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
768 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
769 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
770 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
771 | |
772 e = DoGet(_REMOTE, '/exports') | |
773 self.assertEqual(1, len(e['Exports'])) | |
774 self.assertTrue(e['Done']) | |
775 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
776 e = DoGet(_REMOTE, '/exports?limit=1') | |
777 self.assertEqual(1, len(e['Exports'])) | |
778 self.assertTrue(e['Done']) | |
779 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
780 e = DoGet(_REMOTE, '/exports?last') | |
781 self.assertEqual(1, len(e['Exports'])) | |
782 self.assertTrue(e['Done']) | |
783 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
784 seqInstance = e['Last'] | |
785 | |
786 # Export the series | |
787 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', 'text/plain') | |
788 | |
789 e = DoGet(_REMOTE, '/exports') | |
790 self.assertEqual(2, len(e['Exports'])) | |
791 self.assertTrue(e['Done']) | |
792 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
793 seqSeries = e['Last'] | |
794 self.assertNotEqual(seqInstance, seqSeries) | |
795 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
796 self.assertEqual(1, len(e['Exports'])) | |
797 self.assertFalse(e['Done']) | |
798 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
799 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
800 self.assertEqual(1, len(e['Exports'])) | |
801 self.assertTrue(e['Done']) | |
802 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
803 e = DoGet(_REMOTE, '/exports?last') | |
804 self.assertEqual(1, len(e['Exports'])) | |
805 self.assertTrue(e['Done']) | |
806 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
807 | |
808 # Export the study | |
809 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', 'text/plain') | |
810 seqStudy = DoGet(_REMOTE, '/exports')['Last'] | |
811 | |
812 # Export the patient | |
813 j = DoPost(_REMOTE, '/modalities/orthanctest/store', '6816cb19-844d5aee-85245eba-28e841e6-2414fae2', 'text/plain') | |
814 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
815 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
816 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
817 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
818 | |
819 e = DoGet(_REMOTE, '/exports') | |
820 self.assertEqual(4, len(e['Exports'])) | |
821 self.assertTrue(e['Done']) | |
822 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
823 seqPatient = e['Last'] | |
824 self.assertNotEqual(seqInstance, seqSeries) | |
825 self.assertNotEqual(seqSeries, seqStudy) | |
826 self.assertNotEqual(seqStudy, seqPatient) | |
827 self.assertTrue(seqInstance < seqSeries) | |
828 self.assertTrue(seqSeries < seqStudy) | |
829 self.assertTrue(seqStudy < seqPatient) | |
830 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
831 self.assertEqual(1, len(e['Exports'])) | |
832 self.assertFalse(e['Done']) | |
833 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
834 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
835 self.assertEqual(1, len(e['Exports'])) | |
836 self.assertFalse(e['Done']) | |
837 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
838 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqSeries)) | |
839 self.assertEqual(1, len(e['Exports'])) | |
840 self.assertFalse(e['Done']) | |
841 self.assertEqual(e['Exports'][-1]['Seq'], seqStudy) | |
842 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqStudy)) | |
843 self.assertEqual(1, len(e['Exports'])) | |
844 self.assertTrue(e['Done']) | |
845 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
846 e = DoGet(_REMOTE, '/exports?last') | |
847 self.assertEqual(1, len(e['Exports'])) | |
848 self.assertTrue(e['Done']) | |
849 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
850 | |
851 | |
852 # Check the content of the logged information | |
853 e = DoGet(_REMOTE, '/exports')['Exports'] | |
854 | |
855 if 'PatientID' in e[0]: | |
856 # Since Orthanc 0.8.6 | |
857 patient = 'PatientID' | |
858 study = 'StudyInstanceUID' | |
859 series = 'SeriesInstanceUID' | |
860 instance = 'SOPInstanceUID' | |
861 else: | |
862 # Up to Orthanc 0.8.5 | |
863 patient = 'PatientId' | |
864 study = 'StudyInstanceUid' | |
865 series = 'SeriesInstanceUid' | |
866 instance = 'SopInstanceUid' | |
867 | |
868 for k in range(4): | |
869 self.assertTrue('Date' in e[k]) | |
870 self.assertTrue('Seq' in e[k]) | |
871 self.assertEqual('orthanctest', e[k]['RemoteModality']) | |
872 | |
873 self.assertEqual(10, len(e[0])) | |
874 self.assertEqual('Instance', e[0]['ResourceType']) | |
875 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['ID']) | |
876 self.assertEqual('/instances/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['Path']) | |
877 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', e[0][instance]) | |
878 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[0][series]) | |
879 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[0][study]) | |
880 self.assertEqual('ozp00SjY2xG', e[0][patient]) | |
881 | |
882 self.assertEqual(9, len(e[1])) | |
883 self.assertEqual('Series', e[1]['ResourceType']) | |
884 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['ID']) | |
885 self.assertEqual('/series/f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['Path']) | |
886 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[1][series]) | |
887 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[1][study]) | |
888 self.assertEqual('ozp00SjY2xG', e[1][patient]) | |
889 | |
890 self.assertEqual(8, len(e[2])) | |
891 self.assertEqual('Study', e[2]['ResourceType']) | |
892 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['ID']) | |
893 self.assertEqual('/studies/b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['Path']) | |
894 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[2][study]) | |
895 self.assertEqual('ozp00SjY2xG', e[2][patient]) | |
896 | |
897 self.assertEqual(7, len(e[3])) | |
898 self.assertEqual('Patient', e[3]['ResourceType']) | |
899 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['ID']) | |
900 self.assertEqual('/patients/6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['Path']) | |
901 self.assertEqual('ozp00SjY2xG', e[3][patient]) | |
902 | |
903 DropOrthanc(_REMOTE) | |
904 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
905 | |
906 | |
907 def test_store_peer(self): | |
908 self.assertEqual(0, len(DoGet(_LOCAL, '/exports')['Exports'])) | |
909 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
910 | |
911 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
912 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
913 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
914 | |
915 j = DoPost(_REMOTE, '/peers/peer/store', str(i), 'text/plain') | |
916 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
917 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
918 | |
919 self.assertEqual(1, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
920 | |
921 DropOrthanc(_REMOTE) | |
922 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
923 | |
924 | |
925 def test_bulk_storescu(self): | |
926 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
927 | |
928 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
929 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
930 | |
931 j = DoPost(_REMOTE, '/modalities/orthanctest/store', [ a['ID'], b['ID'] ], 'application/json') | |
932 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
933 | |
934 DropOrthanc(_LOCAL) | |
935 | |
936 # Send using patient's UUID | |
937 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
938 j = DoPost(_REMOTE, '/modalities/orthanctest/store', | |
939 [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ], 'application/json') | |
940 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
941 | |
942 | |
943 def test_color(self): | |
944 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
945 im = GetImage(_REMOTE, '/instances/%s/preview' % i) | |
946 self.assertEqual("RGB", im.mode) | |
947 self.assertEqual(41, im.size[0]) | |
948 self.assertEqual(41, im.size[1]) | |
949 | |
950 # http://effbot.org/zone/pil-comparing-images.htm | |
13 | 951 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) |
11 | 952 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) |
953 | |
954 | |
12 | 955 def test_faking_ruby_put(self): |
956 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
957 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
958 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
959 a = DoGet(_REMOTE, '/patients')[0] | |
960 b = DoGet(_REMOTE, '/patients')[1] | |
961 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
962 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
963 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
964 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '1') | |
965 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
966 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
967 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
968 | |
969 | |
970 def test_faking_ruby_delete(self): | |
971 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
972 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
973 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
974 a = DoGet(_REMOTE, '/patients')[0] | |
975 b = DoGet(_REMOTE, '/patients')[1] | |
976 DoGet(_REMOTE, '/patients/%s' % a, data = { '_method' : 'DELETE' }) | |
977 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
978 DoGet(_REMOTE, '/patients/%s' % b, data = { '_method' : 'DELETE' }) | |
979 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
980 | |
981 | |
982 def test_faking_google_put(self): | |
983 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
984 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
985 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
986 a = DoGet(_REMOTE, '/patients')[0] | |
987 b = DoGet(_REMOTE, '/patients')[1] | |
988 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
989 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
990 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
991 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '1') | |
992 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
993 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
994 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
995 | |
996 | |
997 def test_faking_google_delete(self): | |
998 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
999 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1000 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1001 a = DoGet(_REMOTE, '/patients')[0] | |
1002 b = DoGet(_REMOTE, '/patients')[1] | |
1003 DoPost(_REMOTE, '/patients/%s' % a, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
1004 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1005 DoPost(_REMOTE, '/patients/%s' % b, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
1006 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1007 | |
1008 | |
1009 def test_lua(self): | |
1010 self.assertEqual(42, DoPost(_REMOTE, '/tools/execute-script', 'print(42)')) | |
1011 self.assertTrue(IsDefinedInLua(_REMOTE, 'PrintRecursive')) | |
1012 self.assertFalse(IsDefinedInLua(_REMOTE, 'HelloWorld')) | |
1013 | |
1014 | |
1015 def test_metadata(self): | |
1016 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
1017 p = DoGet(_REMOTE, '/patients')[0] | |
1018 i = DoGet(_REMOTE, '/instances')[0] | |
1019 | |
1020 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1021 self.assertEqual(1, len(m)) | |
1022 self.assertEqual('LastUpdate', m[0]) | |
1023 | |
1024 m = DoGet(_REMOTE, '/instances/%s/metadata' % i) | |
145 | 1025 self.assertEqual(8, len(m)) |
12 | 1026 self.assertTrue('IndexInSeries' in m) |
1027 self.assertTrue('ReceptionDate' in m) | |
1028 self.assertTrue('RemoteAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1029 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1030 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1031 self.assertTrue('SopClassUid' in m) |
145 | 1032 self.assertTrue('RemoteIP' in m) |
1033 self.assertTrue('HttpUsername' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1034 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
|
1035 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
|
1036 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
|
1037 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
|
1038 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % i), '1.2.840.10008.5.1.4.1.1.4') |
12 | 1039 |
1040 # Play with custom metadata | |
1041 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'coucou') | |
1042 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1043 self.assertEqual(2, len(m)) | |
1044 self.assertTrue('LastUpdate' in m) | |
1045 self.assertTrue('5555' in m) | |
1046 self.assertEqual('coucou', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1047 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'hello') | |
1048 self.assertEqual('hello', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1049 DoDelete(_REMOTE, '/patients/%s/metadata/5555' % p) | |
1050 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1051 self.assertEqual(1, len(m)) | |
1052 self.assertTrue('LastUpdate' in m) | |
13 | 1053 |
1054 | |
1055 def test_statistics(self): | |
1056 # Upload 16 instances | |
1057 for i in range(4): | |
1058 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1059 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1060 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1061 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1062 | |
1063 s = DoGet(_REMOTE, '/statistics') | |
1064 self.assertEqual(16, s['CountInstances']) | |
1065 self.assertEqual(2, s['CountPatients']) | |
1066 self.assertEqual(2, s['CountStudies']) | |
1067 self.assertEqual(4, s['CountSeries']) | |
1068 d = int(s['TotalUncompressedSize']) | |
1069 | |
1070 e = 0 | |
1071 for patient in DoGet(_REMOTE, '/patients'): | |
1072 s = DoGet(_REMOTE, '/patients/%s/statistics' % patient) | |
1073 self.assertEqual(8, s['CountInstances']) | |
1074 self.assertEqual(1, s['CountStudies']) | |
1075 self.assertEqual(2, s['CountSeries']) | |
1076 e += int(s['UncompressedSize']) | |
1077 | |
1078 for study in DoGet(_REMOTE, '/studies'): | |
1079 s = DoGet(_REMOTE, '/studies/%s/statistics' % study) | |
1080 self.assertEqual(8, s['CountInstances']) | |
1081 self.assertEqual(2, s['CountSeries']) | |
1082 e += int(s['UncompressedSize']) | |
1083 | |
1084 for series in DoGet(_REMOTE, '/series'): | |
1085 s = DoGet(_REMOTE, '/series/%s/statistics' % series) | |
1086 self.assertEqual(4, s['CountInstances']) | |
1087 e += int(s['UncompressedSize']) | |
1088 | |
1089 self.assertEqual(3 * d, e) | |
1090 | |
1091 | |
1092 def test_custom_attachment(self): | |
1093 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1094 patient = DoGet(_REMOTE, '/patients')[0] | |
1095 instance = DoGet(_REMOTE, '/instances')[0] | |
1096 size = int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']) | |
1097 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1098 | |
1099 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1100 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) | |
1101 self.assertTrue('dicom' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1102 self.assertTrue('dicom-as-json' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1103 | |
1104 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/22' % patient, 'hello')) | |
1105 hello = 'hellohellohellohellohellohellohellohellohello' | |
1106 DoPut(_REMOTE, '/patients/%s/attachments/1025' % patient, hello) | |
1107 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1108 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1109 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1110 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient))) | |
1111 | |
1112 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world') | |
1113 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1114 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1115 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1116 size + | |
1117 int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient)) + | |
1118 int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1119 | |
1120 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1121 self.assertEqual(hello, DoGet(_REMOTE, '/patients/%s/attachments/1025/data' % patient)) | |
1122 self.assertEqual('world', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1123 DoPost(_REMOTE, '/patients/%s/attachments/1025/verify-md5' % patient) | |
1124 DoPost(_REMOTE, '/patients/%s/attachments/1026/verify-md5' % patient) | |
1125 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world2') | |
1126 self.assertEqual('world2', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1127 | |
1128 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) | |
1129 DoDelete(_REMOTE, '/patients/%s/attachments/1025' % patient) | |
1130 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1131 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1132 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1133 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1134 | |
1135 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1136 DoDelete(_REMOTE, '/patients/%s/attachments/1026' % patient) | |
1137 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1138 | |
1139 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), size) | |
1140 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1141 | |
1142 | |
1143 def test_incoming_storescu(self): | |
1144 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
45 | 1145 subprocess.check_call([ FindExecutable('storescu'), |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
1146 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
13 | 1147 GetDatabasePath('ColorTestImageJ.dcm') ]) |
1148 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1149 | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1150 i = DoGet(_REMOTE, '/instances') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1151 self.assertEqual(1, len(i)) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1152 m = DoGet(_REMOTE, '/instances/%s/metadata' % i[0]) |
145 | 1153 self.assertEqual(8, len(m)) |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1154 self.assertTrue('IndexInSeries' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1155 self.assertTrue('ReceptionDate' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1156 self.assertTrue('RemoteAET' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1157 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1158 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1159 self.assertTrue('SopClassUid' in m) |
145 | 1160 self.assertTrue('RemoteIP' in m) |
1161 self.assertTrue('CalledAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1162 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
|
1163 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
|
1164 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
|
1165 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
|
1166 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
|
1167 |
13 | 1168 |
1169 def test_incoming_findscu(self): | |
1170 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
1171 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') | |
1172 | |
1173 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', '0010,0010' ]) | |
1174 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) | |
1175 self.assertEqual(2, len(patientNames)) | |
1176 self.assertTrue('Test Patient BG ' in patientNames) | |
1177 self.assertTrue('Anonymized' in patientNames) | |
1178 | |
1179 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021' ]) | |
1180 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) | |
1181 self.assertEqual(2, len(series)) | |
1182 self.assertTrue('20070208' in series) | |
1183 self.assertTrue('19980312' in series) | |
1184 | |
56
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1185 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
|
1186 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1187 self.assertEqual(1, len(series)) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1188 self.assertTrue('19980312' in series) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1189 |
13 | 1190 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=Anonymized' ]) |
1191 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1192 self.assertEqual(1, len(series)) | |
1193 | |
1194 # Test the "CaseSentitivePN" flag (false by default) | |
1195 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=anonymized' ]) | |
1196 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1197 self.assertEqual(1, len(series)) | |
66
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1198 |
70 | 1199 # Test range search (buggy if Orthanc <= 0.9.6) |
1200 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-' ]) | |
1201 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1202 self.assertEqual(2, len(studies)) | |
1203 self.assertTrue('20070208' in studies) | |
1204 self.assertTrue('19980312' in studies) | |
1205 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-19980312' ]) | |
1206 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1207 self.assertEqual(1, len(studies)) | |
1208 self.assertTrue('19980312' in studies) | |
1209 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=-19980312' ]) | |
1210 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1211 self.assertEqual(1, len(studies)) | |
1212 self.assertTrue('19980312' in studies) | |
13 | 1213 |
1214 | |
191
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1215 def test_incoming_findscu_2(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1216 # This test fails if "LookupMode_DatabaseOnly" is used |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1217 # (sequences are not available in this mode, and only main |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1218 # DICOM tags are returned) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1219 UploadInstance(_REMOTE, 'Multiframe.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1220 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1221 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1222 # Test returning sequence values (only since Orthanc 0.9.5) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1223 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,2112' ]) # "ColorTestImageJ" has this sequence tag |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1224 sequences = re.findall('\(0008,2112\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1225 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1226 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1227 # Test returning a non-main DICOM tag, |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1228 # "SecondaryCaptureDeviceID" (0018,1010), whose value is |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1229 # "MEDPC" in "ColorTestImageJ.dcm" |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1230 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0018,1010' ]) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1231 tags = re.findall('\(0018,1010\).*MEDPC', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1232 self.assertEqual(1, len(tags)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1233 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1234 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1235 def test_incoming_findscu_3(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1236 # This test fails if "LookupMode_DatabaseOnly" or |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1237 # "LookupMode_DiskOnAnswer" is used, as |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1238 # "SecondaryCaptureDeviceID" (0018,1010) is not a main DICOM |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1239 # tag, as thus a constraint cannot be applied to it |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1240 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1241 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1242 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0018,1010=MEDPC' ]) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1243 sequences = re.findall('\(0018,1010\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1244 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1245 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1246 |
13 | 1247 def test_incoming_movescu(self): |
1248 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1249 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1250 # No matching patient, so no job is created |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1251 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1252 CallMoveScu([ '--patient', '-k', '0008,0052=PATIENT', '-k', 'PatientID=none' ]) |
13 | 1253 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1254 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1255 # 1 Matching patient, track the job |
138 | 1256 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
1257 '--patient', | |
1258 '-k', '0008,0052=PATIENT', | |
1259 '-k', 'PatientID=12345678' | |
1260 ]))) | |
13 | 1261 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
1262 | |
1263 | |
1264 def test_findscu(self): | |
1265 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1266 j = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
1267 k = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] | |
1268 DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1269 | |
1270 # Test the "find-patient" level | |
1271 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1272 self.assertEqual(1, len(p)) | |
1273 self.assertEqual('ozp00SjY2xG', p[0]['PatientID']) | |
1274 | |
1275 # Test wildcards constraints. The "LO" value representation | |
1276 # for PatientID is always case-sensitive, but the "PN" for | |
1277 # PatientName might depend on the implementation: | |
1278 # "GenerateConfigurationForTests.py" will force it to be case | |
1279 # insensitive (which was the default until Orthanc 0.8.6). | |
1280 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'K*' }) | |
1281 self.assertEqual(1, len(p)) | |
1282 | |
1283 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'k*' }) | |
1284 self.assertEqual(1, len(p)) | |
1285 | |
1286 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'ozp*' }) | |
1287 self.assertEqual(1, len(p)) | |
1288 | |
1289 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'o?p*' }) | |
1290 self.assertEqual(1, len(p)) | |
1291 | |
1292 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : '0?q*' }) | |
1293 self.assertEqual(0, len(p)) | |
1294 | |
1295 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'B*' }) | |
1296 self.assertEqual(0, len(p)) | |
1297 | |
1298 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'b*' }) | |
1299 self.assertEqual(0, len(p)) | |
1300 | |
1301 DoPost(_REMOTE, '/modalities/orthanctest/store', str(j), 'text/plain') | |
1302 DoPost(_REMOTE, '/modalities/orthanctest/store', str(k), 'text/plain') | |
1303 DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1304 self.assertEqual(3, len(DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }))) | |
1305 | |
1306 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'A*' }) | |
1307 self.assertEqual(2, len(p)) | |
1308 | |
1309 # Test the "find-study" level. This is the instance "ColorTestImageJ.dcm" | |
1310 s = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ' }) | |
1311 self.assertEqual(1, len(s)) | |
1312 self.assertEqual('20070208', s[0]['StudyDate']) | |
1313 | |
1314 # Test range searches | |
1315 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1316 'StudyDate' : '-20070101' }) | |
1317 self.assertEqual(0, len(t)) | |
1318 | |
1319 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1320 'StudyDate' : '20090101-' }) | |
1321 self.assertEqual(0, len(t)) | |
1322 | |
1323 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1324 'StudyDate' : '20070101-' }) | |
1325 self.assertEqual(1, len(t)) | |
1326 | |
1327 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1328 'StudyDate' : '-20090101' }) | |
1329 self.assertEqual(1, len(t)) | |
1330 | |
1331 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1332 'StudyDate' : '20070207-20070207' }) | |
1333 self.assertEqual(0, len(t)) | |
1334 | |
1335 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1336 'StudyDate' : '20070208-20070208' }) | |
1337 self.assertEqual(1, len(t)) | |
1338 | |
1339 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1340 'StudyDate' : '20070209-20070209' }) | |
1341 self.assertEqual(0, len(t)) | |
1342 | |
1343 # Test the ModalitiesInStudy tag | |
1344 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1345 'PatientID' : 'B9uTHKOZ', | |
1346 'ModalitiesInStudy' : 'US' }) | |
1347 self.assertEqual(0, len(t)) | |
1348 | |
1349 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1350 'PatientID' : 'B9uTHKOZ', | |
1351 'ModalitiesInStudy' : 'CT' }) | |
1352 self.assertEqual(1, len(t)) | |
1353 | |
1354 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1355 'PatientID' : 'B9uTHKOZ', | |
1356 'ModalitiesInStudy' : 'US\\CT' }) | |
1357 self.assertEqual(1, len(t)) | |
1358 | |
1359 # Test the "find-series" level | |
1360 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1361 'PatientID' : 'B9uTHKOZ', | |
1362 'StudyInstanceUID' : s[0]['StudyInstanceUID'] }) | |
1363 self.assertEqual(1, len(t)) | |
1364 | |
1365 # Test "\" separator | |
1366 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1367 'PatientID' : 'B9uTHKOZ', | |
1368 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1369 'Modality' : 'MR\\CT\\US' }) | |
1370 self.assertEqual(1, len(t)) | |
1371 | |
1372 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1373 'PatientID' : 'B9uTHKOZ', | |
1374 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1375 'Modality' : 'MR\\US' }) | |
1376 self.assertEqual(0, len(t)) | |
1377 | |
1378 | |
1379 def test_update_modalities(self): | |
1380 try: | |
1381 DoDelete(_REMOTE, '/modalities/toto') | |
1382 except: | |
1383 pass | |
1384 try: | |
1385 DoDelete(_REMOTE, '/modalities/tata') | |
1386 except: | |
1387 pass | |
1388 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1389 DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000 ]) | |
116 | 1390 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'MedInria' ]) # check backward compatiblity with obsolete manufacturer |
1391 DoDelete(_REMOTE, '/modalities/tata') | |
124 | 1392 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoUniversalWildcard' ]) |
121
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1393 DoDelete(_REMOTE, '/modalities/tata') |
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1394 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoWildcardInDates' ]) |
128 | 1395 modalitiesReadback = DoGet(_REMOTE, '/modalities?expand') |
182
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1396 self.assertEqual('STORESCP', modalitiesReadback['tata']['AET']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1397 self.assertEqual('localhost', modalitiesReadback['tata']['Host']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1398 self.assertEqual(2000, modalitiesReadback['tata']['Port']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1399 self.assertEqual('GenericNoWildcardInDates', modalitiesReadback['tata']['Manufacturer']) |
116 | 1400 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000, 'InvalidManufacturerName' ])) |
13 | 1401 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/toto')) |
1402 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/tata')) | |
1403 DoDelete(_REMOTE, '/modalities/toto') | |
1404 DoDelete(_REMOTE, '/modalities/tata') | |
1405 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1406 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/tata')) | |
1407 | |
1408 | |
1409 def test_update_peers(self): | |
1410 # curl -X PUT http://localhost:8042/peers/toto -d '["http://localhost:8042/"]' -v | |
1411 try: | |
1412 DoDelete(_REMOTE, '/peers/toto') | |
1413 except: | |
1414 pass | |
1415 try: | |
1416 DoDelete(_REMOTE, '/peers/tata') | |
1417 except: | |
1418 pass | |
1419 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1420 DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/' ]) | |
214 | 1421 DoPut(_REMOTE, '/peers/tata', { 'Url': 'http://localhost:8042/', |
1422 'Username': 'user', | |
1423 'Password' : 'pass', | |
1424 'RemoteSelf' : 'self' }) | |
128 | 1425 self.assertTrue('tata' in DoGet(_REMOTE, '/peers')) |
1426 peersReadback = DoGet(_REMOTE, '/peers?expand') | |
1427 self.assertEqual('http://localhost:8042/', peersReadback['tata']['Url']) | |
1428 self.assertEqual('user', peersReadback['tata']['Username']) | |
214 | 1429 |
1430 if IsOrthancVersionAbove(_REMOTE, 1, 5, 4): | |
1431 self.assertEqual(None, peersReadback['tata']['Password']) # make sure no sensitive data is included | |
1432 self.assertFalse(peersReadback['tata']['Pkcs11']) # make sure no sensitive data is included | |
1433 self.assertEqual('self', peersReadback['tata']['RemoteSelf']) | |
1434 else: | |
1435 self.assertFalse('Password' in peersReadback['tata']) # make sure no sensitive data is included | |
1436 self.assertFalse('Pkcs11' in peersReadback['tata']) # make sure no sensitive data is included | |
1437 self.assertFalse('RemoteSelf' in peersReadback['tata']) | |
1438 | |
128 | 1439 self.assertFalse('CertificateFile' in peersReadback['tata']) # make sure no sensitive data is included |
1440 self.assertFalse('CertificateKeyFile' in peersReadback['tata']) # make sure no sensitive data is included | |
1441 self.assertFalse('CertificateKeyPassword' in peersReadback['tata']) # make sure no sensitive data is included | |
214 | 1442 |
13 | 1443 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a' ])) |
1444 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a', 'b', 'c' ])) | |
1445 self.assertTrue('store' in DoGet(_REMOTE, '/peers/toto')) | |
1446 self.assertTrue('store' in DoGet(_REMOTE, '/peers/tata')) | |
1447 DoDelete(_REMOTE, '/peers/toto') | |
1448 DoDelete(_REMOTE, '/peers/tata') | |
1449 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1450 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/tata')) | |
1451 | |
1452 | |
1453 def test_mesterhazy_modification(self): | |
1454 # When I modify a series ( eg. curl | |
1455 # http://localhost:8042/series/uidhere/modify -X POST -d | |
1456 # '{"Replace":{"SeriesDate":"19990101"}}' ) the modified | |
1457 # series is added to a new Study, instead of the existing | |
1458 # Study. Fixed in Orthanc 0.7.5 | |
1459 | |
1460 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1461 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1462 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1463 | |
1464 modified = DoPost(_REMOTE, '/series/%s/modify' % series, | |
1465 json.dumps({ "Replace" : { "SeriesDate" : "19990101" }})) | |
1466 | |
1467 self.assertEqual(study, DoGet(_REMOTE, '/series/%s' % modified['ID']) ['ParentStudy']) | |
1468 | |
1469 | |
1470 def test_create(self): | |
1471 i = DoPost(_REMOTE, '/tools/create-dicom', | |
1472 json.dumps({ | |
1473 'PatientName' : 'Jodogne', | |
1474 'Modality' : 'CT', | |
58 | 1475 'SOPClassUID' : '1.2.840.10008.5.1.4.1.1.1', |
13 | 1476 'PixelData' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' # red dot in RGBA |
1477 })) | |
1478 | |
1479 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
1480 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
1481 | |
1482 png = GetImage(_REMOTE, '/instances/%s/preview' % i['ID']) | |
1483 self.assertEqual((5, 5), png.size) | |
1484 | |
38 | 1485 j = DoGet(_REMOTE, i['Path']) |
1486 self.assertEqual('Instance', j['Type']) | |
1487 self.assertEqual(j['ID'], i['ID']) | |
1488 | |
13 | 1489 |
1490 def test_pilates(self): | |
1491 # "SCU failed error when accessing orthanc with osirix" by | |
1492 # Pilates Agentur (Mar 10, 2014 at 9:33 PM) | |
1493 i = UploadInstance(_REMOTE, 'PilatesArgenturGEUltrasoundOsiriX.dcm')['ID'] | |
1494 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
1495 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1496 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
1497 | |
1498 | |
1499 def test_shared_tags(self): | |
1500 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1501 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm')['ID'] | |
1502 p = DoGet(_REMOTE, '/patients')[0] | |
1503 | |
1504 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1505 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
|
1506 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
|
1507 |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1508 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
|
1509 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
|
1510 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
|
1511 |
13 | 1512 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) |
1513 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1514 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1515 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1516 self.assertFalse('0008,0018' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1517 self.assertFalse('SOPInstanceUID' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1518 | |
1519 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/tags' % a)) | |
1520 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)) | |
1521 | |
1522 | |
1523 def test_modules(self): | |
1524 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1525 p = DoGet(_REMOTE, '/patients')[0] | |
1526 s = DoGet(_REMOTE, '/studies')[0] | |
1527 t = DoGet(_REMOTE, '/series')[0] | |
1528 | |
1529 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/module' % p)) | |
1530 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/module?simplify' % p)) | |
1531 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/studies/%s/module-patient' % p)) | |
1532 self.assertTrue('PatientName' in DoGet(_REMOTE, '/studies/%s/module-patient?simplify' % p)) | |
1533 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/studies/%s/module' % s)) | |
1534 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/studies/%s/module?simplify' % s)) | |
1535 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/series/%s/module' % p)) | |
1536 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/series/%s/module?simplify' % p)) | |
1537 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/module' % a)) | |
1538 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/module?simplify' % a)) | |
1539 | |
1540 | |
1541 def test_auto_directory(self): | |
1542 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1543 self.assertTrue('now' in DoGet(_REMOTE, '/tools')) | |
1544 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
|
1545 self.assertTrue('invalidate-tags' in DoGet(_REMOTE, '/tools')) |
13 | 1546 self.assertTrue(len(DoGet(_REMOTE, '/tools/dicom-conformance')) > 1000) |
1547 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
1548 self.assertTrue('echo' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1549 self.assertTrue('find' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1550 self.assertTrue('find-instance' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1551 self.assertTrue('find-patient' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1552 self.assertTrue('find-series' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1553 self.assertTrue('find-study' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1554 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1555 self.assertTrue('store' in DoGet(_REMOTE, '/peers/peer')) | |
1556 self.assertTrue('matlab' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) | |
79 | 1557 self.assertTrue('raw' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) |
13 | 1558 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/tools/nope')) |
28 | 1559 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope')) |
1560 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope/nope.html')) | |
1561 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope')[0].status) | |
1562 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope/nope.html')[0].status) | |
13 | 1563 |
1564 | |
1565 def test_echo(self): | |
1566 DoPost(_REMOTE, '/modalities/orthanctest/echo') | |
1567 | |
1568 | |
1569 def test_xml(self): | |
1570 json = DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/json' }) | |
1571 xml = minidom.parseString(DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/xml' })) | |
1572 items = xml.getElementsByTagName('root')[0].getElementsByTagName('item') | |
1573 self.assertEqual(len(items), len(json)) | |
1574 | |
1575 self.assertTrue('dicom-conformance' in json) | |
1576 | |
1577 ok = False | |
1578 for i in items: | |
1579 if i.childNodes[0].data == 'dicom-conformance': | |
1580 ok = True | |
1581 self.assertTrue(ok) | |
1582 | |
1583 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1584 def test_googlecode_issue_16(self): |
13 | 1585 i = UploadInstance(_REMOTE, 'Issue16.dcm')['ID'] |
1586 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['FrameIncrementPointer'] | |
1587 self.assertEqual('0018,1063', t) | |
1588 | |
1589 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1590 def test_googlecode_issue_22(self): |
13 | 1591 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] |
1592 a = [ | |
1593 "f804691f62197040438f4627c6b994f1", # Frame 0 | |
1594 "c69eee9a51eea3e8611e82e578897254", | |
1595 "315666be83e2d0111c77bc0996d84901", | |
1596 "3e27aa959d911172c48a1436443c72b1", | |
1597 "958642c9e7e9d232d3869faff546058c", | |
1598 "5e7ea8e3e4230cae707d143481355c59", | |
1599 "eda37f83558d858a596175aed8b2ad47", | |
1600 "486713bd2895c4ecbe0e97715ac7f80a", | |
1601 "091ef729eb169e67da8a0faa9631f9a8", | |
1602 "5aa2b8c7ffe0a483efaa8e12417686ca", | |
1603 "e2f39e85896fe58876654b94cd0b5013", | |
1604 "6fd2129e4950abbe1be053bc814d5da8", | |
1605 "c3331a8ba7a757f3d423735ab7fa81f9", | |
1606 "746f808582156734dd6b6fdfd3a0b72c", | |
1607 "8075ea2b227a70c60ea6b7b75a6bb190", | |
1608 "806b8b3e300c615099c11a5ec23465aa", | |
1609 "7c836aa298ba6eef96434579af631a11", | |
1610 "a0357dc9f4f72d73a885c33d7c287446", | |
1611 "f25ba3be1cc7d7fad95706adc199ea7d", | |
1612 "8b114c526b8cbed6cad8a3248b7b480c", | |
1613 "44e6670f127e612a2b4aa60a0d207698", | |
1614 "b8945f90fe02facf2ace24ca1ecbe0a5", | |
1615 "95c796c2fa8f59018b15cf2987b1f79b", | |
1616 "ce0a51ab30224205b44920221dc27351", # Frame 23 | |
1617 ] | |
1618 | |
1619 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
1620 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/preview' % s)) | |
1621 | |
1622 for i in range(len(a)): | |
1623 self.assertEqual(a[i], ComputeMD5(DoGet(_REMOTE, '/instances/%s/frames/%d/preview' % (s, i)))) | |
1624 | |
1625 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1626 def test_googlecode_issue_19(self): |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1627 # This is an image with "YBR_FULL" photometric interpretation, it is not supported by Orthanc |
13 | 1628 # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm |
1629 | |
1630 a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID'] | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1631 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) |
13 | 1632 |
1633 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1634 def test_googlecode_issue_37(self): |
13 | 1635 # Same test for issues 35 and 37. Fixed in Orthanc 0.9.1 |
1636 u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] | |
1637 | |
1638 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1639 'CaseSensitive' : True, | |
1640 'Query' : { 'StationName' : 'SMR4-MP3' }}) | |
1641 self.assertEqual(1, len(a)) | |
14 | 1642 |
1643 | |
1644 def test_rest_find(self): | |
1645 # Upload 8 instances | |
1646 for i in range(2): | |
1647 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1648 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1649 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1650 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1651 | |
1652 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1653 'CaseSensitive' : False, | |
194
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1654 'Query' : { 'PatientName' : 'BRAINIX' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1655 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1656 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1657 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1658 'CaseSensitive' : False, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1659 'Query' : { 'PatientName' : 'BRAINIX\\KNEE\\NOPE' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1660 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1661 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1662 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1663 'CaseSensitive' : False, |
14 | 1664 'Query' : { 'PatientName' : '*n*' }}) |
1665 self.assertEqual(2, len(a)) | |
1666 | |
1667 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1668 'CaseSensitive' : True, | |
1669 'Query' : { 'PatientName' : '*n*' }}) | |
1670 self.assertEqual(0, len(a)) | |
1671 | |
1672 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, | |
1673 'Level' : 'Patient', | |
1674 'CaseSensitive' : False, | |
1675 'Query' : { 'PatientName' : '*ne*' }}) | |
1676 self.assertEqual(1, len(a)) | |
1677 self.assertEqual('20080822', a[0]['MainDicomTags']['PatientBirthDate']) | |
1678 | |
1679 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1680 'CaseSensitive' : True, | |
1681 'Query' : { 'PatientName' : '*ne*' }}) | |
1682 self.assertEqual(0, len(a)) | |
1683 | |
1684 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', | |
1685 'CaseSensitive' : True, | |
1686 'Query' : { 'PatientName' : '*NE*' }}) | |
1687 self.assertEqual(1, len(a)) | |
1688 | |
1689 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1690 'CaseSensitive' : True, | |
1691 'Query' : { 'PatientName' : '*NE*' }}) | |
1692 self.assertEqual(2, len(a)) | |
1693 | |
1694 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
1695 'CaseSensitive' : True, | |
1696 'Query' : { 'PatientName' : '*NE*' }}) | |
1697 self.assertEqual(4, len(a)) | |
1698 | |
1699 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', 'Query' : { }}) | |
1700 self.assertEqual(2, len(a)) | |
1701 | |
1702 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', 'Query' : { }}) | |
1703 self.assertEqual(2, len(a)) | |
1704 | |
1705 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', 'Query' : { }}) | |
1706 self.assertEqual(4, len(a)) | |
1707 | |
1708 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', 'Query' : { }}) | |
1709 self.assertEqual(8, len(a)) | |
1710 | |
194
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1711 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1712 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1713 'Query' : { 'StudyDate' : '20061201-20061201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1714 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1715 self.assertEqual('BRAINIX', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1716 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1717 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1718 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1719 'Query' : { 'StudyDate' : '20061201-20091201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1720 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1721 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1722 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1723 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1724 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1725 'Query' : { 'StudyDate' : '20061202-20061202' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1726 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1727 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1728 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1729 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1730 'Query' : { 'StudyDate' : '-20061201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1731 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1732 self.assertEqual('BRAINIX', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1733 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1734 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1735 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1736 'Query' : { 'StudyDate' : '-20051201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1737 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1738 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1739 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1740 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1741 'Query' : { 'StudyDate' : '20061201-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1742 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1743 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1744 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1745 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1746 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1747 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1748 'Query' : { 'StudyDate' : '20061202-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1749 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1750 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1751 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1752 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1753 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1754 'Query' : { 'StudyDate' : '20080819-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1755 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1756 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1757 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1758 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1759 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1760 'Query' : { 'StudyDate' : '20080820-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1761 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1762 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1763 |
14 | 1764 |
1765 def test_rest_query_retrieve(self): | |
1766 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1767 | |
1768 # Upload 8 instances | |
1769 for i in range(2): | |
1770 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1771 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1772 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1773 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1774 | |
1775 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1776 for p in DoGet(_REMOTE, '/patients'): | |
1777 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
1778 DoDelete(_REMOTE, '/patients/%s' % p) | |
1779 | |
1780 for q in DoGet(_REMOTE, '/queries'): | |
1781 DoDelete(_REMOTE, '/queries/%s' % q) | |
1782 | |
1783 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1784 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1785 a = DoPost(_REMOTE, '/modalities/orthanctest/query', { 'Level' : 'Series', | |
27 | 1786 'Query' : { |
1787 'PatientName' : '*NE*', | |
1788 'StudyDate' : '*', | |
1789 }})['ID'] | |
14 | 1790 self.assertEqual(1, len(DoGet(_REMOTE, '/queries'))) |
1791 | |
1792 b = DoGet(_REMOTE, '/queries/%s' % a) | |
1793 self.assertTrue('answers' in b) | |
1794 self.assertTrue('level' in b) | |
1795 self.assertTrue('modality' in b) | |
1796 self.assertTrue('query' in b) | |
1797 self.assertTrue('retrieve' in b) | |
1798 self.assertEqual('Series', DoGet(_REMOTE, '/queries/%s/level' % a)) | |
1799 self.assertEqual('orthanctest', DoGet(_REMOTE, '/queries/%s/modality' % a)) | |
1800 | |
1801 q = DoGet(_REMOTE, '/queries/%s/query?simplify' % a) | |
27 | 1802 self.assertEqual(2, len(q)) |
14 | 1803 self.assertTrue('PatientName' in q) |
27 | 1804 self.assertTrue('StudyDate' in q) |
14 | 1805 self.assertEqual('*NE*', q['PatientName']) |
27 | 1806 self.assertEqual('*', q['StudyDate']) |
14 | 1807 |
1808 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) | |
1809 | |
1810 s = DoGet(_REMOTE, '/queries/%s/answers/0' % a) | |
1811 self.assertTrue('content' in s) | |
1812 self.assertTrue('retrieve' in s) | |
1813 | |
1814 s = DoGet(_REMOTE, '/queries/%s/answers/0/content?simplify' % a) | |
1815 self.assertEqual('887', s['PatientID']) | |
1816 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s['StudyInstanceUID']) | |
1817 | |
1818 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1819 DoPost(_REMOTE, '/queries/%s/answers/0/retrieve' % a, 'ORTHANC') | |
1820 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1821 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1822 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
1823 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
1824 | |
112 | 1825 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 | 1826 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
1827 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1828 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1829 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
1830 | |
186
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1831 # New in Orthanc 1.4.3 |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1832 s = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1833 self.assertEqual(2, len(s)) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1834 for i in range(2): |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1835 self.assertEqual('SERIES', s[i]['QueryRetrieveLevel']) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1836 self.assertEqual('887', s[i]['PatientID']) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1837 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s[i]['StudyInstanceUID']) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1838 |
14 | 1839 DoDelete(_REMOTE, '/queries/%s' % a) |
1840 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1841 | |
1842 | |
1843 def test_parent(self): | |
1844 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1845 patient = '6816cb19-844d5aee-85245eba-28e841e6-2414fae2' | |
1846 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1847 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1848 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
1849 self.assertEqual(instance, u) |
14 | 1850 |
1851 a = DoGet(_REMOTE, '/studies/%s/patient' % study) | |
1852 self.assertEqual('Patient', a['Type']) | |
1853 self.assertEqual(patient, a['ID']) | |
1854 | |
1855 a = DoGet(_REMOTE, '/series/%s/patient' % series) | |
1856 self.assertEqual('Patient', a['Type']) | |
1857 self.assertEqual(patient, a['ID']) | |
1858 | |
1859 a = DoGet(_REMOTE, '/series/%s/study' % series) | |
1860 self.assertEqual('Study', a['Type']) | |
1861 self.assertEqual(study, a['ID']) | |
1862 | |
1863 a = DoGet(_REMOTE, '/instances/%s/patient' % instance) | |
1864 self.assertEqual('Patient', a['Type']) | |
1865 self.assertEqual(patient, a['ID']) | |
1866 | |
1867 a = DoGet(_REMOTE, '/instances/%s/study' % instance) | |
1868 self.assertEqual('Study', a['Type']) | |
1869 self.assertEqual(study, a['ID']) | |
1870 | |
1871 a = DoGet(_REMOTE, '/instances/%s/series' % instance) | |
1872 self.assertEqual('Series', a['Type']) | |
1873 self.assertEqual(series, a['ID']) | |
1874 | |
1875 | |
1876 def test_shanon(self): | |
1877 def Anonymize(instance, replacements = {}): | |
119 | 1878 return DoPost(_REMOTE, '/instances/%s/anonymize' % instance, { |
1879 'Replace' : replacements, | |
1880 'Force' : True, | |
1881 }, 'application/json') | |
14 | 1882 |
1883 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1884 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1885 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1886 | |
1887 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1888 ids = [ 'ozp00SjY2xG', | |
1889 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1890 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1891 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1892 | |
1893 a = ExtractDicomTags(Anonymize(u), tags) | |
1894 for i in range(4): | |
1895 self.assertNotEqual(ids[i], a[i]) | |
1896 self.assertTrue(a[4].startswith('Orthanc')) | |
1897 | |
1898 a = ExtractDicomTags(Anonymize(u, { 'PatientName' : 'toto' }), tags) | |
1899 for i in range(4): | |
1900 self.assertNotEqual(ids[i], a[i]) | |
1901 self.assertFalse(a[4].startswith('Orthanc')) | |
1902 | |
1903 a = ExtractDicomTags(Anonymize(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1904 self.assertEqual('instance', a[3]) | |
1905 self.assertFalse(a[4].startswith('Orthanc')) | |
1906 | |
1907 a = ExtractDicomTags(Anonymize(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1908 self.assertEqual('series', a[2]) | |
1909 self.assertFalse(a[4].startswith('Orthanc')) | |
1910 | |
1911 a = ExtractDicomTags(Anonymize(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1912 self.assertEqual('study', a[1]) | |
1913 self.assertFalse(a[4].startswith('Orthanc')) | |
1914 | |
1915 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient' }), tags) | |
1916 self.assertEqual('patient', a[0]) | |
1917 self.assertFalse(a[4].startswith('Orthanc')) | |
1918 | |
1919 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient', | |
1920 'StudyInstanceUID' : 'study', | |
1921 'SeriesInstanceUID' : 'series', | |
1922 'SOPInstanceUID' : 'instance' }), tags) | |
1923 self.assertEqual('patient', a[0]) | |
1924 self.assertFalse(a[4].startswith('Orthanc')) | |
1925 | |
1926 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1927 | |
1928 | |
1929 def test_shanon_2(self): | |
1930 def Modify(instance, replacements = {}): | |
119 | 1931 return DoPost(_REMOTE, '/instances/%s/modify' % instance, { |
1932 'Replace' : replacements, | |
1933 'Force': True, | |
1934 }, 'application/json') | |
14 | 1935 |
1936 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1937 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1938 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1939 | |
1940 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1941 ids = [ 'ozp00SjY2xG', | |
1942 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1943 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1944 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1945 | |
1946 a = ExtractDicomTags(Modify(u), tags) | |
1947 self.assertEqual(ids[0], a[0]) | |
1948 self.assertEqual(ids[1], a[1]) | |
1949 self.assertEqual(ids[2], a[2]) | |
1950 self.assertNotEqual(ids[3], a[3]) | |
1951 self.assertEqual(0, len(a[4])) | |
1952 | |
1953 a = ExtractDicomTags(Modify(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1954 self.assertEqual(ids[0], a[0]) | |
1955 self.assertEqual(ids[1], a[1]) | |
1956 self.assertEqual(ids[2], a[2]) | |
1957 self.assertEqual('instance', a[3]) | |
1958 | |
1959 a = ExtractDicomTags(Modify(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1960 self.assertEqual(ids[0], a[0]) | |
1961 self.assertEqual(ids[1], a[1]) | |
1962 self.assertEqual('series', a[2]) | |
1963 self.assertNotEqual(ids[3], a[3]) | |
1964 | |
1965 a = ExtractDicomTags(Modify(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1966 self.assertEqual(ids[0], a[0]) | |
1967 self.assertEqual('study', a[1]) | |
1968 self.assertNotEqual(ids[2], a[2]) | |
1969 self.assertNotEqual(ids[3], a[3]) | |
1970 | |
1971 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient' }), tags) | |
1972 self.assertEqual('patient', a[0]) | |
1973 self.assertNotEqual(ids[1], a[1]) | |
1974 self.assertNotEqual(ids[2], a[2]) | |
1975 self.assertNotEqual(ids[3], a[3]) | |
1976 | |
1977 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient', | |
1978 'StudyInstanceUID' : 'study', | |
1979 'SeriesInstanceUID' : 'series', | |
1980 'SOPInstanceUID' : 'instance' }), tags) | |
1981 self.assertEqual('patient', a[0]) | |
1982 self.assertEqual('study', a[1]) | |
1983 self.assertEqual('series', a[2]) | |
1984 self.assertEqual('instance', a[3]) | |
1985 | |
1986 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1987 | |
1988 | |
1989 def test_instances_tags(self): | |
1990 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1991 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] | |
1992 #a = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386937.676343')['ID'] | |
1993 #b = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386925.676329')['ID'] | |
1994 | |
1995 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/patients')[0]) | |
1996 self.assertEqual(2, len(i)) | |
1997 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1998 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1999 | |
2000 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/studies')[0]) | |
2001 self.assertEqual(2, len(i)) | |
2002 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2003 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
2004 | |
2005 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
2006 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[0]) | |
2007 self.assertEqual(1, len(i)) | |
2008 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2009 | |
2010 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[1]) | |
2011 self.assertEqual(1, len(i)) | |
2012 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2013 | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2014 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
|
2015 self.assertEqual(1, len(i)) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2016 self.assertEqual('887', i[i.keys()[0]]['0010,0020']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2017 |
14 | 2018 |
2019 def test_lookup(self): | |
2020 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
2021 self.assertEqual(0, len(a)) | |
2022 | |
2023 UploadInstance(_REMOTE, 'DummyCT.dcm') | |
2024 | |
2025 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
2026 self.assertEqual(1, len(a)) | |
2027 self.assertEqual('Patient', a[0]['Type']) | |
2028 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', a[0]['ID']) | |
2029 self.assertEqual('/patients/%s' % a[0]['ID'], a[0]['Path']) | |
2030 | |
2031 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390') | |
2032 self.assertEqual(1, len(a)) | |
2033 self.assertEqual('Study', a[0]['Type']) | |
2034 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', a[0]['ID']) | |
2035 self.assertEqual('/studies/%s' % a[0]['ID'], a[0]['Path']) | |
2036 | |
2037 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394') | |
2038 self.assertEqual(1, len(a)) | |
2039 self.assertEqual('Series', a[0]['Type']) | |
2040 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', a[0]['ID']) | |
2041 self.assertEqual('/series/%s' % a[0]['ID'], a[0]['Path']) | |
2042 | |
2043 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109') | |
2044 self.assertEqual(1, len(a)) | |
2045 self.assertEqual('Instance', a[0]['Type']) | |
2046 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a[0]['ID']) | |
2047 self.assertEqual('/instances/%s' % a[0]['ID'], a[0]['Path']) | |
2048 | |
2049 DropOrthanc(_REMOTE) | |
2050 a = DoPost(_REMOTE, '/tools/lookup', '3113719P') | |
2051 self.assertEqual(0, len(a)) | |
2052 | |
15 | 2053 |
2054 def test_autorouting(self): | |
2055 knee1 = 'Knee/T1/IM-0001-0001.dcm' | |
2056 knee2 = 'Knee/T2/IM-0001-0002.dcm' | |
2057 other = 'Brainix/Flair/IM-0001-0001.dcm' | |
2058 | |
2059 # Check that this version is >= 0.8.0 | |
2060 self.assertTrue(IsDefinedInLua(_REMOTE, '_InitializeJob')) | |
2061 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
2062 | |
2063 UploadInstance(_REMOTE, knee1) | |
2064 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2065 | |
2066 DropOrthanc(_REMOTE) | |
2067 DropOrthanc(_LOCAL) | |
174 | 2068 InstallLuaScriptFromPath(_REMOTE, 'Lua/Autorouting.lua') |
15 | 2069 UploadInstance(_REMOTE, knee1) |
2070 UploadInstance(_REMOTE, knee2) | |
2071 UploadInstance(_REMOTE, other) | |
2072 WaitEmpty(_REMOTE) | |
174 | 2073 UninstallLuaCallbacks(_REMOTE) |
15 | 2074 self.assertEqual(3, len(DoGet(_LOCAL, '/instances'))) |
2075 | |
2076 DropOrthanc(_REMOTE) | |
2077 DropOrthanc(_LOCAL) | |
174 | 2078 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingConditional.lua') |
15 | 2079 UploadInstance(_REMOTE, knee1) |
2080 UploadInstance(_REMOTE, knee2) | |
2081 UploadInstance(_REMOTE, other) | |
2082 WaitEmpty(_REMOTE) | |
174 | 2083 UninstallLuaCallbacks(_REMOTE) |
15 | 2084 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
2085 | |
2086 DropOrthanc(_REMOTE) | |
2087 DropOrthanc(_LOCAL) | |
174 | 2088 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingModification.lua') |
15 | 2089 UploadInstance(_REMOTE, knee1) |
2090 WaitEmpty(_REMOTE) | |
174 | 2091 UninstallLuaCallbacks(_REMOTE) |
15 | 2092 i = DoGet(_LOCAL, '/instances') |
2093 self.assertEqual(1, len(i)) | |
2094 | |
2095 with tempfile.NamedTemporaryFile(delete = True) as f: | |
2096 f.write(DoGet(_LOCAL, '/instances/%s/file' % i[0])) | |
2097 f.flush() | |
45 | 2098 routed = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
15 | 2099 self.assertEqual('My Medical Device', re.search('"StationName">(.*?)<', routed).group(1).strip()) |
2100 self.assertEqual(None, re.search('"MilitaryRank"', routed)) | |
2101 self.assertEqual(None, re.search('"0051,0010"', routed)) # A private tag | |
17 | 2102 |
2103 | |
2104 def test_storescu_rf(self): | |
2105 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] | |
2106 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2107 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
2108 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
18 | 2109 |
2110 | |
2111 def test_anonymize_instance(self): | |
2112 def AnonymizeAndUpload(instanceId, parameters): | |
2113 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/anonymize' % instanceId, parameters, | |
2114 'application/json'), 'application/dicom')['ID'] | |
2115 | |
2116 def ModifyAndUpload(instanceId, parameters): | |
2117 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/modify' % instanceId, parameters, | |
2118 'application/json'), 'application/dicom')['ID'] | |
2119 | |
2120 a = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
2121 s1 = DoGet(_REMOTE, '/instances/%s/content/PatientName' % a) | |
2122 s2 = DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % a) # Some private tag | |
2123 s3 = DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % a) | |
2124 s4 = DoGet(_REMOTE, '/instances/%s/content/SeriesDescription' % a) | |
2125 s5 = DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2126 | |
2127 b = AnonymizeAndUpload(a, '{}') | |
2128 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2129 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2130 | |
2131 # Keep private tag (only OK since Orthanc 0.8.0) | |
2132 b = AnonymizeAndUpload(a, '{"Keep":["00e1-10c2"]}') | |
2133 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2134 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2135 | |
2136 b = AnonymizeAndUpload(a, '{"Keep":["00e1,10c2","PatientName"]}') | |
2137 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2138 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2139 | |
2140 b = AnonymizeAndUpload(a, '{"Keep":["PatientName"],"Replace":{"00e1,10c2":"Hello"}}') | |
2141 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2142 self.assertTrue(DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b).startswith('Hello')) | |
2143 | |
2144 # Examples from the Wiki | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2145 b = AnonymizeAndUpload(a, '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": true,"Force":true}') |
18 | 2146 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2147 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2148 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2149 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2150 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2151 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2152 DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2153 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2154 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2155 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Remove":["InstitutionName"],"RemovePrivateTags": true,"Force":true}') |
18 | 2156 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2157 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2158 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2159 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2160 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2161 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2162 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2163 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Force":true}') |
18 | 2164 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2165 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2166 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1,10c2' % b)) | |
2167 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2168 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2169 self.assertEqual(s5, DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2170 | |
2171 | |
2172 # Test modify non-existing | |
2173 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2174 json.dumps({ | |
2175 'PatientName' : 'Jodogne', | |
2176 'Modality' : 'CT', | |
2177 }))['ID'] | |
2178 | |
2179 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i).strip()) | |
2180 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % i)) | |
2181 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i).strip()) | |
2182 | |
2183 b = ModifyAndUpload(i, '{"Replace":{"StudyDescription":"hello","Modality":"world"}}') | |
2184 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % b).strip()) | |
2185 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % b).strip()) | |
2186 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/Modality' % b).strip()) | |
2187 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2188 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2189 def test_incoming_jpeg(self): |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2190 def storescu(image, acceptUnknownSopClassUid): |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2191 if acceptUnknownSopClassUid: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2192 tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2193 else: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2194 tmp = [ '-xs' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2195 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2196 with open(os.devnull, 'w') as FNULL: |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2197 subprocess.check_call([ FindExecutable('storescu') ] + tmp + |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2198 [ _REMOTE['Server'], str(_REMOTE['DicomPort']), |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2199 GetDatabasePath(image) ], |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2200 stderr = FNULL) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2201 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2202 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
174 | 2203 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxDisable.lua') |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2204 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
|
2205 self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True)) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2206 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
174 | 2207 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxEnable.lua') |
62
f9c4ce95756f
removal of useless information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
61
diff
changeset
|
2208 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
|
2209 storescu('Knix/Loc/IM-0001-0001.dcm', False) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2210 storescu('UnknownSopClassUid.dcm', True) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2211 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2212 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2213 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2214 def test_storescu_jpeg(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2215 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2216 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2217 knixStudy = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
64 | 2218 i = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
2219 | |
2220 # This is JPEG lossless | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2221 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header' % i)['0002,0010']['Value']) |
64 | 2222 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
|
2223 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?short' % i)['0002,0010']) |
64 | 2224 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2225 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0002.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2226 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0003.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2227 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2228 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
|
2229 b = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2230 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2231 DoPost(_REMOTE, '/modalities/orthanctest/store', [ knixStudy, a, b ]) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2232 self.assertEqual(5, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2233 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2234 self.assertEqual(3, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2235 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2236 DropOrthanc(_REMOTE) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2237 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2238 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2239 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2240 def test_pixel_data(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2241 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
|
2242 color = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2243 phenix = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2244 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2245 phenixSize = 358 * 512 * 2 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2246 colorSize = 1000 * 1000 * 3 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2247 jpegSize = 51918 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2248 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2249 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
|
2250 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
|
2251 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
|
2252 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2253 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
|
2254 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
|
2255 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2256 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
|
2257 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
|
2258 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2259 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2260 def test_decode_brainix(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2261 brainix = [ |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2262 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'], # (*) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2263 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
|
2264 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
|
2265 ] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2266 h = '6fb11b932d535c2be04beabd99793ff8' |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2267 maxValue = 426.0 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2268 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2269 truth = Image.open(GetDatabasePath('Formats/Brainix.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2270 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2271 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2272 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2273 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2274 truth2 = map(lambda x: min(255, x), truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2275 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2276 self.AssertSameImages(truth2, '/instances/%s/image-uint8' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2277 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2278 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
|
2279 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2280 self.AssertSameImages(truth2, '/instances/%s/preview' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2281 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2282 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2283 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
|
2284 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2285 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2286 def test_decode_color(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2287 imagej = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2288 color = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2289 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2290 for i in [ imagej, color ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2291 for j in [ 'image-uint8', 'image-uint16', 'image-int16' ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2292 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
|
2293 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2294 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
|
2295 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
|
2296 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2297 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
|
2298 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
|
2299 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2300 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2301 def test_decode_rf(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2302 rf = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2303 truth = Image.open(GetDatabasePath('Formats/KarstenHilbertRF.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2304 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2305 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2306 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2307 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2308 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2309 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2310 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
|
2311 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2312 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2313 def test_decode_multiframe(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2314 mf = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2315 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2316 # Test the first frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2317 truth = Image.open(GetDatabasePath('Formats/Multiframe0.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2318 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2319 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2320 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2321 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2322 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
|
2323 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2324 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
|
2325 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2326 # Test the last frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2327 truth = Image.open(GetDatabasePath('Formats/Multiframe75.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2328 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
|
2329 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2330 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2331 def test_decode_signed(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2332 signed = UploadInstance(_REMOTE, 'SignedCT.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2333 minValue = -2000 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2334 maxValue = 4042 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2335 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2336 truth = Image.open(GetDatabasePath('Formats/SignedCT.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2337 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2338 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2339 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
|
2340 self.AssertSameImages(truth2, '/instances/%s/image-uint16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2341 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2342 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
|
2343 self.AssertSameImages(truth3, '/instances/%s/image-uint8' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2344 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2345 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
|
2346 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
|
2347 self.AssertSameImages(tmp, '/instances/%s/preview' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2348 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2349 self.assertEqual('b57e6c872a3da50877c7da689b03a444', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % signed))) |
22 | 2350 |
2351 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
2352 def test_googlecode_issue_32(self): |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2353 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/default-encoding', 'nope')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2354 self.assertEqual('Windows1251', DoPut(_REMOTE, '/tools/default-encoding', 'Windows1251')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2355 self.assertEqual('Windows1251', DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2356 |
22 | 2357 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
2358 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) | |
2359 self.assertEqual(u'Рентгенография', tags['SeriesDescription']) | |
2360 self.assertEqual(u'Таз', tags['BodyPartExamined']) | |
2361 self.assertEqual(u'Прямая', tags['ViewPosition']) | |
2362 | |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2363 # 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
|
2364 self.assertEqual('Latin1', DoPut(_REMOTE, '/tools/default-encoding', 'Latin1')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2365 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2366 DoDelete(_REMOTE, '/instances/%s' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2367 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2368 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2369 self.assertNotEqual(u'Рентгенография', tags['SeriesDescription']) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2370 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2371 |
22 | 2372 def test_encodings(self): |
23 | 2373 # Latin-1 (ISO_IR 100) |
22 | 2374 brainix = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2375 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % brainix) | |
2376 self.assertEqual(u'IRM cérébrale, neuro-crâne', tags['StudyDescription']) | |
23 | 2377 |
2378 # Latin-2 (ISO_IR 101) | |
2379 a = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] | |
2380 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % a) | |
2381 # dcm2xml MarekLatin2.dcm | iconv -f latin2 -t utf-8 | xmllint --format - | |
2382 self.assertEqual('Imię i Nazwisko osoby opisującej', | |
2383 i['ContentSequence'][4]['ConceptNameCodeSequence'][0]['CodeMeaning'].encode('utf-8')) | |
2384 | |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2385 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2386 def test_storescu_custom_aet(self): |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2387 # 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
|
2388 # 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
|
2389 # in the REST API)." |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2390 # 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
|
2391 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2392 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2393 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2394 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2395 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2396 c = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0003.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2397 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2398 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2399 'LocalAet' : 'YOP', |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2400 'Resources' : [ a['ID'], b['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2401 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2402 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2403 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2404 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
|
2405 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2406 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2407 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2408 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2409 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2410 'Resources' : [ c['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2411 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2412 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2413 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2414 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
|
2415 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2416 DropOrthanc(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2417 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2418 |
174 | 2419 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingChangeAet.lua') |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2420 DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2421 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2422 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2423 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2424 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2425 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2426 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
|
2427 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2428 DoPost(_REMOTE, '/tools/execute-script', 'aet = nill', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2429 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2430 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2431 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2432 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
|
2433 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2434 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
|
2435 # 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
|
2436 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
|
2437 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
|
2438 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
|
2439 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
|
2440 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
|
2441 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2442 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
|
2443 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
|
2444 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
|
2445 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
|
2446 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2447 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
|
2448 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
|
2449 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2450 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
|
2451 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
|
2452 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
|
2453 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
|
2454 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
|
2455 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
|
2456 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
|
2457 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
|
2458 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
|
2459 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
|
2460 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
|
2461 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
|
2462 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
|
2463 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
|
2464 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
|
2465 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2466 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
|
2467 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
|
2468 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
|
2469 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
|
2470 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
|
2471 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
|
2472 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
|
2473 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2474 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
|
2475 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
|
2476 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
|
2477 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2478 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
|
2479 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
|
2480 self.assertTrue(instance in s) |
36 | 2481 |
2482 | |
2483 def test_create_pdf(self): | |
2484 # Upload 4 instances | |
2485 brainixInstance = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
2486 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2487 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2488 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2489 | |
2490 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
2491 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
2492 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
2493 | |
2494 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: | |
2495 pdf = f.read() | |
2496 | |
2497 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2498 json.dumps({ | |
2499 'Tags' : { | |
2500 'PatientName' : 'Jodogne', | |
2501 'Modality' : 'CT', | |
2502 }, | |
2503 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2504 })) | |
2505 | |
2506 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2507 self.assertEqual('OT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
2508 | |
2509 b = DoGet(_REMOTE, '/instances/%s/content/0042-0011' % i['ID']) | |
2510 self.assertEqual(len(b), len(pdf) + 1) | |
2511 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf + '\0')) | |
2512 | |
2513 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/tools/create-dicom', | |
2514 json.dumps({ | |
2515 'Parent' : brainixPatient, | |
2516 'Tags' : { | |
2517 'PatientName' : 'Jodogne', | |
2518 } | |
2519 }))) | |
2520 | |
2521 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2522 json.dumps({ | |
2523 'Parent' : brainixPatient, | |
2524 'Tags' : { 'StudyDescription' : 'PDF^Patient' }, | |
2525 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2526 })) | |
2527 | |
2528 self.assertEqual(brainixPatient, DoGet(_REMOTE, '/instances/%s/patient' % i['ID'])['ID']) | |
2529 | |
2530 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2531 json.dumps({ | |
2532 'Parent' : brainixStudy, | |
2533 'Tags' : { 'SeriesDescription' : 'PDF^Study' }, | |
2534 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2535 })) | |
2536 | |
2537 self.assertEqual(brainixStudy, DoGet(_REMOTE, '/instances/%s/study' % i['ID'])['ID']) | |
2538 | |
2539 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2540 json.dumps({ | |
2541 'Parent' : brainixEpi, | |
37 | 2542 'Tags' : { 'SpecificCharacterSet' : 'ISO_IR 13' }, |
36 | 2543 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
2544 })) | |
2545 | |
2546 self.assertEqual(brainixEpi, DoGet(_REMOTE, '/instances/%s/series' % i['ID'])['ID']) | |
2547 | |
2548 b = DoGet(_REMOTE, '/instances/%s/pdf' % i['ID']) | |
2549 self.assertEqual(len(b), len(pdf)) | |
2550 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf)) | |
2551 | |
2552 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/pdf' % brainixInstance)) | |
38 | 2553 |
2554 | |
2555 def test_create_series(self): | |
2556 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2557 json.dumps({ | |
2558 'Tags' : { | |
40 | 2559 'SpecificCharacterSet' : 'ISO_IR 100', |
2560 'PatientName' : 'Sébastien Jodogne', | |
38 | 2561 'Modality' : 'CT', |
2562 }, | |
2563 'Content' : [ | |
40 | 2564 { |
2565 'Content': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', # red dot in RGBA | |
2566 'Tags' : { 'ImageComments' : 'Tutu' } | |
2567 }, | |
38 | 2568 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAoUlEQVQ4jZ2SWw3EIBREjwUsYAELa2EtoAULFUCyXAtroRZqoRbox254BdLC/DZnZjoXWJFgCDg8egW2CBEhEnDzyRk+Ecxz2KP/0AL8S99T+jQccAVs22qKwAuPuq0uyNg9cPLh3am+pe/dkHLZtqJHj6vXJrZ7nvzvxxgemXgUwnGfXqpee09mUwp8m022OYP6bLF7mVuVe0y/umxinsAXRd9z0k1ubWsAAAAASUVORK5CYII=', |
2569 ] | |
2570 })) | |
2571 | |
2572 s = DoGet(_REMOTE, i['Path']) | |
2573 self.assertEqual('Series', s['Type']) | |
2574 self.assertEqual(s['ID'], i['ID']) | |
2575 self.assertEqual(2, len(s['Instances'])) | |
39 | 2576 self.assertEqual(2, s['ExpectedNumberOfInstances']) |
2577 self.assertEqual('Complete', s['Status']) | |
40 | 2578 |
2579 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][0]) | |
2580 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][1]) | |
2581 self.assertTrue('ImageComments' in a or 'ImageComments' in b) | |
2582 if 'ImageComments' in a: | |
2583 self.assertEqual('Tutu', a['ImageComments']) | |
2584 else: | |
2585 self.assertEqual('Tutu', b['ImageComments']) | |
2586 | |
2587 patient = DoGet(_REMOTE, '/instances/%s/patient' % s['Instances'][0]) | |
2588 self.assertEqual(patient['MainDicomTags']['PatientName'].encode('utf-8'), | |
2589 'Sébastien Jodogne') | |
47 | 2590 |
2591 | |
2592 def test_create_binary(self): | |
2593 binary = ''.join(map(chr, range(256))) | |
2594 encoded = 'data:application/octet-stream;base64,' + base64.b64encode(binary) | |
2595 tags = { | |
2596 'PatientName' : 'Jodogne', | |
2597 '8899-8899' : encoded | |
2598 } | |
2599 | |
2600 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2601 json.dumps({ | |
2602 'Tags' : tags | |
2603 })) | |
2604 | |
2605 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2606 self.assertEqual(binary, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID']).strip()) | |
2607 | |
2608 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2609 json.dumps({ | |
2610 'InterpretBinaryTags' : False, | |
2611 'Tags' : tags | |
2612 })) | |
2613 | |
2614 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2615 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
|
2616 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2617 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2618 def test_patient_ids_collision(self): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2619 # 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
|
2620 # same PatientID |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2621 for i in range(3): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2622 UploadInstance(_REMOTE, 'PatientIdsCollision/Image%d.dcm' % (i + 1)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2623 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2624 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2625 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2626 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2627 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
|
2628 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2629 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2630 'CaseSensitive' : True, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2631 'Query' : { 'PatientName' : 'FOO\\HELLO' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2632 self.assertEqual(2, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2633 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2634 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2635 'CaseSensitive' : False, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2636 'Query' : { 'PatientName' : 'Foo' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2637 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2638 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
|
2639 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
|
2640 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
|
2641 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2642 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2643 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2644 self.assertEqual(3, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2645 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
|
2646 self.assertTrue('FOO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2647 self.assertTrue('HELLO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2648 self.assertTrue('WORLD^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2649 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2650 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
|
2651 self.assertEqual(1, len(set(d))) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2652 self.assertEqual('COMMON', d[0]) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2653 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2654 for i in a: |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2655 d = DoGet(_REMOTE, '/studies/%s' % i) ['MainDicomTags']['StudyDescription'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2656 p = DoGet(_REMOTE, '/studies/%s' % i) ['PatientMainDicomTags']['PatientName'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2657 self.assertEqual('%s^SERIES' % p, d) |
49
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2658 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2659 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2660 def test_bitbucket_issue_4(self): |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2661 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2662 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2663 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2664 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2665 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2666 UploadInstance(_REMOTE, 'Formats/Rle.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2667 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2668 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2669 self.assertEqual(6, len(DoGet(_REMOTE, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2670 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2671 p = DoGet(_REMOTE, '/patients') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2672 self.assertEqual(2, len(p)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2673 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
|
2674 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
|
2675 self.assertEqual(3, len(i1)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2676 self.assertEqual(3, len(i2)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2677 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2678 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
|
2679 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2680 self.assertEqual(6, len(DoGet(_LOCAL, '/instances'))) |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2681 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2682 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2683 def test_create_sequence(self): |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2684 i = DoPost(_REMOTE, '/tools/create-dicom', |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2685 json.dumps({ |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2686 'Tags' : { |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2687 'SpecificCharacterSet': 'ISO_IR 100', # Encode using Latin1 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2688 'PatientName': 'Jodogne^', |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2689 'ReferencedStudySequence': GenerateTestSequence(), |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2690 } |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2691 }))['ID'] |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2692 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2693 self.assertEqual('Jodogne^', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2694 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
|
2695 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
|
2696 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
|
2697 self.assertEqual(u'Sébastien^'.encode('latin-1'), |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2698 DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/1/StudyDescription' % i)) |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2699 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2700 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2701 def test_modify_sequence(self): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2702 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2703 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
|
2704 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2705 j = DoPost(_REMOTE, '/instances/%s/modify' % i, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2706 json.dumps({ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2707 "Replace" : { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2708 "PatientName" : "hello", |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2709 'ReferencedStudySequence': GenerateTestSequence(), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2710 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2711 }), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2712 'application/json') |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2713 j = DoPost(_REMOTE, '/instances', j, 'application/dicom')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2714 DoDelete(_REMOTE, '/instances/%s' % i) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2715 |
52 | 2716 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % j))) |
2717 | |
2718 | |
2719 def test_compression(self): | |
2720 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
2721 | |
2722 data = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % i)[1] | |
2723 | |
2724 # "StorageCompression" is enabled in the Orthanc to be tested, | |
2725 # uncompress the data before running the test | |
2726 if DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i) != 0: | |
2727 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2728 | |
2729 cs = DoGet(_REMOTE, '/statistics')['TotalDiskSize'] | |
2730 us = DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'] | |
2731 size = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i) | |
2732 md5 = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i) | |
2733 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2734 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2735 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2736 | |
2737 ops = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % i) | |
2738 self.assertTrue('compress' in ops) | |
2739 self.assertTrue('uncompress' in ops) | |
2740 self.assertTrue('is-compressed' in ops) | |
2741 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2742 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2743 | |
2744 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/compress' % i) | |
2745 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2746 self.assertEqual(1, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2747 self.assertLess(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2748 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
2749 self.assertGreater(len(data), len(DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1])) | |
2750 self.assertGreater(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2751 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2752 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2753 self.assertNotEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2754 | |
2755 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2756 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2757 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2758 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2759 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2760 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2761 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2762 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2763 self.assertEqual(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2764 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
53 | 2765 |
2766 | |
2767 def test_ordered_slices(self): | |
2768 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
2769 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2770 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2771 self.assertEqual('Sequence', o['Type']) | |
2772 self.assertEqual(1, len(o['Dicom'])) | |
2773 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/file', o['Dicom'][0]) | |
2774 self.assertEqual(76, len(o['Slices'])) | |
2775 for j in range(76): | |
2776 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/frames/%d' % j, o['Slices'][j]) | |
2777 | |
68 | 2778 self.assertEqual(1, len(o['SlicesShort'])) |
2779 self.assertEqual('9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02', o['SlicesShort'][0][0]) | |
2780 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2781 self.assertEqual(76, o['SlicesShort'][0][2]) | |
2782 | |
53 | 2783 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2784 j = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm')['ID'] | |
2785 k = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm')['ID'] | |
2786 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2787 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2788 | |
2789 self.assertEqual('Volume', o['Type']) | |
2790 self.assertEqual(3, len(o['Dicom'])) | |
2791 self.assertEqual(3, len(o['Slices'])) | |
2792 self.assertEqual('/instances/%s/file' % i, o['Dicom'][2]) | |
2793 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2794 self.assertEqual('/instances/%s/file' % k, o['Dicom'][0]) | |
2795 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][2]) | |
2796 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
2797 self.assertEqual('/instances/%s/frames/0' % k, o['Slices'][0]) | |
2798 | |
68 | 2799 self.assertEqual(3, len(o['SlicesShort'])) |
2800 self.assertEqual(k, o['SlicesShort'][0][0]) | |
2801 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2802 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2803 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2804 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2805 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2806 self.assertEqual(i, o['SlicesShort'][2][0]) | |
2807 self.assertEqual(0, o['SlicesShort'][2][1]) | |
2808 self.assertEqual(1, o['SlicesShort'][2][2]) | |
2809 | |
53 | 2810 i = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] |
2811 j = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0002.dcm')['ID'] | |
2812 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2813 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2814 | |
2815 self.assertEqual('Sequence', o['Type']) | |
2816 self.assertEqual(2, len(o['Dicom'])) | |
2817 self.assertEqual(2, len(o['Slices'])) | |
2818 self.assertEqual('/instances/%s/file' % i, o['Dicom'][0]) | |
2819 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2820 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][0]) | |
2821 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
|
2822 |
68 | 2823 self.assertEqual(2, len(o['SlicesShort'])) |
2824 self.assertEqual(i, o['SlicesShort'][0][0]) | |
2825 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2826 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2827 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2828 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2829 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2830 | |
2831 | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2832 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2833 def test_incoming_movescu_accession(self): |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2834 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2835 |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2836 # No matching patient, so no job is created |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2837 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2838 CallMoveScu([ '--study', '-k', '0008,0052=STUDY', '-k', 'AccessionNumber=nope' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2839 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2840 CallMoveScu([ '--study', '-k', '0008,0052=PATIENT', '-k', 'AccessionNumber=A10003245599' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2841 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2842 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2843 # 1 Matching patient, track the job |
138 | 2844 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
2845 '--study', | |
2846 '-k', '0008,0052=STUDY', | |
2847 '-k', 'AccessionNumber=A10003245599' | |
2848 ]))) | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2849 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2850 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2851 |
55 | 2852 |
2853 def test_dicom_to_json(self): | |
2854 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
|
2855 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
|
2856 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2857 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
|
2858 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
|
2859 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
123 | 2860 # Tags for compatibility with DCMTK 3.6.0 |
2861 'RETIRED_OtherPatientIDs', | |
2862 'OtherPatientIDs', | |
2863 'ACR_NEMA_2C_VariablePixelDataGroupLength', | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2864 ])) |
55 | 2865 |
2866 t = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
2867 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
|
2868 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
|
2869 ])) |
55 | 2870 |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2871 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
|
2872 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
|
2873 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
|
2874 ])) |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2875 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2876 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
|
2877 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
|
2878 a = json.loads(f.read()) |
65
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2879 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
|
2880 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
|
2881 self.assertEqual(aa, tt) |
57 | 2882 |
2883 | |
2884 def test_batch_archive(self): | |
2885 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2886 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') | |
2887 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2888 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0002.dcm') | |
2889 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2890 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') | |
2891 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
2892 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
2893 | |
2894 s = DoPost(_REMOTE, '/tools/create-archive', [ ]) | |
2895 z = zipfile.ZipFile(StringIO(s), "r") | |
2896 self.assertEqual(0, len(z.namelist())) | |
2897 | |
2898 # One patient | |
2899 s = DoPost(_REMOTE, '/tools/create-archive', [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ]) | |
2900 z = zipfile.ZipFile(StringIO(s), "r") | |
2901 self.assertEqual(4, len(z.namelist())) | |
2902 | |
2903 # One patient + twice its study + one series from other patient | |
2904 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2905 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2906 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918', | |
2907 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
2908 ]) | |
2909 z = zipfile.ZipFile(StringIO(s), "r") | |
2910 self.assertEqual(6, len(z.namelist())) | |
2911 | |
2912 # One patient + one series + one instance | |
2913 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2914 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2915 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0', | |
2916 '1d429ccb-bdcc78a1-7d129d6a-ba4966ed-fe4dbd87' | |
2917 ]) | |
2918 z = zipfile.ZipFile(StringIO(s), "r") | |
2919 self.assertEqual(7, len(z.namelist())) | |
59
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2920 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2921 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2922 def test_decode_brainix_as_jpeg(self): |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2923 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
|
2924 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2925 j = GetImage(_REMOTE, '/instances/%s/preview' % i) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2926 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2927 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2928 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2929 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2930 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
|
2931 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2932 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2933 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
|
2934 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2935 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2936 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
|
2937 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2938 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2939 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
|
2940 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2941 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2942 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2943 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2944 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
|
2945 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
|
2946 self.assertLess(a, b) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2947 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2948 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
|
2949 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2950 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2951 # 16bit encoding is not supported with JPEG |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2952 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
|
2953 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
|
2954 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2955 # No matching content type |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2956 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
|
2957 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2958 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2959 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2960 def test_media_encodings(self): |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2961 ascii = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2962 latin1 = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2963 latin2 = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2964 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2965 tmp = DoPost(_REMOTE, '/tools/create-media', [ascii,latin1,latin2]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2966 z = zipfile.ZipFile(StringIO(tmp), "r") |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2967 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2968 self.assertEqual(4, len(z.namelist())) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2969 self.assertTrue('IMAGES/IM0' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2970 self.assertTrue('IMAGES/IM1' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2971 self.assertTrue('IMAGES/IM2' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2972 self.assertTrue('DICOMDIR' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2973 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2974 try: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2975 os.remove('/tmp/DICOMDIR') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2976 except: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2977 # The file does not exist |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2978 pass |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2979 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2980 z.extract('DICOMDIR', '/tmp') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2981 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2982 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2983 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2984 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2985 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2986 self.assertEqual(1, len(a)) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2987 self.assertEqual('', a[0]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2988 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2989 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2990 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
|
2991 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
|
2992 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
|
2993 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2994 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
|
2995 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2996 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2997 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
|
2998 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
|
2999 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
|
3000 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
|
3001 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3002 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
|
3003 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
|
3004 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
|
3005 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
|
3006 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3007 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
|
3008 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
|
3009 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
|
3010 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
|
3011 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3012 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
|
3013 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
|
3014 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
|
3015 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
|
3016 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3017 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
|
3018 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
|
3019 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
|
3020 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
|
3021 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3022 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
|
3023 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
|
3024 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
|
3025 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
|
3026 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3027 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
|
3028 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
|
3029 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
|
3030 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
|
3031 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
|
3032 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3033 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
|
3034 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
|
3035 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
|
3036 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
|
3037 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
|
3038 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
|
3039 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3040 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
|
3041 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
|
3042 self.assertEqual(1, len(s)) |
176
48cc188ffb09
strip trailing 0 char that appears with some findscu versions
am@osimis.io
parents:
175
diff
changeset
|
3043 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
|
3044 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
|
3045 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
|
3046 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3047 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3048 def test_decode_transfer_syntax(self): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3049 def Check(t, md5): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3050 i = UploadInstance(_REMOTE, 'TransferSyntaxes/%s.dcm' % t)['ID'] |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3051 |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3052 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
|
3053 transferSyntax = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3054 self.assertEqual(t, transferSyntax) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3055 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3056 if md5 == None: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3057 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
|
3058 else: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3059 m = ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3060 self.assertEqual(m, md5) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3061 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3062 Check('1.2.840.10008.1.2.1', 'fae08d5415c4c0cd2cdbae4522408631') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3063 Check('1.2.840.10008.1.2.2', 'f3d9784768b8feb54d6a50b6d5c37682') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3064 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
|
3065 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
|
3066 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
|
3067 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
|
3068 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
|
3069 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
|
3070 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
|
3071 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3072 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
|
3073 Check('1.2.840.10008.1.2.4.91', None) # JPEG-2000 image, not supported |
79 | 3074 |
3075 | |
3076 def test_raw_frame(self): | |
3077 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
3078 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3079 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3080 self.assertEqual(512 * 512 * 2, len(a)) | |
3081 self.assertEqual(512 * 512 * 2, len(DoGet(_REMOTE, '/instances/%s/frames/23/raw' % s))) | |
3082 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/raw' % s)) | |
3083 self.assertEqual('1914287dc4d958eca21fdaacfb3482fa', ComputeMD5(a)) | |
3084 | |
3085 s = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
3086 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3087 self.assertEqual(186274, len(DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s))) | |
3088 self.assertEqual(189424, len(DoGet(_REMOTE, '/instances/%s/frames/75/raw' % s))) | |
3089 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/raw' % s)) | |
3090 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3091 self.assertEqual("L", im.mode) | |
3092 self.assertEqual(512, im.size[0]) | |
3093 self.assertEqual(512, im.size[1]) | |
3094 | |
3095 # Test an image with 2 JPEG frames spread over multiple fragments | |
3096 s = UploadInstance(_REMOTE, 'LenaTwiceWithFragments.dcm')['ID'] | |
3097 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3098 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3099 b = DoGet(_REMOTE, '/instances/%s/frames/1/raw' % s) | |
3100 self.assertEqual(69214, len(a)) | |
3101 self.assertEqual(ComputeMD5(a), ComputeMD5(b)) | |
3102 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/2/raw' % s)) | |
3103 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3104 self.assertEqual("RGB", im.mode) | |
3105 self.assertEqual(512, im.size[0]) | |
3106 self.assertEqual(512, im.size[1]) | |
3107 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % s) | |
3108 self.assertEqual("RGB", im.mode) | |
3109 self.assertEqual(512, im.size[0]) | |
3110 self.assertEqual(512, im.size[1]) | |
81 | 3111 |
3112 | |
3113 | |
3114 def test_rest_movescu(self): | |
3115 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3116 | |
3117 # Upload 4 instances | |
3118 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
3119 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
3120 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
3121 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
3122 | |
3123 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3124 for p in DoGet(_REMOTE, '/patients'): | |
3125 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
3126 DoDelete(_REMOTE, '/patients/%s' % p) | |
3127 | |
3128 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3129 | |
3130 # Upload instance Brainix/Flair/IM-0001-0001.dcm | |
3131 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Instance', | |
3132 'Resources' : [ | |
3133 { | |
3134 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3135 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3136 'SOPInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549', | |
3137 } | |
3138 ]}) | |
3139 | |
3140 # Upload series Brainix/Flair/* | |
3141 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3142 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3143 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3144 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
3145 | |
3146 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3147 'Resources' : [ | |
3148 { | |
3149 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3150 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3151 } | |
3152 ]}) | |
3153 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3154 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3155 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3156 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
3157 | |
3158 # Upload series Brainix/Epi/* | |
3159 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3160 'Resources' : [ | |
3161 { | |
3162 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3163 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314125550', | |
3164 } | |
3165 ]}) | |
3166 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3167 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3168 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
3169 self.assertEqual(3, len(DoGet(_REMOTE, '/instances'))) | |
3170 | |
3171 # Upload study Knee/* | |
3172 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3173 'Resources' : [ | |
3174 { | |
3175 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3176 } | |
3177 ]}) | |
3178 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3179 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3180 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3181 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3182 | |
3183 # Reset | |
3184 for p in DoGet(_REMOTE, '/patients'): | |
3185 DoDelete(_REMOTE, '/patients/%s' % p) | |
3186 | |
3187 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3188 | |
3189 | |
3190 # Upload all at once | |
3191 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3192 'Resources' : [ | |
3193 { | |
3194 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3195 }, | |
3196 { | |
3197 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3198 } | |
3199 ]}) | |
3200 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3201 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3202 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3203 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3204 | |
86
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3205 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3206 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3207 def test_reconstruct_json(self): |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3208 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3209 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3210 instance = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3211 first = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3212 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3213 self.assertEqual('TWINOW', first['0008,1010']['Value']) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3214 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3215 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3216 # Cannot delete the "DICOM" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3217 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
|
3218 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3219 # Can delete the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3220 r = DoDelete(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3221 self.assertTrue(type(r) is dict and len(r) == 0) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3222 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3223 # Only the "DICOM" attachment subsists |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3224 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3225 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3226 # Cannot manually reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3227 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
|
3228 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3229 # Transparently reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3230 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
|
3231 second = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3232 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3233 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3234 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
|
3235 self.assertEqual(str(first), str(second)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3236 self.assertEqual(str(first), str(third)) |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3237 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3238 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3239 def test_reconstruct_json2(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3240 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3241 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3242 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
|
3243 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
|
3244 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3245 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
|
3246 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
|
3247 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3248 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
|
3249 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
|
3250 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3251 DoPost(_REMOTE, '/tools/invalidate-tags', '', 'text/plain') |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3252 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3253 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
|
3254 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
|
3255 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3256 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
|
3257 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
|
3258 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3259 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
|
3260 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
|
3261 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3262 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3263 def test_private_tags(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3264 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3265 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
|
3266 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
|
3267 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
|
3268 |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3269 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3270 def test_findscu_encoding(self): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3271 # Check out ../Database/Encodings/Generate.sh |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3272 TEST = u'Test-éüäöòДΘĝדصķћ๛ネİ' |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3273 ENCODINGS = { |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3274 'Arabic' : [ 'ISO_IR 127' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3275 'Ascii' : [ 'ISO_IR 6' ], # More accurately, ISO 646 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3276 'Cyrillic' : [ 'ISO_IR 144' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3277 'Greek' : [ 'ISO_IR 126' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3278 'Hebrew' : [ 'ISO_IR 138' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3279 'Japanese' : [ 'ISO_IR 13', 'shift-jis' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3280 'Latin1' : [ 'ISO_IR 100' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3281 'Latin2' : [ 'ISO_IR 101' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3282 'Latin3' : [ 'ISO_IR 109' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3283 'Latin4' : [ 'ISO_IR 110' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3284 'Latin5' : [ 'ISO_IR 148' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3285 'Thai' : [ 'ISO_IR 166', 'tis-620' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3286 'Utf8' : [ 'ISO_IR 192' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3287 } |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3288 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3289 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3290 if len(ENCODINGS[name]) == 1: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3291 ENCODINGS[name].append(name.lower()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3292 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3293 UploadInstance(_REMOTE, 'Encodings/Lena-utf8.dcm') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3294 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3295 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3296 self.assertEqual(name, DoPut(_REMOTE, '/tools/default-encoding', name)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3297 self.assertEqual(name, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3298 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3299 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3300 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3301 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3302 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3303 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3304 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3305 self.assertEqual(ENCODINGS[name][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3306 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3307 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3308 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3309 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3310 expected = TEST.encode(ENCODINGS[name][1], 'ignore') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3311 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3312 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3313 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3314 #for master in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3315 for master in [ 'Latin1', 'Utf8', 'Cyrillic' ]: # Shortcut to speedup tests |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3316 self.assertEqual(master, DoPut(_REMOTE, '/tools/default-encoding', master)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3317 self.assertEqual(master, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3318 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3319 for name in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3320 DropOrthanc(_REMOTE) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3321 UploadInstance(_REMOTE, 'Encodings/Lena-%s.dcm' % ENCODINGS[name][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3322 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3323 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3324 '-k', 'PatientID', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3325 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3326 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3327 i = i.decode(ENCODINGS[master][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3328 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3329 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3330 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3331 self.assertEqual(ENCODINGS[master][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3332 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3333 patientId = re.findall('\(0010,0020\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3334 self.assertEqual(1, len(patientId)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3335 self.assertEqual(ENCODINGS[name][1], patientId[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3336 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3337 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3338 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3339 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3340 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3341 expected = TEST.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3342 tmp = ENCODINGS[master][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3343 expected = expected.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3344 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3345 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3346 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3347 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3348 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3349 'Level' : 'Study', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3350 'Query' : { }}) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3351 self.assertEqual(1, len(a)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3352 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3353 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3354 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
|
3355 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3356 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3357 def test_reconstruct(self): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3358 def CompareMainDicomTag(expected, instance, level, tag): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3359 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
|
3360 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3361 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3362 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3363 studies = DoGet(_REMOTE, '/studies/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3364 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3365 self.assertEqual(1, len(studies)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3366 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3367 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3368 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3369 modified = DoPost(_REMOTE, '/studies/%s/modify' % studies[0], { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3370 "Replace" : { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3371 "StudyDescription" : "hello", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3372 "SeriesDescription" : "world", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3373 "SOPClassUID" : "test", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3374 "SOPInstanceUID" : "myid", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3375 }, |
119 | 3376 "Keep" : [ "StudyInstanceUID", "SeriesInstanceUID" ], |
3377 "Force" : True | |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3378 }) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3379 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3380 instances = DoGet(_REMOTE, '/instances/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3381 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3382 self.assertEqual(1, len(DoGet(_REMOTE, '/studies/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3383 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3384 self.assertEqual(2, len(instances)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3385 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3386 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
|
3387 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3388 CompareMainDicomTag('Knee (R)', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3389 CompareMainDicomTag('AX. FSE PD', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3390 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
|
3391 CompareMainDicomTag('myid', b, '', 'SOPInstanceUID') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3392 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
|
3393 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
|
3394 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3395 DoPost(_REMOTE, '/instances/%s/reconstruct' % b, {}) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3396 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3397 CompareMainDicomTag('hello', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3398 CompareMainDicomTag('world', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3399 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') |
102 | 3400 |
104 | 3401 def test_httpClient_lua(self): |
3402 with open(GetDatabasePath('Lua/HttpClient.lua'), 'r') as f: | |
102 | 3403 result = DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua') |
3404 | |
3405 self.assertIn('OK', result) | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3406 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3407 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3408 def test_bitbucket_issue_44(self): |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3409 # 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
|
3410 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3411 UploadInstance(_REMOTE, 'Issue44/Monochrome2.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3412 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3413 # dcmcjpeg +ua +eb Monochrome1.dcm Monochrome1-Jpeg.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3414 UploadInstance(_REMOTE, 'Issue44/Monochrome1-Jpeg.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3415 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3416 # dcmcjpeg +ua Monochrome1.dcm Monochrome1-JpegLS.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3417 UploadInstance(_REMOTE, 'Issue44/Monochrome1-JpegLS.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3418 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3419 monochrome1 = 'bcdd600a-a6a9c522-5f0a6e84-8657c9f3-b76e59b7' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3420 monochrome1_jpeg = '9df82121-208a2da8-0038674a-3d7a773b-b7008cd2' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3421 monochrome1_jpegls = '0486d1a2-9165573f-b1976b20-e927b016-6b8d67ab' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3422 monochrome2 = 'f00947b7-f61f7164-c93414d1-c6fbda6a-9e92ed20' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3423 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3424 for i in [ monochrome1, monochrome1_jpeg, monochrome1_jpegls ]: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3425 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3426 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3427 self.assertEqual(2010, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3428 self.assertEqual(2446, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3429 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3430 # 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
|
3431 # white (255), should be rendered as black (0) => invert |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3432 if i == monochrome1_jpeg: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3433 # Add some tolerance because of JPEG destructive compression |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3434 self.assertGreater(10, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3435 else: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3436 self.assertEqual(0, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3437 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3438 im = GetImage(_REMOTE, '/instances/%s/preview' % monochrome2) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3439 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3440 self.assertEqual(1572, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3441 self.assertEqual(2010, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3442 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3443 # 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
|
3444 # white (255), should be rendered as white (255) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3445 self.assertEqual(255, im.getpixel((0,0))) |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3446 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3447 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3448 def test_bitbucket_issue_42(self): |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3449 # https://bitbucket.org/sjodogne/orthanc/issues/42/fails-to-modify-a-dicom-video-file |
123 | 3450 # 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
|
3451 UploadInstance(_REMOTE, 'Issue42.dcm')['ID'] |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3452 modified = DoPost(_REMOTE, |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3453 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify', |
119 | 3454 '{"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
|
3455 'application/json') |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3456 self.assertTrue('PatientID' in modified) |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3457 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3458 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3459 def test_rest_find_limit(self): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3460 # 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
|
3461 # 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
|
3462 |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3463 # Upload 6 instances |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3464 brainix = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3465 knee = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3466 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3467 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
|
3468 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
|
3469 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
|
3470 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3471 # Check using BRAINIX |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3472 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3473 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3474 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3475 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3476 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3477 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3478 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3479 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3480 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3481 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3482 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3483 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3484 'Since' : 2, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3485 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3486 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3487 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3488 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3489 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3490 'Limit' : 3 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3491 self.assertEqual(3, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3492 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3493 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3494 for i in range(4): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3495 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3496 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3497 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3498 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3499 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3500 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3501 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3502 # 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
|
3503 self.assertEqual(0, len(set(b) ^ set(brainix))) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3504 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3505 # Check using KNEE |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3506 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3507 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3508 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3509 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3510 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3511 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3512 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3513 'Limit' : 2 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3514 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3515 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3516 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3517 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3518 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3519 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3520 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3521 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3522 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3523 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3524 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3525 self.assertEqual(0, len(set(b) ^ set(knee))) |
115
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3526 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3527 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3528 def test_bitbucket_issue_46(self): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3529 # "PHI remaining after anonymization" |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3530 # https://bitbucket.org/sjodogne/orthanc/issues/46 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3531 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3532 def GetAnonymizedTags(study, version): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3533 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3534 { 'DicomVersion' : version }, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3535 'application/json') ['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3536 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3537 self.assertEqual(1, len(a)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3538 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3539 instance = a[0]['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3540 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3541 return (instance, DoGet(_REMOTE, '/instances/%s/tags' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3542 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3543 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3544 origStudy = '6068a14b-d4df27af-9ec22145-538772d8-74f228ff' |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3545 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3546 # 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
|
3547 # (Patient's Mother's Birth Name) tags |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3548 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3549 '{"Replace":{"0010,1060":"OSIMIS","0032,1033":"MOTHER"}}', |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3550 'application/json')['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3551 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3552 # 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
|
3553 # 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
|
3554 (instance, tags) = GetAnonymizedTags(newStudy, "2008") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3555 self.assertTrue('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3556 self.assertTrue('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3557 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3558 # 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
|
3559 # 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
|
3560 (instance, tags) = GetAnonymizedTags(newStudy, "2017c") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3561 self.assertFalse('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3562 self.assertFalse('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3563 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3564 t = {} |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3565 for (key, value) in tags.iteritems(): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3566 t[value['Name']] = value['Value'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3567 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3568 self.assertEqual('', t['StudyDate']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3569 self.assertEqual('', t['StudyTime']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3570 self.assertEqual('', t['PatientSex']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3571 self.assertFalse('SeriesDate' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3572 self.assertFalse('SeriesTime' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3573 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3574 with tempfile.NamedTemporaryFile(delete = True) as f: |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3575 # 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
|
3576 f.write(DoGet(_REMOTE, '/instances/%s/file' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3577 f.flush() |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3578 subprocess.check_output([ FindExecutable('dciodvfy'), f.name ], |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3579 stderr = subprocess.STDOUT).split('\n') |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3580 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3581 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3582 def test_bitbucket_issue_55(self): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3583 def Run(modify, query): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3584 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3585 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3586 operation = 'modify' if modify else 'anonymize' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3587 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3588 self.assertRaises(Exception, lambda: DoPost( |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3589 _REMOTE, '/studies/%s/%s' % (study, operation), query)) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3590 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3591 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3592 query["Force"] = True |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3593 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
|
3594 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3595 DoDelete(_REMOTE, a) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3596 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3597 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3598 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3599 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3600 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3601 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3602 Run(True, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3603 Run(True, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3604 Run(True, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3605 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3606 Run(False, { "Keep" : [ "StudyInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3607 Run(False, { "Keep" : [ "SeriesInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3608 Run(False, { "Keep" : [ "SOPInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3609 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3610 Run(False, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3611 Run(False, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3612 Run(False, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3613 |
120
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3614 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3615 def test_bitbucket_issue_56(self): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3616 # Case-insensitive matching over accents. This test assumes |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3617 # that the "CaseSensitivePN" configuration option of Orthanc |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3618 # is set to "false" (default value). |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3619 # https://bitbucket.org/sjodogne/orthanc/issues/56 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3620 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3621 def Check(name, expected, expectedSensitive): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3622 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
|
3623 '-k', '0008,0052=PATIENT', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3624 '-k', 'PatientName=%s' % name ]) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3625 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', a) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3626 self.assertEqual(expected, len(patientNames)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3627 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3628 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3629 'CaseSensitive' : False, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3630 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3631 self.assertEqual(expected, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3632 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3633 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3634 'CaseSensitive' : True, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3635 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3636 self.assertEqual(expectedSensitive, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3637 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3638 UploadInstance(_REMOTE, 'Encodings/Lena-latin1.dcm') |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3639 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3640 # WildcardConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3641 Check('TeSt*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3642 Check('TeSt-a*', 0, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3643 Check('TeSt-É*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3644 Check('TeSt-é*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3645 Check('Test-é*', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3646 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3647 # ListConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3648 Check('Test-éüäöò\\nope', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3649 Check('Test-ÉÜÄÖÒ\\nope', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3650 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3651 # ValueConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3652 Check('Test-éüäöò', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3653 Check('Test-ÉÜÄÖÒ', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3654 |
125 | 3655 |
3656 def test_gbk_alias(self): | |
3657 # https://groups.google.com/d/msg/orthanc-users/WMM8LMbjpUc/02-1f_yFCgAJ | |
3658 # This test fails on Orthanc <= 1.3.0 | |
3659 i = UploadInstance(_REMOTE, '2017-09-19-GBK-Tumashu.dcm')['ID'] | |
3660 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3661 self.assertEqual(tags['PatientName'], u'徐浩凯') | |
3662 self.assertEqual(tags['InstitutionName'], u'灌云县疾病预防控制中心') | |
126 | 3663 |
3664 | |
3665 def test_long_tag(self): | |
3666 i = UploadInstance(_REMOTE, 'DummyCTWithLongTag.dcm')['ID'] | |
3667 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
3668 | |
3669 tags = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
3670 self.assertTrue('0018,1020' in tags) | |
3671 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3672 self.assertEqual('TooLong', tags['0018,1020']['Type']) | |
3673 self.assertEqual(None, tags['0018,1020']['Value']) | |
3674 | |
3675 tags = DoGet(_REMOTE, '/instances/%s/tags?ignore-length=0018-1020' % i) | |
3676 self.assertTrue('0018,1020' in tags) | |
3677 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3678 self.assertEqual('String', tags['0018,1020']['Type']) | |
3679 self.assertTrue(tags['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3680 | |
3681 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3682 self.assertTrue('SoftwareVersions' in tags) | |
3683 self.assertEqual(None, tags['SoftwareVersions']) | |
3684 self.assertTrue('HeartRate' in tags) | |
3685 self.assertEqual(474, int(tags['HeartRate'])) | |
3686 | |
3687 tags = DoGet(_REMOTE, '/instances/%s/simplified-tags' % i) | |
3688 self.assertTrue('SoftwareVersions' in tags) | |
3689 self.assertEqual(None, tags['SoftwareVersions']) | |
3690 | |
3691 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=0018-1020' % i) | |
3692 self.assertTrue('SoftwareVersions' in tags) | |
3693 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3694 | |
3695 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=SoftwareVersions' % i) | |
3696 self.assertTrue('SoftwareVersions' in tags) | |
3697 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3698 | |
3699 tags = DoGet(_REMOTE, '/series/%s/instances-tags' % series) | |
3700 self.assertEqual(1, len(tags)) | |
3701 self.assertTrue(i in tags.keys()) | |
3702 self.assertTrue('0018,1020' in tags[i]) | |
3703 self.assertEqual('TooLong', tags[i]['0018,1020']['Type']) | |
3704 | |
3705 tags = DoGet(_REMOTE, '/series/%s/instances-tags?ignore-length=SoftwareVersions' % series) | |
3706 self.assertEqual(1, len(tags)) | |
3707 self.assertTrue(i in tags.keys()) | |
3708 self.assertTrue('0018,1020' in tags[i]) | |
3709 self.assertEqual('String', tags[i]['0018,1020']['Type']) | |
3710 self.assertTrue(tags[i]['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3711 | |
127
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3712 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3713 def test_extended_media(self): |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3714 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3715 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3716 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
|
3717 self.assertEqual(2, len(z.namelist())) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3718 self.assertTrue('IMAGES/IM0' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3719 self.assertTrue('DICOMDIR' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3720 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3721 try: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3722 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3723 except: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3724 # The file does not exist |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3725 pass |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3726 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3727 z.extract('DICOMDIR', '/tmp') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3728 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3729 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3730 self.assertEqual(5, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3731 self.assertTrue(a[0].startswith('Warning')) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3732 self.assertEqual('BasicDirectory', a[1]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3733 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
|
3734 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
|
3735 self.assertEqual('', a[4]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3736 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3737 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3738 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3739 self.assertEqual(1, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3740 self.assertEqual('', a[0]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3741 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3742 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3743 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
|
3744 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3745 # Check the presence of the series description (extended tag) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3746 self.assertTrue(re.search('T1W_aTSE', a) != None) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3747 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3748 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3749 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3750 |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3751 def test_anonymize_relationships_1(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3752 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3753 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
|
3754 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3755 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3756 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3757 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3758 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3759 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3760 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3761 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3762 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3763 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3764 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3765 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3766 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3767 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3768 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3769 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3770 SEQUENCE = '/instances/%s/content/ReferencedImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3771 SOP = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3772 CLASS = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3773 FRAME = '/instances/%s/content/FrameOfReferenceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3774 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3775 self.assertEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3776 DoGet(_REMOTE, FRAME % a2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3777 self.assertEqual(DoGet(_REMOTE, FRAME % b1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3778 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3779 self.assertNotEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3780 DoGet(_REMOTE, FRAME % b1)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3781 self.assertNotEqual(DoGet(_REMOTE, FRAME % a2), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3782 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3783 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3784 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
|
3785 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
|
3786 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
|
3787 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
|
3788 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3789 for i in range(3): |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3790 self.assertEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3791 DoGet(_REMOTE, SOP % (a2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3792 self.assertEqual(DoGet(_REMOTE, SOP % (b1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3793 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3794 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3795 DoGet(_REMOTE, SOP % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3796 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3797 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3798 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3799 DoGet(_REMOTE, CLASS % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3800 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3801 DoGet(_REMOTE, CLASS % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3802 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3803 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3804 def test_anonymize_relationships_2(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3805 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3806 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
|
3807 study = '6c65289b-db2fcb71-7eaf73f4-8e12470c-a4d6d7cf' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3808 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3809 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3810 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3811 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3812 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3813 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3814 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3815 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3816 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3817 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3818 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3819 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3820 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3821 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3822 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3823 SEQUENCE = '/instances/%s/content/SourceImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3824 SOP = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3825 CLASS = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3826 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3827 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
|
3828 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
|
3829 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
|
3830 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
|
3831 self.assertEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3832 DoGet(_REMOTE, SOP % (a2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3833 self.assertEqual(DoGet(_REMOTE, SOP % (b1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3834 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3835 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3836 DoGet(_REMOTE, SOP % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3837 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3838 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3839 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3840 DoGet(_REMOTE, CLASS % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3841 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3842 DoGet(_REMOTE, CLASS % (b2, 0))) |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3843 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3844 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3845 def test_anonymize_relationships_3(self): |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3846 sr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM0')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3847 mr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM631')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3848 study = 'ef351eb2-c1147229-062736b8-35a151e3-e32d526b' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3849 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3850 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3851 { "Keep" : [ "ContentSequence" ] }) ['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3852 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3853 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3854 self.assertEqual(2, len(a)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3855 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3856 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
|
3857 sr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3858 mr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3859 else: |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3860 sr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3861 mr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3862 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3863 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % sr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3864 DoGet(_REMOTE, '/instances/%s/content/Modality' % sr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3865 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % mr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3866 DoGet(_REMOTE, '/instances/%s/content/Modality' % mr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3867 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3868 mrUid1 = DoGet(_REMOTE, '/instances/%s' % mr1)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3869 mrUid2 = DoGet(_REMOTE, '/instances/%s' % mr2)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3870 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
|
3871 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
|
3872 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
|
3873 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
|
3874 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3875 PATH1 = '/instances/%s/content/CurrentRequestedProcedureEvidenceSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3876 PATH2 = PATH1 + '/0/ReferencedSeriesSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3877 PATH3 = PATH2 + '/0/ReferencedSOPSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3878 PATH4 = PATH3 + '/0/ReferencedSOPInstanceUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3879 PATH5 = PATH3 + '/0/ReferencedSOPClassUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3880 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3881 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3882 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3883 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3884 self.assertEqual(DoGet(_REMOTE, PATH4 % sr1), mrUid1) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3885 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
|
3886 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
|
3887 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3888 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3889 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3890 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3891 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
|
3892 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3893 self.assertEqual(mrUid2, DoGet(_REMOTE, PATH4 % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3894 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
|
3895 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
|
3896 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3897 content1 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr1) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3898 content2 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr2) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3899 self.assertEqual(str(content1), str(content2)) |
141
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3900 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3901 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3902 def test_bitbucket_issue_94(self): |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3903 # "a simple instance modification should not modify FrameOfReferenceUID + ..." |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3904 # https://bitbucket.org/sjodogne/orthanc/issues/94 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3905 i = UploadInstance(_REMOTE, 'Issue94.dcm')['ID'] |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3906 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3907 source = DoGet(_REMOTE, '/instances/%s/attachments/dicom/data' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3908 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3909 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3910 { "Replace" : {"PatientID" : "toto"}, "Force": True}) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3911 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3912 anonymized = DoPost(_REMOTE, '/instances/%s/anonymize' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3913 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3914 a = ExtractDicomTags(source, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3915 self.assertEqual(1, len(a)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3916 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3917 b = ExtractDicomTags(modified, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3918 self.assertEqual(1, len(b)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3919 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3920 c = ExtractDicomTags(anonymized, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3921 self.assertEqual(1, len(c)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3922 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3923 self.assertEqual(a, b) # Modified DICOM |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3924 self.assertNotEqual(a, c) # Anonymized DICOM |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3925 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3926 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3927 def test_metadata_origin(self): |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3928 # Upload using the REST API |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3929 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
|
3930 self.assertEqual('RestApi', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3931 self.assertEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3932 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3933 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
|
3934 self.assertEqual('alice', DoGet(_REMOTE, '/instances/%s/metadata/HttpUsername' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3935 |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3936 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3937 self.assertEqual('RestApi', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3938 self.assertEqual('', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3939 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3940 self.assertFalse('CalledAET' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3941 self.assertEqual('alice', m['HttpUsername']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3942 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3943 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
|
3944 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
|
3945 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3946 self.assertTrue('ReceptionDate' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3947 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3948 DoDelete(_REMOTE, '/instances/%s' % i) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3949 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3950 # Upload using the DICOM protocol |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3951 subprocess.check_call([ FindExecutable('storescu'), |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3952 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3953 GetDatabasePath('Knee/T1/IM-0001-0001.dcm'), |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3954 '-xw' ]) # Propose JPEG2000 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3955 self.assertEqual('DicomProtocol', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3956 self.assertEqual('STORESCU', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3957 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3958 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
|
3959 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
|
3960 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3961 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3962 self.assertEqual('DicomProtocol', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3963 self.assertEqual('STORESCU', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3964 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3965 self.assertEqual('ANY-SCP', m['CalledAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3966 self.assertFalse('HttpUsername' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3967 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3968 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
|
3969 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
|
3970 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3971 self.assertTrue('ReceptionDate' in m) |
147 | 3972 |
3973 | |
3974 def test_lua_deadlock(self): | |
3975 # Rana Asim Wajid (2018-07-14): "It does seem that the issue | |
3976 # is with the lua script I'm using for conversion of images to | |
3977 # JPEG2000. When the script is used with 1.4.0 the first | |
3978 # instance appears to be stored and then everything just | |
3979 # halts, ie Orthanc wont respond to anything after that." | |
3980 # https://groups.google.com/d/msg/orthanc-users/Rc-Beb42xc8/JUgdzrmCAgAJ | |
174 | 3981 InstallLuaScriptFromPath(_REMOTE, 'Lua/Jpeg2000Conversion.lua') |
147 | 3982 |
3983 subprocess.check_call([ FindExecutable('storescu'), | |
3984 _REMOTE['Server'], str(_REMOTE['DicomPort']), | |
3985 GetDatabasePath('Brainix/Flair/IM-0001-0001.dcm'), | |
3986 GetDatabasePath('Brainix/Flair/IM-0001-0002.dcm'), | |
3987 ]) | |
3988 | |
3989 instances = DoGet(_REMOTE, '/instances') | |
3990 self.assertEqual(2, len(instances)) | |
3991 | |
3992 t1 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[0]) | |
3993 t2 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[1]) | |
175 | 3994 self.assertEqual('1.2.840.10008.1.2.4.90', t1) # this will fail if libgdcm-tools is not installed |
147 | 3995 self.assertEqual(t1, t2); |
154
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3996 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3997 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3998 def test_find_group_length(self): |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3999 # 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
|
4000 # one of the Generic Group Length tags (*, 0x0000) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4001 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
|
4002 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
|
4003 self.assertFalse('UnableToProcess' in result) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4004 self.assertFalse('E:' in result) |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4005 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4006 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4007 def test_split(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4008 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4009 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4010 knee1Sop = '1.3.46.670589.11.17521.5.0.3124.2008081908590448738' |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4011 knee2Sop = '1.3.46.670589.11.17521.5.0.3124.2008081909113806560' |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4012 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4013 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4014 t2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4015 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4016 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4017 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4018 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4019 info = DoGet(_REMOTE, '/studies/%s' % study) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4020 self.assertTrue('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4021 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4022 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4023 (_REMOTE, '/studies/%s/split' % study, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4024 'Series' : [ t2 ], |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4025 'Replace' : { 'PatientName' : 'Hello' }, |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4026 'Remove' : [ 'ReferringPhysicianName' ], |
181 | 4027 'KeepSource' : False, |
4028 'Asynchronous' : True | |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4029 })) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4030 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4031 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4032 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4033 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4034 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4035 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4036 series = set(DoGet(_REMOTE, '/series')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4037 self.assertEqual(2, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4038 self.assertTrue(t1 in series) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4039 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4040 study2 = DoGet(_REMOTE, '/jobs/%s' % job)['Content']['TargetStudy'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4041 self.assertTrue(study in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4042 self.assertTrue(study2 in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4043 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4044 info = DoGet(_REMOTE, '/studies/%s' % study2) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4045 self.assertTrue('Hello', info['PatientMainDicomTags']['PatientName']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4046 self.assertFalse('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4047 |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4048 sopInstanceUids = set() |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4049 for i in DoGet(_REMOTE, '/instances?expand'): |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4050 sopInstanceUids.add(i['MainDicomTags']['SOPInstanceUID']) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4051 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4052 self.assertTrue(knee1Sop in sopInstanceUids) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4053 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4054 # Fails if Orthanc <= 1.5.7 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4055 self.assertFalse(knee2Sop in sopInstanceUids) # Because "KeepSource" is False |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4056 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4057 # One original instance is kept, another one is added because of the split |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4058 self.assertEqual(2, len(sopInstanceUids)) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4059 |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4060 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4061 def test_merge(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4062 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4063 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4064 kneeSop = '1.3.46.670589.11.17521.5.0.3124.2008081908590448738' |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4065 brainixSop = '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549' |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4066 knee = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4067 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4068 brainix = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4069 flair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4070 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4071 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4072 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4073 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4074 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4075 (_REMOTE, '/studies/%s/merge' % knee, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4076 'Resources' : [ brainix ], |
181 | 4077 'KeepSource' : True, |
4078 'Synchronous' : False | |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4079 })) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4080 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4081 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4082 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4083 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4084 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4085 self.assertTrue(knee in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4086 self.assertTrue(brainix in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4087 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4088 series = set(DoGet(_REMOTE, '/studies/%s' % knee)['Series']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4089 self.assertTrue(t1 in series) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4090 series.remove(t1) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4091 self.assertEqual(1, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4092 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4093 instances = DoGet(_REMOTE, '/series/%s' % list(series)[0])['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4094 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4095 merged = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4096 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4097 instances = DoGet(_REMOTE, '/series/%s' % t1)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4098 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4099 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4100 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4101 instances = DoGet(_REMOTE, '/series/%s' % flair)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4102 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4103 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4104 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4105 tags = DoGet(_REMOTE, '/studies/%s' % knee) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4106 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4107 for key in tags['PatientMainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4108 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4109 if (key in b and key != 'PatientSex'): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4110 self.assertNotEqual(a[key], b[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4111 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4112 for key in tags['MainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4113 # Not in the patient/study module |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4114 if (not key in [ 'InstitutionName', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4115 'RequestingPhysician', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4116 'RequestedProcedureDescription', ]): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4117 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4118 if (key in b): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4119 self.assertNotEqual(a[key], b[key]) |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4120 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4121 sopInstanceUids = set() |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4122 for i in DoGet(_REMOTE, '/instances?expand'): |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4123 sopInstanceUids.add(i['MainDicomTags']['SOPInstanceUID']) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4124 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4125 self.assertTrue(kneeSop in sopInstanceUids) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4126 self.assertTrue(brainixSop in sopInstanceUids) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4127 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4128 # Fails if Orthanc <= 1.5.7 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4129 # The 2 original instances are kept, another one is added because of the merge |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4130 self.assertEqual(3, len(sopInstanceUids)) |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4131 |
187 | 4132 |
4133 def test_async_archive(self): | |
4134 # Testing the asynchronous generation of archives/medias (new | |
4135 # in Orthanc 1.4.3) | |
4136 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
4137 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
4138 | |
4139 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
4140 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
4141 | |
4142 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4143 (_REMOTE, '/studies/%s/archive' % kneeT1, { | |
4144 'Synchronous' : False | |
4145 })) | |
4146 | |
4147 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4148 self.assertEqual(1, len(z.namelist())) | |
4149 self.assertFalse('DICOMDIR' in z.namelist()) | |
4150 | |
4151 job2 = MonitorJob2(_REMOTE, lambda: DoPost | |
4152 (_REMOTE, '/studies/%s/media' % kneeT1, { | |
4153 'Synchronous' : False | |
4154 })) | |
4155 | |
4156 # The archive from the first job has been replaced by the | |
4157 # archive from second job (as MediaArchiveSize == 1) | |
4158 self.assertRaises(Exception, lambda: GetArchive(_REMOTE, '/jobs/%s/archive' % job)) | |
4159 | |
4160 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job2) | |
4161 self.assertEqual(2, len(z.namelist())) | |
4162 self.assertTrue('DICOMDIR' in z.namelist()) | |
4163 | |
4164 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4165 (_REMOTE, '/tools/create-archive', { | |
4166 'Synchronous' : False, | |
4167 'Resources' : [ kneeT1, kneeT2 ], | |
4168 })) | |
4169 | |
4170 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4171 self.assertEqual(2, len(z.namelist())) | |
4172 self.assertFalse('DICOMDIR' in z.namelist()) | |
4173 | |
4174 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4175 (_REMOTE, '/tools/create-media', { | |
4176 'Synchronous' : False, | |
4177 'Resources' : [ kneeT1, kneeT2 ], | |
4178 })) | |
4179 | |
4180 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4181 self.assertEqual(3, len(z.namelist())) | |
4182 self.assertTrue('DICOMDIR' in z.namelist()) | |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4183 |
187 | 4184 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4185 def test_queries_hierarchy(self): |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4186 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4187 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4188 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4189 tags = { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4190 'NumberOfPatientRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4191 'NumberOfPatientRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4192 'NumberOfPatientRelatedStudies' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4193 'NumberOfStudyRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4194 'NumberOfStudyRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4195 'NumberOfSeriesRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4196 } |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4197 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4198 tags2 = copy.copy(tags) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4199 tags2['PatientID'] = '887' # Only consider the "Knee" patient |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4200 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4201 patient = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4202 'Level' : 'Patient', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4203 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4204 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4205 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4206 study = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4207 'Level' : 'Study', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4208 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4209 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4210 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4211 series = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4212 'Level' : 'Series', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4213 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4214 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4215 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4216 instance = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4217 'Level' : 'Instance', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4218 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4219 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4220 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4221 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % patient) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4222 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4223 self.assertEqual('887', p[0]['PatientID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4224 self.assertEqual('1', p[0]['NumberOfPatientRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4225 self.assertEqual('1', p[0]['NumberOfPatientRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4226 self.assertEqual('1', p[0]['NumberOfPatientRelatedStudies']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4227 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4228 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4229 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4230 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4231 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % study) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4232 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4233 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', p[0]['StudyInstanceUID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4234 self.assertEqual('1', p[0]['NumberOfStudyRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4235 self.assertEqual('1', p[0]['NumberOfStudyRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4236 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4237 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4238 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4239 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4240 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4241 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4242 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4243 self.assertEqual('1.3.46.670589.11.17521.5.0.3124.2008081908564160709', p[0]['SeriesInstanceUID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4244 self.assertEqual('1', p[0]['NumberOfSeriesRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4245 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4246 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4247 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4248 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4249 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4250 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4251 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4252 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4253 self.assertEqual('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', p[0]['SOPInstanceUID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4254 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4255 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-studies' % patient, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4256 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4257 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4258 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % study)) |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4259 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4260 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-series' % patient, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4261 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4262 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4263 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4264 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4265 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-instances' % patient, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4266 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4267 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4268 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4269 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4270 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-series' % study, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4271 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4272 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4273 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4274 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4275 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-instances' % study, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4276 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4277 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4278 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4279 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4280 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-instances' % series, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4281 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4282 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4283 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4284 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4285 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4286 def test_dicom_disk_size(self): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4287 dicomSize = 0 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4288 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4289 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4290 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4291 for i in range(2): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4292 p = 'Knee/T%d/IM-0001-0001.dcm' % (i + 1) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4293 UploadInstance(_REMOTE, p) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4294 dicomSize += os.path.getsize(GetDatabasePath(p)) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4295 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4296 s = DoGet(_REMOTE, '/patients/ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17/statistics') # Consider Knee patient |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4297 self.assertEqual(2, s['CountInstances']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4298 self.assertEqual(2, s['CountSeries']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4299 self.assertEqual(1, s['CountStudies']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4300 self.assertEqual(dicomSize, int(s['DicomDiskSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4301 self.assertEqual(dicomSize, int(s['DicomUncompressedSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4302 self.assertLess(dicomSize, int(s['UncompressedSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4303 self.assertEqual(s['UncompressedSize'], s['DiskSize']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4304 |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4305 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4306 def test_changes_2(self): |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4307 # More consistent behavior since Orthanc 1.5.2 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4308 # https://groups.google.com/d/msg/orthanc-users/QhzB6vxYeZ0/YxabgqpfBAAJ |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4309 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4310 # Make sure that this is not the first change |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4311 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4312 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4313 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4314 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4315 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4316 # No more instance, but there were previous changes |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4317 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4318 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4319 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4320 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4321 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4322 seq = c['Last'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4323 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4324 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4325 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4326 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4327 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4328 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4329 c = DoGet(_REMOTE, '/changes?since=%d' % (seq + 1000)) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4330 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4331 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4332 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4333 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4334 # Add one instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4335 UploadInstance(_REMOTE, 'DummyCT.dcm') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4336 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4337 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4338 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4339 self.assertEqual(4, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4340 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4341 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4342 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4343 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4344 self.assertEqual(1, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4345 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4346 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4347 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4348 c = DoGet(_REMOTE, '/changes?since=%d' % (seq + 1000)) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4349 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4350 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4351 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4352 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4353 # Remove the uploaded instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4354 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4355 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4356 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4357 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4358 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4359 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4360 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4361 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4362 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4363 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4364 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4365 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4366 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4367 c = DoGet(_REMOTE, '/changes?since=%d' % (seq + 1000)) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4368 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4369 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4370 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4371 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4372 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4373 def test_bitbucket_issue_124(self): |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4374 a = UploadInstance(_REMOTE, 'Issue124.dcm')['ID'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4375 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4376 z = GetArchive(_REMOTE, '/patients/%s/media' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4377 self.assertEqual(2, len(z.namelist())) |
207
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4378 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4379 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4380 def test_invalid_findscp(self): |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4381 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4382 findscu = CallFindScu([ '-S', '-k', '8,52=IMAGE', '-k', '8,16', '-k', '2,2' ]) |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4383 self.assertEqual(0, len(re.findall('\(0002,0002\)', findscu))) |
208
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4384 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4385 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4386 def test_bitbucket_issue_90(self): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4387 def CountDicomResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4388 a = CallFindScu([ '-S', '-k', '8,52=STUDY', '-k', sex ]) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4389 return len(re.findall('\(0010,0040\)', a)) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4390 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4391 def CountRestResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4392 a = DoPost(_REMOTE, '/tools/find', |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4393 { 'Level' : 'Study', 'Query' : { 'PatientSex' : sex } }) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4394 return len(a) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4395 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4396 # Just like the "CR000000.dcm" of the issue, the test image |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4397 # "DummyCT.dcm" has the tag PatientSex (0010,0040) unset |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4398 UploadInstance(_REMOTE, 'DummyCT.dcm') |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4399 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4400 # Test that the behavior of DICOM vs. REST API is consistent on missing tags |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4401 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4402 # In wildcard constraints, the patient sex must be set for a match to occur |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4403 self.assertEqual(0, CountDicomResults('PatientSex=*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4404 self.assertEqual(0, CountRestResults('*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4405 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4406 # In single-valued constraints, the patient sex must be set |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4407 self.assertEqual(0, CountDicomResults('PatientSex=F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4408 self.assertEqual(0, CountDicomResults('PatientSex=M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4409 self.assertEqual(0, CountRestResults('F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4410 self.assertEqual(0, CountRestResults('M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4411 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4412 # Empty constraints are only used to ask the actual value of |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4413 # the tag to be added to the *answer*. The tag should not used |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4414 # as a filter in such a situation. |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4415 self.assertEqual(1, CountDicomResults('PatientSex')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4416 self.assertEqual(1, CountDicomResults('PatientSex=')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4417 self.assertEqual(1, CountRestResults('')) # This check fails on Orthanc <= 1.5.2 (issue 90) |
210
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4418 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4419 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4420 def test_rest_modalities_in_study(self): |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4421 # Tests a regression that is present in Orthanc 1.5.2 and 1.5.3 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4422 # https://groups.google.com/d/msg/orthanc-users/7lZyG3wpx-M/uOXzAzVCFwAJ |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4423 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4424 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4425 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4426 'Query' : { 'ModalitiesInStudy' : 'US' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4427 self.assertEqual(0, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4428 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4429 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4430 'Query' : { 'ModalitiesInStudy' : 'US\\CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4431 self.assertEqual(1, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4432 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4433 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4434 'Query' : { 'ModalitiesInStudy' : 'CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4435 self.assertEqual(1, len(a)) |
211 | 4436 |
4437 | |
4438 def test_series_status(self): | |
4439 def HasCompletedInChanges(): | |
4440 for c in DoGet(_REMOTE, '/changes?limit=1000&since=0')['Changes']: | |
4441 if c['ChangeType'] == 'CompletedSeries': | |
4442 return True; | |
4443 | |
4444 return False | |
4445 | |
4446 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm') | |
4447 series = '8ea120d7-5057d919-837dfbcc-ccd04e0f-7f3a94aa' | |
4448 self.assertEqual('Unknown', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4449 self.assertFalse(HasCompletedInChanges()) | |
4450 | |
4451 series = 'ce25ecb6-ed79d004-5ae43ca7-3fc89bc5-67511614' | |
4452 | |
4453 for i in range(3): | |
4454 UploadInstance(_REMOTE, 'Series/Lena-%d.dcm' % (i + 1)) | |
4455 self.assertEqual('Missing', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4456 self.assertFalse(HasCompletedInChanges()) | |
4457 | |
4458 UploadInstance(_REMOTE, 'Series/Lena-4.dcm') | |
4459 self.assertEqual('Complete', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4460 self.assertTrue(HasCompletedInChanges()) | |
4461 | |
4462 DoDelete(_REMOTE, '/changes') | |
4463 self.assertFalse(HasCompletedInChanges()) | |
4464 | |
4465 UploadInstance(_REMOTE, 'Series/Lena-5.dcm') | |
4466 self.assertEqual('Inconsistent', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4467 self.assertFalse(HasCompletedInChanges()) | |
4468 | |
215 | 4469 |
4470 def test_dicomweb(self): | |
4471 def Compare(dicom, reference): | |
4472 a = UploadInstance(_REMOTE, dicom) ['ID'] | |
4473 b = DoGet(_REMOTE, '/instances/%s/file' % a, | |
4474 headers = { 'Accept' : 'application/dicom+json' }) | |
4475 with open(GetDatabasePath(reference), 'rb') as c: | |
4476 d = json.load(c) | |
220 | 4477 AssertAlmostEqualRecursive(self, d, b) |
215 | 4478 |
4479 Compare('DummyCT.dcm', 'DummyCT.json') | |
4480 Compare('MarekLatin2.dcm', 'MarekLatin2.json') | |
4481 Compare('HierarchicalAnonymization/StructuredReports/IM0', | |
4482 'HierarchicalAnonymization/StructuredReports/IM0.json') | |
217 | 4483 |
4484 | |
4485 def test_issue_95_encodings(self): | |
4486 # https://bitbucket.org/sjodogne/orthanc/issues/95/server-cant-support-chinese | |
4487 # Check out image: "../Database/Encodings/DavidClunie/charsettests.screenshot.png" | |
4488 | |
4489 # Very useful tool: "file2" from package "file-kanji" | |
4490 | |
4491 def GetPatientName(dicom): | |
4492 i = UploadInstance(_REMOTE, dicom) ['ID'] | |
4493 j = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
4494 return j['PatientName'] | |
4495 | |
4496 def ComparePatientName(name, dicom): | |
4497 self.assertEqual(name, GetPatientName(dicom)) | |
4498 | |
4499 # gdcmraw -t 10,10 -i SCSFREN -o /tmp/tag && uconv -f ISO-IR-100 -t UTF-8 /tmp/tag && echo | |
4500 ComparePatientName(u'Buc^Jérôme', 'Encodings/DavidClunie/SCSFREN') | |
4501 | |
4502 # gdcmraw -t 10,10 -i SCSI2 -o /tmp/tag && uconv -f KOREAN -t UTF-8 /tmp/tag && echo | |
4503 ComparePatientName(u'Hong^Gildong=洪^吉洞=홍^길동', 'Encodings/DavidClunie/SCSI2') # Since Orthanc 1.5.5 | |
4504 | |
4505 # gdcmraw -t 10,10 -i SCSX2 -o /tmp/tag && uconv -f GB18030 -t UTF-8 /tmp/tag && echo | |
4506 ComparePatientName(u'Wang^XiaoDong=王^小东=', 'Encodings/DavidClunie/SCSX2') | |
4507 | |
4508 # gdcmraw -t 10,10 -i SCSX1 -o /tmp/tag && cat /tmp/tag && echo | |
4509 ComparePatientName(u'Wang^XiaoDong=王^小東=', 'Encodings/DavidClunie/SCSX1') | |
4510 | |
4511 # gdcmraw -t 10,10 -i SCSH31 -o /tmp/tag && uconv -f JIS -t UTF-8 /tmp/tag && echo | |
4512 ComparePatientName(u'Yamada^Tarou=山田^太郎=やまだ^たろう', 'Encodings/DavidClunie/SCSH31') | |
4513 | |
4514 # gdcmraw -t 10,10 -i SCSGERM -o /tmp/tag && uconv -f ISO-IR-100 -t UTF-8 /tmp/tag && echo | |
4515 ComparePatientName(u'Äneas^Rüdiger', 'Encodings/DavidClunie/SCSGERM') | |
4516 | |
4517 # gdcmraw -t 10,10 -i SCSGREEK -o /tmp/tag && uconv -f ISO-IR-126 -t UTF-8 /tmp/tag && echo | |
4518 ComparePatientName(u'Διονυσιος', 'Encodings/DavidClunie/SCSGREEK') | |
4519 | |
4520 # gdcmraw -t 10,10 -i SCSRUSS -o /tmp/tag && uconv -f ISO-IR-144 -t UTF-8 /tmp/tag && echo | |
4521 ComparePatientName(u'Люкceмбypг', 'Encodings/DavidClunie/SCSRUSS') | |
4522 | |
4523 # gdcmraw -t 10,10 -i SCSHBRW -o /tmp/tag && uconv -f ISO-IR-138 -t UTF-8 /tmp/tag && echo | |
4524 # NB: Hebrew is a right-to-left encoding, copying/pasting from | |
4525 # Linux console into Emacs automatically reverse the string | |
4526 ComparePatientName(u'שרון^דבורה', 'Encodings/DavidClunie/SCSHBRW') | |
4527 | |
4528 # gdcmraw -t 10,10 -i SCSARAB -o /tmp/tag && uconv -f ISO-IR-127 -t UTF-8 /tmp/tag && echo | |
4529 # NB: Right-to-left as for Hebrew (SCSHBRW), and the Ubuntu console can't display such | |
4530 # characters by default, but copy/paste works with Emacs | |
4531 ComparePatientName(u'قباني^لنزار', 'Encodings/DavidClunie/SCSARAB') | |
4532 | |
4533 # SCSH32: This SpecificCharacterSet is composed of 2 | |
4534 # codepages: "ISO 2022 IR 13" (i.e. "SHIFT_JIS") until the | |
4535 # first equal, then "ISO 2022 IR 87" (i.e. "JIS") for the | |
4536 # remainer. Orthanc only takes into consideration the first | |
4537 # codepage: This is a limitation. | |
4538 # gdcmraw -t 10,10 -i SCSH32 -o /tmp/tag && cut -d '=' -f 1 /tmp/tag | uconv -f SHIFT_JIS -t UTF-8 | |
4539 self.assertTrue(GetPatientName('Encodings/DavidClunie/SCSH32').startswith(u'ヤマダ^タロウ=')) | |
218
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4540 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4541 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4542 def test_findscu_missing_tags(self): |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4543 # dcmodify -e Rows DummyCTInvalidRows.dcm -gst -gse -gin |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4544 UploadInstance(_REMOTE, 'DummyCT.dcm') |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4545 UploadInstance(_REMOTE, 'DummyCTInvalidRows.dcm') |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4546 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4547 i = CallFindScu([ '-k', '0008,0052=IMAGES', '-k', 'Rows', '-k', 'PatientName' ]) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4548 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4549 # We have 2 instances... |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4550 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4551 self.assertEqual(2, len(patientNames)) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4552 self.assertEqual('KNIX', patientNames[0]) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4553 self.assertEqual('KNIX', patientNames[1]) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4554 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4555 # ...but only 1 value for the "Rows" tag |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4556 rows = re.findall('\(0028,0010\) US ([0-9]+)', i) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4557 self.assertEqual(1, len(rows)) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4558 self.assertEqual('512', rows[0]) |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4559 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4560 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4561 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4562 def test_bitbucket_issue_131(self): |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4563 # "Orthanc PACS silently fails to C-MOVE due to duplicate |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4564 # StudyInstanceUID in it's database." |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4565 # https://bitbucket.org/sjodogne/orthanc/issues/131/orthanc-pacs-silently-fails-to-c-move-due |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4566 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4567 # Insert 2 instances, with the same StudyInstanceUID, but with |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4568 # different patient IDs. Orthanc will create 2 distincts |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4569 # patients, and the hierarchy of resources above the two |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4570 # instances will be fully disjoint. |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4571 UploadInstance(_REMOTE, 'PatientIdsCollision/Issue131-a.dcm') |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4572 UploadInstance(_REMOTE, 'PatientIdsCollision/Issue131-b.dcm') |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4573 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4574 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4575 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4576 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4577 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4578 'Level' : 'Study', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4579 'Query' : {"PatientID": "A" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4580 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4581 # 1 study is matched |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4582 self.assertEqual(1, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4583 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4584 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4585 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4586 (_REMOTE, '/queries/%s/retrieve' % a, | |
4587 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4588 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4589 # The two studies are matched, as we made the request at the |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4590 # Study level, thus the shared StudyInstanceUID is used as the key |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4591 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4592 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4593 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4594 # Match the 2 studies |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4595 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4596 'Level' : 'Study', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4597 'Query' : {"StudyInstanceUID": "2.25.123" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4598 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4599 DropOrthanc(_LOCAL) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4600 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4601 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4602 (_REMOTE, '/queries/%s/retrieve' % a, | |
4603 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4604 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4605 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4606 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4607 # Same test, at the patient level => only 1 instance is transfered |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4608 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4609 'Level' : 'Patient', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4610 'Query' : {"PatientID": "A" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4611 self.assertEqual(1, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4612 DropOrthanc(_LOCAL) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4613 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4614 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4615 (_REMOTE, '/queries/%s/retrieve' % a, | |
4616 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4617 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4618 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4619 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4620 # Same test, at the series level => only 1 instance is transfered |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4621 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4622 'Level' : 'Series', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4623 'Query' : {"PatientID": "A" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4624 self.assertEqual(1, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4625 DropOrthanc(_LOCAL) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4626 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4627 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4628 (_REMOTE, '/queries/%s/retrieve' % a, | |
4629 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4630 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4631 |
233
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4632 |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4633 def test_bitbucket_issue_136(self): |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4634 UploadInstance(_REMOTE, 'Issue137.dcm') |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4635 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', '0010,0010', '-k', '0028,0010', '-k', '0040,0275' ]) |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4636 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4637 self.assertEqual(1, len(patientNames)) |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4638 self.assertEqual('John Doe', patientNames[0]) |
234
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4639 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4640 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4641 def test_anonymize_relationships_4(self): |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4642 # https://groups.google.com/d/msg/orthanc-users/UkcsqyTpszE/bXUpzU0vAAAJ |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4643 sr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/2019-03-28/CR000000.dcm')['ID'] |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4644 mr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/2019-03-28/PR000000.dcm')['ID'] |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4645 study = '0c923249-d52121a9-2b7167f7-6b85534f-0943697e' |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4646 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4647 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, '{}', |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4648 'application/json')['ID'] |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4649 series = DoGet(_REMOTE, '/studies/%s/series' % anonymized) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4650 self.assertEqual(2, len(series)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4651 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4652 cr = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'CR', series)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4653 pr = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'PR', series)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4654 self.assertEqual(1, len(cr)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4655 self.assertEqual(1, len(pr)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4656 self.assertEqual(1, len(cr[0]['Instances'])) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4657 self.assertEqual(1, len(pr[0]['Instances'])) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4658 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4659 crinstance = DoGet(_REMOTE, '/instances/%s' % cr[0]['Instances'][0]) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4660 tags = DoGet(_REMOTE, '/instances/%s/tags?short' % pr[0]['Instances'][0]) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4661 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4662 self.assertEqual(tags['0008,1115'][0]['0008,1140'][0]['0008,1155'], |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4663 crinstance['MainDicomTags']['SOPInstanceUID']) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4664 self.assertEqual(tags['0008,1115'][0]['0008,1140'][0]['0008,1150'], |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4665 '1.2.840.10008.5.1.4.1.1.1') # SOP class for CR Image Storage |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4666 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4667 # This fails on Orthanc <= 1.5.6 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4668 self.assertEqual(tags['0008,1115'][0]['0020,000e'], |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4669 cr[0]['MainDicomTags']['SeriesInstanceUID']) |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4670 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4671 |
255
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4672 def test_anonymize_relationships_5(self): |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4673 ct1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/CT01.dcm') |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4674 rt1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/RT.dcm') |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4675 oStudyId = ct1['ParentStudy'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4676 oCtInstanceId = ct1['ID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4677 oRtInstanceId = rt1['ID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4678 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4679 oCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oCtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4680 oRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oRtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4681 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4682 # first validate the relationships in the source data |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4683 oStudyUID = oCtTags['StudyInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4684 oRtSeriesUID = oRtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4685 oRtInstanceUID = oRtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4686 oRtFrameOfReferenceUID = oRtTags['ReferencedFrameOfReferenceSequence'][0]['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4687 oCtSeriesUID = oCtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4688 oCtInstanceUID = oCtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4689 oCtFrameOfReferenceUID = oCtTags['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4690 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4691 oContourSequenceCount = len(oRtTags['ROIContourSequence'][0]['ContourSequence']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4692 self.assertEqual(oCtFrameOfReferenceUID, oRtFrameOfReferenceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4693 self.assertEqual(oStudyUID, oRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4694 self.assertEqual(oCtSeriesUID, oRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['SeriesInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4695 self.assertEqual(oCtInstanceUID, oRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4696 self.assertEqual(oCtInstanceUID, oRtTags['ROIContourSequence'][0]['ContourSequence'][oContourSequenceCount-1]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4697 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4698 ### anonymize |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4699 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4700 aStudyId = DoPost(_REMOTE, '/studies/%s/anonymize' % oStudyId, '{}', |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4701 'application/json')['ID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4702 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4703 ### validate |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4704 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4705 aSeries = DoGet(_REMOTE, '/studies/%s/series' % aStudyId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4706 self.assertEqual(2, len(aSeries)) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4707 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4708 aCt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'CT', aSeries)) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4709 aRt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'RTSTRUCT', aSeries)) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4710 aCtInstanceId = aCt[0]['Instances'][0] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4711 aRtInstanceId = aRt[0]['Instances'][0] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4712 aCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aCtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4713 aRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aRtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4714 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4715 # now validate the relationships in the anonymized data |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4716 aStudyUID = aCtTags['StudyInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4717 aRtSeriesUID = aRtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4718 aRtInstanceUID = aRtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4719 aRtFrameOfReferenceUID = aRtTags['ReferencedFrameOfReferenceSequence'][0]['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4720 aCtSeriesUID = aCtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4721 aCtInstanceUID = aCtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4722 aCtFrameOfReferenceUID = aCtTags['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4723 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4724 aContourSequenceCount = len(aRtTags['ROIContourSequence'][0]['ContourSequence']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4725 # make sure all UIDs have been updated |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4726 self.assertNotEqual(oStudyUID, aStudyUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4727 self.assertNotEqual(oRtSeriesUID, aRtSeriesUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4728 self.assertNotEqual(oRtInstanceUID, aRtInstanceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4729 self.assertNotEqual(oRtFrameOfReferenceUID, aRtFrameOfReferenceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4730 self.assertNotEqual(oCtSeriesUID, aCtSeriesUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4731 self.assertNotEqual(oCtInstanceUID, aCtInstanceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4732 self.assertNotEqual(oCtFrameOfReferenceUID, aCtFrameOfReferenceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4733 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4734 # validate the relationships |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4735 self.assertEqual(oContourSequenceCount, aContourSequenceCount) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4736 self.assertEqual(aCtFrameOfReferenceUID, aRtFrameOfReferenceUID) |
256 | 4737 self.assertEqual(aStudyUID, aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['ReferencedSOPInstanceUID']) |
4738 self.assertEqual(aCtSeriesUID, aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['SeriesInstanceUID']) | |
255
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4739 self.assertEqual(aCtInstanceUID, aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4740 self.assertEqual(aCtInstanceUID, aRtTags['ROIContourSequence'][0]['ContourSequence'][aContourSequenceCount-1]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4741 |
256 | 4742 def test_anonymize_relationships_5b(self): |
4743 # same test as previous one but, this time, we force the StudyInstanceUID | |
4744 ct1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/CT01.dcm') | |
4745 rt1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/RT.dcm') | |
4746 oStudyId = ct1['ParentStudy'] | |
4747 oCtInstanceId = ct1['ID'] | |
4748 oRtInstanceId = rt1['ID'] | |
4749 | |
4750 oCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oCtInstanceId) | |
4751 oRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oRtInstanceId) | |
4752 | |
4753 ### anonymize while forcing the StudyInstanceUID | |
4754 | |
4755 aStudyId = DoPost(_REMOTE, '/studies/%s/anonymize' % oStudyId, '{ "Replace" : { "StudyInstanceUID" : "1.2.3.4"}, "Force": true}', | |
4756 'application/json')['ID'] | |
4757 | |
4758 ### validate | |
4759 | |
4760 aSeries = DoGet(_REMOTE, '/studies/%s/series' % aStudyId) | |
4761 self.assertEqual(2, len(aSeries)) | |
4762 | |
4763 aCt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'CT', aSeries)) | |
4764 aRt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'RTSTRUCT', aSeries)) | |
4765 aCtInstanceId = aCt[0]['Instances'][0] | |
4766 aRtInstanceId = aRt[0]['Instances'][0] | |
4767 aCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aCtInstanceId) | |
4768 aRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aRtInstanceId) | |
4769 | |
4770 self.assertEqual("1.2.3.4", aCtTags['StudyInstanceUID']) | |
4771 self.assertEqual("1.2.3.4", aRtTags['StudyInstanceUID']) | |
4772 self.assertEqual("1.2.3.4", aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['ReferencedSOPInstanceUID']) | |
255
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4773 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4774 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4775 |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4776 @unittest.skip('Not fixed yet in Orthanc') |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4777 def test_bitbucket_issue_140(self): |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4778 source = UploadInstance(_REMOTE, 'Issue140.dcm') ['ID'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4779 series = DoGet(_REMOTE, '/instances/%s' % source) ['ParentSeries'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4780 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4781 target = DoPost(_REMOTE, '/series/%s/modify' % series, { |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4782 'Replace' : { 'RadioButton3' : 'aaabbbccc' } |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4783 }, 'application/json') ['ID'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4784 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4785 instances = DoGet(_REMOTE, '/series/%s/instances' % target) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4786 self.assertEqual(1, len(instances)) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4787 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4788 tags = DoGet(_REMOTE, '/instances/%s/tags' % source) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4789 t = tags['4321,1012'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4790 self.assertEqual('String', t['Type']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4791 self.assertEqual('RadioButton3', t['Name']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4792 self.assertEqual('RadioLogic', t['PrivateCreator']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4793 self.assertEqual('jklmopq', t['Value']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4794 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4795 tags = DoGet(_REMOTE, '/instances/%s/tags' % instances[0]['ID']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4796 t = tags['4321,1012'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4797 self.assertEqual('String', t['Type']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4798 self.assertEqual('RadioButton3', t['Name']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4799 self.assertEqual('RadioLogic', t['PrivateCreator']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4800 self.assertEqual('aaabbbccc', t['Value']) |
236
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4801 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4802 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4803 def test_find_normalize(self): |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4804 # https://groups.google.com/d/msg/orthanc-users/AIwooGjsh94/YL28MNY4AgAJ |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4805 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4806 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4807 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4808 a = DoPost(_REMOTE, '/modalities/self/query', { |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4809 'Level' : 'Instance', |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4810 'Query' : { 'Rows' : '42' } |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4811 }) ['ID'] |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4812 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4813 b = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4814 self.assertEqual(1, len(b)) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4815 self.assertFalse('Rows' in b[0]) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4816 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4817 a = DoPost(_REMOTE, '/modalities/self/query', { |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4818 'Level' : 'Instance', |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4819 'Query' : { 'Rows' : '42' }, |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4820 'Normalize' : False |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4821 }) ['ID'] |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4822 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4823 b = DoGet(_REMOTE, '/queries/%s/answers' % a) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4824 self.assertEqual(0, len(b)) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4825 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4826 a = DoPost(_REMOTE, '/modalities/self/query', { |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4827 'Level' : 'Instance', |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4828 'Query' : { 'Rows' : '512' }, |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4829 'Normalize' : False |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4830 }) ['ID'] |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4831 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4832 b = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4833 self.assertEqual(1, len(b)) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4834 self.assertTrue('Rows' in b[0]) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
4835 self.assertEqual('512', b[0]['Rows']) |
237 | 4836 |
4837 a = DoPost(_REMOTE, '/modalities/self/query', { | |
4838 'Level' : 'Instance', | |
4839 'Query' : { 'Rows' : '' }, | |
4840 'Normalize' : False | |
4841 }) ['ID'] | |
4842 | |
4843 b = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) | |
4844 self.assertEqual(1, len(b)) | |
4845 self.assertTrue('Rows' in b[0]) | |
4846 self.assertEqual('512', b[0]['Rows']) | |
4847 | |
4848 self.assertRaises(Exception, lambda: DoPost( | |
4849 _REMOTE, '/modalities/self/query', { | |
4850 'Level' : 'Instance', | |
4851 'Query' : { 'Rows' : '*' }, # Out-of-range value | |
4852 'Normalize' : False | |
4853 })) | |
243
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4854 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4855 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4856 def test_bitbucket_issue_141(self): |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4857 # https://bitbucket.org/sjodogne/orthanc/issues/141/ |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4858 a = UploadInstance(_REMOTE, 'Issue141.dcm') ['ID'] |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4859 study = '494c8037-b237f263-d8f15075-c8cb2280-daf39bd1' |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4860 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4861 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4862 pdf = f.read() |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4863 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4864 b = DoPost(_REMOTE, '/tools/create-dicom', { |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4865 'Parent' : study, |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4866 'Tags' : {}, |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4867 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4868 }) ['ID'] |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4869 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4870 tagsA = DoGet(_REMOTE, '/instances/%s/tags?short' % a) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4871 tagsB = DoGet(_REMOTE, '/instances/%s/tags?short' % b) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4872 self.assertEqual(tagsA['0008,0005'], tagsB['0008,0005']) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
4873 self.assertEqual(tagsA['0008,1030'], tagsB['0008,1030']) |
247
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4874 |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4875 |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4876 def test_modifying_missing_patientid(self): |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4877 # https://groups.google.com/d/msg/orthanc-users/aphG_h1AHVg/rfOTtTPTAgAJ |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4878 UploadInstance(_REMOTE, '2019-06-17-VedranZdesic.dcm') |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
4879 DoPost(_REMOTE, '/studies/0c4aca1d-c107a241-6659d6aa-594c674a-a468b94a/modify', {}) |
262 | 4880 |
4881 | |
4882 def test_log_level(self): | |
4883 # https://bitbucket.org/sjodogne/orthanc/issues/65/ | |
4884 original = DoGet(_REMOTE, '/tools/log-level') | |
4885 | |
4886 DoPut(_REMOTE, '/tools/log-level', 'default') | |
4887 self.assertEqual('default', DoGet(_REMOTE, '/tools/log-level')) | |
4888 DoGet(_REMOTE, '/system') | |
4889 | |
4890 DoPut(_REMOTE, '/tools/log-level', 'verbose') | |
4891 self.assertEqual('verbose', DoGet(_REMOTE, '/tools/log-level')) | |
4892 DoGet(_REMOTE, '/system') | |
4893 | |
4894 DoPut(_REMOTE, '/tools/log-level', 'trace') | |
4895 self.assertEqual('trace', DoGet(_REMOTE, '/tools/log-level')) | |
4896 DoGet(_REMOTE, '/system') | |
4897 | |
4898 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/log-level', 'nope')) | |
4899 | |
4900 # Switch back to the original log level | |
4901 DoPut(_REMOTE, '/tools/log-level', original) | |
264
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4902 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4903 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4904 def test_upload_compressed(self): |
265 | 4905 # New in Orthanc 1.6.0 |
264
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4906 with open(GetDatabasePath('DummyCT.dcm.gz'), 'rb') as f: |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4907 d = f.read() |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4908 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4909 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/instances', d, 'application/dicom')) |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4910 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4911 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/instances', d, 'application/dicom', |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4912 headers = { 'Content-Encoding' : 'nope' })) |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4913 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4914 a = DoPost(_REMOTE, '/instances', d, 'application/dicom', |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4915 headers = { 'Content-Encoding' : 'gzip' }) |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
4916 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a['ID']) |
262 | 4917 |
4918 | |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4919 def test_study_series_find_inconsistency(self): |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4920 # https://groups.google.com/forum/#!topic/orthanc-users/bLv6Z11COy0 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4921 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4922 def CountAnswers(query): |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4923 a = DoPost(_REMOTE, 'modalities/self/query', query) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4924 return len(DoGet(_REMOTE, '%s/answers' % a['Path'])) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4925 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4926 # This instance has "SeriesDescription" (0008,103e) tag, but no |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4927 # "ProtocolName" (0018,1030). Both of those tags are part of |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4928 # the "main DICOM tags" of Orthanc. |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4929 UploadInstance(_REMOTE, 'Issue137.dcm') |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4930 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4931 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4932 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4933 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4934 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4935 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4936 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4937 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4938 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4939 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4940 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4941 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4942 ## "SeriesDescription" is present, and has VR "CS" => wildcard is allowed |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4943 ## http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.4.html |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4944 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4945 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4946 # At the study level, the "SeriesDescription" tag is not allowed, but |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4947 # is wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4948 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4949 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4950 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4951 'SeriesDescription' : 'NOPE' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4952 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4953 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4954 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4955 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4956 # This test fails on Orthanc <= 1.5.8 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4957 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4958 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4959 'SeriesDescription' : '*' # Wildcard matching => no match, as the tag is absent |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4960 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4961 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4962 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4963 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4964 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4965 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4966 'SeriesDescription' : 'THIS^VALUE^IS^WIPED^OUT' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4967 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4968 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4969 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4970 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4971 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4972 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4973 'SeriesDescription' : '*' # Matches, as wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4974 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4975 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4976 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4977 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4978 for normalize in [ True, False ]: |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4979 # At the series level, the "SeriesDescription" tag is allowed, and |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4980 # normalization has no effect |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4981 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4982 # "Universal matching" will match all entities, including |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4983 # those with the missing tag |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4984 # http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.3.html |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4985 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4986 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4987 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4988 'SeriesDescription' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4989 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4990 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4991 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4992 # "Universal matching" will match all entities, including |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4993 # those with the missing tag |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4994 # http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.3.html |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4995 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4996 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4997 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4998 'SeriesDescription' : '*' # Wildcard matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
4999 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5000 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5001 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5002 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5003 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5004 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5005 'SeriesDescription' : '*model*' # The actual value is "STL model: intraop Report" |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5006 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5007 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5008 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5009 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5010 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5011 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5012 'SeriesDescription' : '*MISMATCHED^VALUE*' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5013 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5014 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5015 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5016 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5017 # Universal matching matches any instance, even if the |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5018 # query is at the study-level, and thus if "SeriesDescription" |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5019 # makes no sense |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5020 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5021 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5022 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5023 'SeriesDescription' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5024 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5025 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5026 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5027 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5028 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5029 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5030 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5031 ## "ProtocolName" is absent, and has VR "CS" => wildcard is allowed |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5032 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5033 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5034 # At the study level, the "ProtocolName" tag is not allowed, but |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5035 # is wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5036 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5037 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5038 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5039 'ProtocolName' : 'NOPE' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5040 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5041 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5042 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5043 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5044 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5045 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5046 'ProtocolName' : '*' # Wildcard matching => no match, as the tag is absent |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5047 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5048 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5049 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5050 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5051 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5052 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5053 'ProtocolName' : 'THIS^VALUE^IS^WIPED^OUT' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5054 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5055 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5056 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5057 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5058 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5059 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5060 'ProtocolName' : '*' # Matches, as wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5061 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5062 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5063 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5064 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5065 for normalize in [ True, False ]: |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5066 # At the series level, the "ProtocolName" tag is allowed, and |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5067 # normalization has no effect |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5068 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5069 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5070 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5071 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5072 'ProtocolName' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5073 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5074 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5075 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5076 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5077 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5078 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5079 'ProtocolName' : '*' # Wildcard matching => no match, as the tag is absent |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5080 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5081 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5082 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5083 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5084 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5085 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5086 'ProtocolName' : '*MISMATCHED^VALUE*' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5087 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5088 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5089 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5090 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5091 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5092 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5093 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5094 'ProtocolName' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5095 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5096 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5097 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5098 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5099 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5100 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5101 ## "StudyInstanceUID" is present, and has VR "UI" => wildcard is not allowed |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5102 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5103 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5104 for level in [ 'Study', 'Series' ] : |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5105 for normalize in [ True, False ]: |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5106 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5107 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5108 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5109 'StudyInstanceUID' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5110 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5111 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5112 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5113 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5114 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5115 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5116 'StudyInstanceUID' : 'MISMATCHED^VALUE' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5117 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5118 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5119 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5120 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5121 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5122 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5123 'StudyInstanceUID' : '4.5.6' # This is the actual value |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5124 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5125 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5126 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5127 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5128 # This test fails on Orthanc <= 1.5.8 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5129 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5130 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5131 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5132 'StudyInstanceUID' : '*' # Wildcard matching not allowed for this VR |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5133 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5134 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5135 })) |
265 | 5136 |
5137 | |
5138 def test_rendered(self): | |
5139 # New in Orthanc 1.6.0 | |
5140 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
5141 im = GetImage(_REMOTE, '/instances/%s/rendered' % i) | |
5142 self.assertEqual("RGB", im.mode) | |
5143 self.assertEqual(41, im.size[0]) | |
5144 self.assertEqual(41, im.size[1]) | |
5145 | |
5146 # http://effbot.org/zone/pil-comparing-images.htm | |
5147 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) | |
5148 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) | |
5149 | |
5150 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10' % i) | |
5151 self.assertEqual("RGB", im.mode) | |
5152 self.assertEqual(10, im.size[0]) | |
5153 self.assertEqual(10, im.size[1]) | |
5154 | |
5155 im = GetImage(_REMOTE, '/instances/%s/rendered?height=10' % i) | |
5156 self.assertEqual("RGB", im.mode) | |
5157 self.assertEqual(10, im.size[0]) | |
5158 self.assertEqual(10, im.size[1]) | |
5159 | |
5160 im = GetImage(_REMOTE, '/instances/%s/rendered?height=128' % i) | |
5161 self.assertEqual("RGB", im.mode) | |
5162 self.assertEqual(128, im.size[0]) | |
5163 self.assertEqual(128, im.size[1]) | |
5164 | |
5165 im = GetImage(_REMOTE, '/instances/%s/rendered?height=10&smooth=0' % i) | |
5166 self.assertEqual("RGB", im.mode) | |
5167 self.assertEqual(10, im.size[0]) | |
5168 self.assertEqual(10, im.size[1]) | |
5169 | |
5170 im = GetImage(_REMOTE, '/instances/%s/rendered?height=10&smooth=1' % i) | |
5171 self.assertEqual("RGB", im.mode) | |
5172 self.assertEqual(10, im.size[0]) | |
5173 self.assertEqual(10, im.size[1]) | |
5174 | |
5175 im = GetImage(_REMOTE, '/instances/%s/rendered?height=5&width=10' % i) | |
5176 self.assertEqual("RGB", im.mode) | |
5177 self.assertEqual(5, im.size[0]) | |
5178 self.assertEqual(5, im.size[1]) | |
5179 | |
5180 | |
5181 # Grayscale image | |
5182 i = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
5183 im = GetImage(_REMOTE, '/instances/%s/rendered' % i) | |
5184 self.assertEqual("L", im.mode) | |
5185 self.assertEqual(288, im.size[0]) | |
5186 self.assertEqual(288, im.size[1]) | |
5187 self.assertEqual(0, im.getpixel((0, 0))) | |
5188 | |
5189 # Those are the original windowing parameters that are written | |
5190 # inside the DICOM file | |
5191 im2 = GetImage(_REMOTE, '/instances/%s/rendered?window-center=248.009544468547&window-width=431.351843817788' % i) | |
5192 self.assertEqual("L", im2.mode) | |
5193 self.assertEqual(288, im2.size[0]) | |
5194 self.assertEqual(288, im2.size[1]) | |
5195 self.assertTrue(ImageChops.difference(im, im2).getbbox() is None) | |
5196 | |
5197 im = GetImage(_REMOTE, '/instances/%s/rendered?width=512&smooth=0' % i) | |
5198 self.assertEqual("L", im.mode) | |
5199 self.assertEqual(512, im.size[0]) | |
5200 self.assertEqual(512, im.size[1]) | |
5201 | |
5202 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10&smooth=0' % i) | |
5203 self.assertEqual("L", im.mode) | |
5204 self.assertEqual(10, im.size[0]) | |
5205 self.assertEqual(10, im.size[1]) | |
5206 | |
5207 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10&smooth=1' % i) | |
5208 self.assertEqual("L", im.mode) | |
5209 self.assertEqual(10, im.size[0]) | |
5210 self.assertEqual(10, im.size[1]) | |
5211 | |
5212 im = GetImage(_REMOTE, '/instances/%s/rendered?width=1&window-center=-1000' % i) | |
5213 self.assertEqual("L", im.mode) | |
5214 self.assertEqual(1, im.size[0]) | |
5215 self.assertEqual(1, im.size[1]) | |
5216 self.assertEqual(255, im.getpixel((0, 0))) | |
5217 | |
5218 im = GetImage(_REMOTE, '/instances/%s/rendered?width=1&window-center=1000' % i) | |
5219 self.assertEqual("L", im.mode) | |
5220 self.assertEqual(1, im.size[0]) | |
5221 self.assertEqual(1, im.size[1]) | |
5222 self.assertEqual(0, im.getpixel((0, 0))) | |
5223 | |
5224 | |
5225 # Test monochrome 1 | |
5226 i = UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm')['ID'] | |
5227 im = GetImage(_REMOTE, '/instances/%s/rendered' % i) | |
5228 self.assertEqual("L", im.mode) | |
5229 self.assertEqual(2010, im.size[0]) | |
5230 self.assertEqual(2446, im.size[1]) | |
5231 self.assertEqual(0, im.getpixel((0, 0))) | |
5232 im = GetImage(_REMOTE, '/instances/%s/rendered?width=20' % i) | |
5233 self.assertEqual("L", im.mode) | |
5234 self.assertEqual(20, im.size[0]) | |
5235 self.assertEqual(24, im.size[1]) | |
5236 im = GetImage(_REMOTE, '/instances/%s/rendered?height=24' % i) | |
5237 self.assertEqual("L", im.mode) | |
5238 self.assertEqual(20, im.size[0]) | |
5239 self.assertEqual(24, im.size[1]) | |
5240 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10&height=24' % i) | |
5241 self.assertEqual("L", im.mode) | |
5242 self.assertEqual(10, im.size[0]) | |
5243 self.assertEqual(12, im.size[1]) | |
5244 im = GetImage(_REMOTE, '/instances/%s/rendered?width=40&height=24' % i) | |
5245 self.assertEqual("L", im.mode) | |
5246 self.assertEqual(20, im.size[0]) | |
5247 self.assertEqual(24, im.size[1]) |