comparison Sphinx/source/plugins/python/pydicom.py @ 703:a589668768d7

moving python samples in separate files (2)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 Jun 2021 10:07:12 +0200
parents
children
comparison
equal deleted inserted replaced
702:6e02cd89eb6a 703:a589668768d7
1 import io
2 import orthanc
3 import pydicom
4
5 def DecodeInstance(output, uri, **request):
6 if request['method'] == 'GET':
7 # Retrieve the instance ID from the regular expression (*)
8 instanceId = request['groups'][0]
9 # Get the content of the DICOM file
10 f = orthanc.GetDicomForInstance(instanceId)
11 # Parse it using pydicom
12 dicom = pydicom.dcmread(io.BytesIO(f))
13 # Return a string representation the dataset to the caller
14 output.AnswerBuffer(str(dicom), 'text/plain')
15 else:
16 output.SendMethodNotAllowed('GET')
17
18 orthanc.RegisterRestCallback('/pydicom/(.*)', DecodeInstance) # (*)