annotate Sphinx/source/plugins/python/lookup-dictionary.py @ 927:dfe96daba4f8

python in win installer
author Alain Mazy <am@osimis.io>
date Wed, 29 Mar 2023 11:54:58 +0200
parents cd70d23f34bc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
708
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 import json
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 import orthanc
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # Create a dictionary mapping the numeric values in enumeration
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # "orthanc.ValueRepresentation" to the name of the corresponding VR
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 VR_NAMES = {}
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 for name in dir(orthanc.ValueRepresentation):
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 if not name.startswith('_'):
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 value = getattr(orthanc.ValueRepresentation, name)
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 VR_NAMES[value] = name
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 entry = orthanc.LookupDictionary('PatientID')
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 orthanc.LogWarning('Entry in the dictionary: %s' %
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 json.dumps(entry, indent = 4, sort_keys = True))
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 orthanc.LogWarning('Name of the value representation: %s' %
cd70d23f34bc Lookup DICOM dictionary in Python scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 VR_NAMES[entry['ValueRepresentation']])