Pynetdicom C-GET schlägt fehl, wenn mehrere Übertragungssyntaxen für komprimierte Bilder angefordert werdenPython

Python-Programme
Anonymous
 Pynetdicom C-GET schlägt fehl, wenn mehrere Übertragungssyntaxen für komprimierte Bilder angefordert werden

Post by Anonymous »

Ich implementieren eine C-GET-SCU mit pynetdicom, um CT-Bilder abzurufen. Beim Abrufen von CT-DICOM-Bildern mit der Übertragungssyntax „JPEG-LS Lossless Image Compression“ zeigen die SCP-Protokolle den folgenden Fehler.

Code: Select all

E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
W: C-STORE sub-operation failed.
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
I: Get SCP: Received Store SCP response (Failure)
D: ========================== OUTGOING DIMSE MESSAGE ==========================
D: Message Type                  : C-GET RSP
D: Message ID Being Responded To : 1
D: Affected SOP Class UID        : Study Root Query/Retrieve Information Model - GET
D: Identifier                    : None
D: Status                        : 0xFF00
D: ============================ END DIMSE MESSAGE =============================
I: Get SCP Response 260: 0xFF00 (Pending)
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
W: C-STORE sub-operation failed.
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
I: Get SCP: Received Store SCP response (Failure)
D: ========================== OUTGOING DIMSE MESSAGE ==========================
D: Message Type                  : C-GET RSP
D: Message ID Being Responded To : 1
D: Affected SOP Class UID        : Study Root Query/Retrieve Information Model - GET
D: Identifier                    : None
D: Status                        : 0xFF00
D: ============================ END DIMSE MESSAGE =============================
I: Get SCP Response 261: 0xFF00 (Pending)
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
W: C-STORE sub-operation failed.
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
I: Get SCP: Received Store SCP response (Failure)
D: ========================== OUTGOING DIMSE MESSAGE ==========================
D: Message Type                  : C-GET RSP
D: Message ID Being Responded To : 1
D: Affected SOP Class UID        : Study Root Query/Retrieve Information Model - GET
D: Identifier                    : None
D: Status                        : 0xFF00
D: ============================ END DIMSE MESSAGE =============================
I: Get SCP Response 262: 0xFF00 (Pending)
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
W: C-STORE sub-operation failed.
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
I: Get SCP: Received Store SCP response (Failure)
D: ========================== OUTGOING DIMSE MESSAGE ==========================
D: Message Type                  : C-GET RSP
D: Message ID Being Responded To : 1
D: Affected SOP Class UID        : Study Root Query/Retrieve Information Model - GET
D: Identifier                    : None
D: Status                        : 0xFF00
D: ============================ END DIMSE MESSAGE =============================
I: Get SCP Response 263: 0xFF00 (Pending)
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
W: C-STORE sub-operation failed.
E: No presentation context for 'CT Image Storage' has been accepted by the peer with 'JPEG-LS Lossless Image Compression' transfer syntax for the SCU role
I: Get SCP:  Received Store SCP response (Failure)
Dies wiederholt sich für jede C-STORE-Unteroperation während des C-GET.
Meine C-GET SCU-Implementierung folgt,

Code: Select all

from pydicom.dataset import Dataset
from pynetdicom import AE, evt, build_role, StoragePresentationContexts, debug_logger
from pynetdicom.sop_class import (
StudyRootQueryRetrieveInformationModelGet, CTImageStorage
)
import os
from datetime import datetime
from pydicom.uid import JPEGLSLossless, JPEG2000Lossless, JPEG2000, JPEGLSLossy

debug_logger()

def handle_store_simple(event):
"""Simplified handler - all files in data/ folder"""
os.makedirs('data', exist_ok=True)

ds = event.dataset
ds.file_meta = event.file_meta

# Generate timestamp-based filename
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S_%f')[:-3]
sop_instance_uid = ds.SOPInstanceUID if 'SOPInstanceUID' in ds else timestamp

filepath = os.path.join('data', f"{sop_instance_uid}.dcm")

ds.save_as(filepath, write_like_original=False)
print(f"Saved: {filepath}")
return 0x0000

handlers = [(evt.EVT_C_STORE, handle_store_simple)]

# Initialise the Application Entity (our client) note ip is auto assigned by TCP
ae = AE()
ae.ae_title = 'My_SCU'  # Set our client's AE title

ae.requested_contexts.extend(StoragePresentationContexts[:123])

# Create an SCP/SCU Role Selection Negotiation item for CT Image Storage
roles = [build_role(ctx.abstract_syntax, scp_role=True, scu_role=True) for ctx in StoragePresentationContexts]

# Adding presentation context with compressed transfer syntaxes
ae.add_requested_context(CTImageStorage, [JPEG2000Lossless, JPEGLSLossless, JPEG2000, JPEGLSLossy])

# Add the C-GET SCU presentation context
ae.add_requested_context(StudyRootQueryRetrieveInformationModelGet)

ds = Dataset()
ds.QueryRetrieveLevel = 'STUDY'
ds.StudyInstanceUID = '1.2.840.113619.2.415.3.2831182592.624.1738073045.897'

assoc = ae.associate('192.168.10.24', 9999, ae_title='Default', ext_neg=roles, evt_handlers=handlers)

if assoc.is_established:
print("Association established successfully.")
# The 'responses' generator will yield the status from the SCP's C-STORE sub-operations
# - StudyRootQueryRetrieveInformationModelGet: Query/Retrieve Information Model
responses = assoc.send_c_get(ds, StudyRootQueryRetrieveInformationModelGet)
for (status, identifier) in responses:
if status:
print(f"C-GET query status: 0x{status.Status:04x}")

if status.Status in [0xFF00]:  # Success or pending
print(f"Status - {status.Status}")

else:
print('Connection timed out, was aborted or received invalid response')

# Release the association
assoc.release()
Das Problem besteht darin, dass der SCP keinen akzeptierten Präsentationskontext für komprimierte Dicom-Bilder findet, wenn ich mehrere komprimierte Übertragungssyntaxen in einem einzelnen Präsentationskontext hinzufüge.

Code: Select all

ae.add_requested_context(CTImageStorage, [JPEG2000Lossless, JPEGLSLossless, JPEG2000, JPEGLSLossy])
Wenn ich jedoch stattdessen eine Übertragungssyntax pro Präsentationskontext hinzufüge, werden alle CT-Bilder erfolgreich abgerufen.

Code: Select all

# Adding one compressed transfer syntax at a time
ae.add_requested_context(CTImageStorage, [JPEGLSLossless])
ae.add_requested_context(CTImageStorage, [JPEG2000Lossless])
ae.add_requested_context(CTImageStorage, [JPEG2000])
ae.add_requested_context(CTImageStorage, [JPEGLSLossy])
Warum funktioniert das Anfordern mehrerer Übertragungssyntaxen in einer einzelnen Präsentation nicht? Die Dokumentation ermöglicht das Hinzufügen mehrerer Übertragungssyntaxen pro Präsentationskontext mit ApplicationEntity.add_requested_context

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post