How does the SCU receive dcm images from Dicom Server with C-GET?

2.1k views Asked by At

I've seen the official pynetdicom documentation but I've not got the proper event handlers (for the SCU) on receiving images.

First I've created the required .dcm files Dataset and used the C-GET command, which should actually give me the .dcm files but also I've not specified where my images are to be stored on the SCU. Do I need to use the C-MOVE command to actually get images or my code is incomplete (in a sense that no event handlers are specified for SCU onReceiveStore)?

from pydicom.dataset import Dataset
import pydicom

from pynetdicom import (
    AE, evt, build_role,
    PYNETDICOM_IMPLEMENTATION_UID,
    PYNETDICOM_IMPLEMENTATION_VERSION
)

from pynetdicom.sop_class import (
    PatientRootQueryRetrieveInformationModelGet,
    CTImageStorage
)


ae = AE()

ae.add_requested_context(PatientRootQueryRetrieveInformationModelGet)
ae.add_requested_context(CTImageStorage)

role = build_role(CTImageStorage, scp_role=True)

ds = Dataset()
ds.QueryRetrieveLevel = 'SERIES'
ds.PatientID = '0009703828'
ds.StudyInstanceUID = '1.3.46.670589.5.2.10.2156913941.892665384.993397'
ds.SeriesInstanceUID = '1.3.46.670589.5.2.10.2156913941.892665339.860724'

assoc = ae.associate('127.0.0.1', 5678)

if assoc.is_established:

responses = assoc.send_c_get(ds, PatientRootQueryRetrieveInformationModelGet)
for (status,dataset) in responses:
    if status:
        print('C-GET query status: 0x{0:04x}'.format(status.Status))
        # If the status is 'Pending' then `identifier` is the C-GET response
        if status.Status in (0x0000, 0x1022):
            print(dataset)
        else:
            print('Connection timed out, was aborted or received invalid response') 

    assoc.release()
else:
    print('Association rejected, aborted or never connected')

I expected the .dcm be sent from the DICOM server (i.e ConQuest server in my case) ,but I'm only receving the DICOM tag confirming that this Dataset (given as a query to the ConQuest Server) is present! I want to know exactly how do I receive the images on my SCU using this Application Entity (ae)

This is the response from the ConQuest Server

[CONQUESTSRV1] UPACS THREAD 11: STARTED AT: Fri Oct 25 06:56:23 2019
[CONQUESTSRV1]  Calling Application Title : "PYNETDICOM      "
[CONQUESTSRV1]  Called Application Title : "ANY-SCP         "
[CONQUESTSRV1]  Application Context : "1.2.840.10008.3.1.1.1", PDU length: 16382
[CONQUESTSRV1]  Presentation Context 0 "1.2.840.10008.5.1.4.1.2.1.3" 1
[CONQUESTSRV1]  Presentation Context 1 "1.2.840.10008.5.1.4.1.1.2" 1
[CONQUESTSRV1] Number of images to send: 2
[CONQUESTSRV1] Sending file : c:\users\sagar\onedrive\desktop\dicomserver1419d1\data\0009703828\1.3.46.670589.5.2.10.2156913941.892665339.860724_0001_002000_14579035620000.dcm
[CONQUESTSRV1] [recompress]: recompressed with mode = un (strip=1)
[CONQUESTSRV1] C-Get (PatientRoot)
[CONQUESTSRV1] UPACS THREAD 11: ENDED AT: Fri Oct 25 06:56:23 2019
[CONQUESTSRV1] UPACS THREAD 11: TOTAL RUNNING TIME: 0 SECONDS

The ConQuest Server is sending the file but the SCU is unable to receive it!

3

There are 3 answers

1
scaramallion On

You need to bind a callable handler function to evt.EVT_C_STORE as shown in this example.

0
Paolo Brandoli On

Both C-GET and C-MOVE will cause the SCP to send back to your device a C-STORE command containing the dataset.

The difference between C-GET and C-MOVE is that C-MOVE will try to open a connection back to your device (which has to act also as an SCP to receive the C-STORE) while C-GET will send the C-STORE on the same connection negotiated by your device.

The response for the C-GET and C-MOVE contains just the status of the operation.

0
Amit Joshi On

Do I need to use the C-MOVE command to actually get images

Yes; either of C-MOVE or C-GET will work without issue; which one to use depends on your requirements. C-MOVE will establish new connection (roles will be reversed) and instances will be sent on newly established connection. C-GET will work on same connection.

or my code is incomplete (in a sense that no event handlers are specified for SCU onReceiveStore)?

I do not know the programming language and the toolkit. So I may not comment on this.

I expected the .dcm be sent from the DICOM server (i.e ConQuest server in my case) ,but I'm only receving the DICOM tag confirming that this Dataset (given as a query to the ConQuest Server) is present!

Most probably, you are getting C-FIND response here. This does not contain image instance. Please refer to this answer for more details.

I want to know exactly how do I receive the images on my SCU using this Application Entity (ae)

On receiving C-FIND response, using the identifiers from it, you should further issue C-MOVE/C-GET command/request. In response to this request, you will get actual image instance. Your C-FIND SCU becomes C-STORE SCP here; generally called Role Reversal. Please refer to this answer for more details.

I also recommend you to read below articles from Roni: