Mercurial > hg > orthanc-book
view Sphinx/source/plugins/python/pydicom.py @ 1165:28b55ad71cb6 Orthanc-1.12.8
Orthanc 1.12.8
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Sat, 14 Jun 2025 17:53:22 +0200 |
| parents | a589668768d7 |
| children |
line wrap: on
line source
import io import orthanc import pydicom def DecodeInstance(output, uri, **request): if request['method'] == 'GET': # Retrieve the instance ID from the regular expression (*) instanceId = request['groups'][0] # Get the content of the DICOM file f = orthanc.GetDicomForInstance(instanceId) # Parse it using pydicom dicom = pydicom.dcmread(io.BytesIO(f)) # Return a string representation the dataset to the caller output.AnswerBuffer(str(dicom), 'text/plain') else: output.SendMethodNotAllowed('GET') orthanc.RegisterRestCallback('/pydicom/(.*)', DecodeInstance) # (*)
