Mercurial > hg > orthanc-stone
annotate OrthancStone/UnitTestsSources/SortedFramesCreateTest.py @ 2061:6ea5f40ea0e9 deep-learning
added ImageProcessingProgram
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 03 May 2023 16:34:34 +0200 |
parents | a2955abe4c2e |
children | 07964689cb0b |
rev | line source |
---|---|
1477 | 1 #!/usr/bin/env python |
2 | |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
3 # Stone of Orthanc |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
5 # Department, University Hospital of Liege, Belgium |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 # Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
7 # Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
8 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
9 # This program is free software: you can redistribute it and/or |
1877
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
10 # modify it under the terms of the GNU Lesser General Public License |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
11 # as published by the Free Software Foundation, either version 3 of |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
12 # the License, or (at your option) any later version. |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
13 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
14 # This program is distributed in the hope that it will be useful, but |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
15 # WITHOUT ANY WARRANTY; without even the implied warranty of |
1877
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
17 # Lesser General Public License for more details. |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
18 # |
1877
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
19 # You should have received a copy of the GNU Lesser General Public |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
20 # License along with this program. If not, see |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
21 # <http://www.gnu.org/licenses/>. |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
22 |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1587
diff
changeset
|
23 |
1477 | 24 import pprint |
25 import requests | |
26 import sys | |
27 | |
28 if len(sys.argv) != 2: | |
29 print('Usage: %s [Orthanc series ID]' % sys.argv[0]) | |
30 print('Example: %s 4d04593b-953ced51-87e93f11-ae4cf03c-25defdcd | xclip -selection c -t text/plain' % sys.argv[0]) | |
31 exit(-1) | |
32 | |
33 SERIES = sys.argv[1] | |
34 | |
35 r = requests.get('http://localhost:8042/series/%s/study' % SERIES) | |
36 r.raise_for_status() | |
37 print(' // From patient %s' % r.json() ['PatientMainDicomTags']['PatientName']) | |
38 | |
39 r = requests.get('http://localhost:8042/series/%s' % SERIES) | |
40 r.raise_for_status() | |
41 | |
42 first = True | |
43 | |
44 for instance in r.json() ['Instances']: | |
45 tags = requests.get('http://localhost:8042/instances/%s/tags?short' % instance) | |
46 tags.raise_for_status() | |
47 | |
48 if first: | |
49 print(''' | |
50 Orthanc::DicomMap tags; | |
51 tags.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, "%s", false); | |
52 tags.SetValue(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, "%s", false); | |
53 OrthancStone::SortedFrames f; | |
54 ''' % (tags.json() ['0020,000d'], tags.json() ['0020,000e'])) | |
55 first = False | |
56 | |
57 print(' tags.SetValue(Orthanc::DICOM_TAG_SOP_INSTANCE_UID, "%s", false);' % instance) | |
58 | |
59 if '0020,0032' in tags.json(): | |
60 print(' tags.SetValue(Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT, "%s", false);' % | |
61 tags.json() ['0020,0032'].replace('\\', '\\\\')) | |
62 | |
63 if '0020,0037' in tags.json(): | |
64 print(' tags.SetValue(Orthanc::DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "%s", false);' % | |
65 tags.json() ['0020,0037'].replace('\\', '\\\\')) | |
66 | |
67 if '0020,0013' in tags.json(): | |
68 print(' tags.SetValue(Orthanc::DICOM_TAG_INSTANCE_NUMBER, "%s", false);' % | |
69 tags.json() ['0020,0013'].replace('\\', '\\\\')) | |
70 | |
71 if '0054,1330' in tags.json(): | |
72 print(' tags.SetValue(Orthanc::DICOM_TAG_IMAGE_INDEX, "%s", false);' % | |
73 tags.json() ['0054,1330'].replace('\\', '\\\\')) | |
74 | |
75 print(' f.AddInstance(tags);') | |
76 | |
77 print(' f.Sort();') | |
78 | |
79 r = requests.get('http://localhost:8042/series/%s/ordered-slices' % SERIES) | |
80 r.raise_for_status() | |
81 slices = r.json() ['SlicesShort'] | |
82 | |
83 print(' ASSERT_EQ(%du, f.GetFramesCount());' % len(slices)) | |
84 | |
85 for i in range(len(slices)): | |
1644
4796fb60999e
removing methods from SortedFrames to simplify api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
86 print(' ASSERT_EQ(f.GetInstanceOfFrame(%d).GetSopInstanceUid(), "%s");' % (i, slices[i][0])) |
1477 | 87 |