pydicom / pynetdicom

A Python implementation of the DICOM networking protocol
https://pydicom.github.io/pynetdicom
MIT License
500 stars 176 forks source link

E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG 2000 Image Compression' transfer syntax for the SCU role #922

Closed jeevchiran closed 5 months ago

jeevchiran commented 5 months ago

Does anyone know how to resolve this issue, I'm trying to push all Dicom images to PACS from a directory, the dcm images have the transfer syntax (0002,0010) Transfer Syntax UID 1.2.840.10008.1.2.4.91 (JPEG 2000 Image Compression)

from pydicom import dcmread
import os
from pynetdicom import AE, debug_logger
from pynetdicom.sop_class import CTImageStorage
import argparse

def push_to_pacs(directory, pac_addr, pacs_port):

    debug_logger()
    ae = AE()
    ae.add_requested_context(CTImageStorage)
    assoc = ae.associate(pac_addr, pacs_port)

    if assoc.is_established:
        # Use the C-STORE service to send the dataset
        for _, _, files in os.walk(directory):
            for file in files:
                try:
                    ds = dcmread(os.path.join(directory, file))
                    status = assoc.send_c_store(ds)

                    # Check the status of the storage request
                    if status:
                        # If the storage request succeeded this will be 0x0000
                        print("C-STORE request status: 0x{0:04x}".format(status.Status))
                    else:
                        print(
                            "Connection timed out, was aborted or received invalid response"
                        )
                except Exception as ex:
                    print(ex)

        # Release the association
        assoc.release()
    else:
        print("Association rejected, aborted or never connected")

if __name__ == "__main__":t
    parser = argparse.ArgumentParser(description="Process a directory.")
    parser.add_argument("--directory", required=True, help="Path to the directory")
    args = parser.parse_args()
    directory_path = args.directory

    push_to_pacs(
        directory=directory_path,
        pac_addr="localhost",
        pacs_port=8050,
    )

Any possible workaround?

debug logs

I: Requesting Association
D: Request Parameters:
D: ======================= OUTGOING A-ASSOCIATE-RQ PDU ========================
D: Our Implementation Class UID:      1.2.826.0.1.3680043.9.3811.2.0.2
D: Our Implementation Version Name:   PYNETDICOM_202
D: Application Context Name:    1.2.840.10008.3.1.1.1
D: Calling Application Name:    PYNETDICOM
D: Called Application Name:     ANY-SCP
D: Our Max PDU Receive Size:    16382
D: Presentation Context:
D:   Context ID:        1 (Proposed)
D:     Abstract Syntax: =CT Image Storage
D:     Proposed SCP/SCU Role: Default
D:     Proposed Transfer Syntaxes:
D:       =Implicit VR Little Endian
D:       =Explicit VR Little Endian
D:       =Deflated Explicit VR Little Endian
D:       =Explicit VR Big Endian
D: Requested Extended Negotiation: None
D: Requested Common Extended Negotiation: None
D: Requested Asynchronous Operations Window Negotiation: None
D: Requested User Identity Negotiation: None
D: ========================== END A-ASSOCIATE-RQ PDU ==========================
D: Accept Parameters:
D: ======================= INCOMING A-ASSOCIATE-AC PDU ========================
D: Their Implementation Class UID:    1.2.826.0.1.3680043.9.3811.2.0.2
D: Their Implementation Version Name: PYNETDICOM_202
D: Application Context Name:    1.2.840.10008.3.1.1.1
D: Calling Application Name:    PYNETDICOM
D: Called Application Name:     ANY-SCP
D: Their Max PDU Receive Size:  0
D: Presentation Contexts:
D:   Context ID:        1 (Accepted)
D:     Abstract Syntax: =CT Image Storage
D:     Accepted SCP/SCU Role: Default
D:     Accepted Transfer Syntax: =Implicit VR Little Endian
D: Accepted Extended Negotiation: None
D: Accepted Asynchronous Operations Window Negotiation: None
D: User Identity Negotiation Response: None
D: ========================== END A-ASSOCIATE-AC PDU ==========================
I: Association Accepted
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG 2000 Image Compression' transfer syntax for the SCU role
No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG 2000 Image Compression' transfer syntax for the SCU role
I: Releasing Association
scaramallion commented 5 months ago

D: Accepted Transfer Syntax: =Implicit VR Little Endian

You need to add CT Image Storage as a requested context with a matching transfer syntax (i.e. JPEG 2000). AE.add_requested_context() defaults to the native transfer syntaxes only. This is all explained in the user guide.

jeevchiran commented 5 months ago

thanks, had to add the following transfer syntax

ae.add_requested_context(CTImageStorage, JPEG2000)