Pynetdicom C-GET завершается сбоем, когда для сжатых изображений запрашивается несколько синтаксисов передачиPython

Программы на Python
Ответить
Anonymous
 Pynetdicom C-GET завершается сбоем, когда для сжатых изображений запрашивается несколько синтаксисов передачи

Сообщение Anonymous »

Я реализую C-GET SCU, используя pynetdicom для получения изображений КТ. При получении изображений CT DICOM с синтаксисом передачи «Сжатие изображений без потерь JPEG-LS» в журналах SCP отображается следующая ошибка.

Код: Выделить всё

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)
Это повторяется для каждой подоперации C-STORE во время C-GET.
Моя реализация C-GET SCU следующая:

Код: Выделить всё

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()
Проблема в том, что если я добавлю несколько синтаксисов сжатой передачи в один контекст представления, SCP не сможет найти принятый контекст представления для сжатых изображений dicom.

Код: Выделить всё

ae.add_requested_context(CTImageStorage, [JPEG2000Lossless, JPEGLSLossless, JPEG2000, JPEGLSLossy])
Однако, если вместо этого я добавлю один синтаксис передачи для каждого контекста представления, все изображения CT будут успешно получены.

Код: Выделить всё

# 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])
Почему запрос нескольких синтаксисов передачи в одной презентации не работает? Документация позволяет добавлять несколько синтаксисов передачи для каждого контекста представления с помощью ApplicationEntity.add_requested_context

Подробнее здесь: https://stackoverflow.com/questions/798 ... or-compres
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»