pydicom / pynetdicom

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

How to Prioritize Transfer Syntaxes in Presentation Contexts #944

Closed Alceu-wv closed 1 month ago

Alceu-wv commented 2 months ago

Description:

I'm working with pynetdicom to manage presentation contexts during DICOM communication. While I can define the list of supported transfer syntaxes, it seems unclear how to explicitly prioritize specific syntaxes.

I intend to accept any transfer syntax but have priorities. E. g JPEG2000Lossless is best.

Attempted Solution:

I tried ordering the list of transfer syntaxes, placing the preferred syntax first. However, this approach didn't appear to influence the chosen syntax during negotiation.

Question:

Is there a recommended way to define the priority of transfer syntaxes within presentation contexts in pynetdicom?

Code Snipet

def get_AE(conf: Dict) -> AE:
    ae = AE()
    ae.ae_title = conf["aet"]
    ae.add_requested_context(StudyRootQueryRetrieveInformationModelFind)
    ae.add_requested_context(StudyRootQueryRetrieveInformationModelMove)

    transfer_syntaxes = [JPEG2000Lossless] + [ts for ts in ALL_TRANSFER_SYNTAXES if ts != JPEG2000Lossless]
    storage_sop_classes = [cx.abstract_syntax for cx in AllStoragePresentationContexts]
    for uid in storage_sop_classes:
        ae.add_supported_context(uid, transfer_syntaxes)

    return ae
scaramallion commented 2 months ago

If you're the one requesting the association then the decision on which transfer syntax to use is entirely up to the receiver.

You can however request multiple of the same abstract syntax, each with a different transfer syntax, e.g. CT with Explicit VR, CT with JPEG2000. If the receiver accepts both then you're free to use whichever of those you want.

ae.add_requested_content(CTImageStorage, ExplicitVRLittleEndian)
ae.add_requested_content(CTImageStorage, JPEG2000Lossless)

Keep in mind that you're limited to a maximum of 128 requested contexts overall.