Sending DICOM from workstation to DICOM Server

Dear all,

I’m new starter about ORTHANC and DICOM server that is why I need some help.

I’ve generated new dicom to send DICOM server via below python script. I’ve faced some issues.

On the other hand, while I’m sending the original CT dicom to same DICOM Server I’ve been succesfully completed.

Kindly provide any suggestion, if I’m missing something.

Python Code

from pydicom import dcmread
from pynetdicom import AE, StoragePresentationContexts, build_role
from pynetdicom.pdu_primitives import SCP_SCU_RoleSelectionNegotiation
from pynetdicom.sop_class import (
    PatientRootQueryRetrieveInformationModelFind,
    PatientRootQueryRetrieveInformationModelGet,
    ProtocolApprovalInformationModelGet,
    CTImageStorage,
    StudyRootQueryRetrieveInformationModelGet,
    MRImageStorage,
    StudyRootQueryRetrieveInformationModelMove,
    PatientRootQueryRetrieveInformationModelMove,
    CompositeInstanceRetrieveWithoutBulkDataGet,
    XRayAngiographicImageStorage,
    Verification
    )


def dicomSend(path_img):

    ae = AE(ae_title='TEST')
    aeIP = 'ip_addrr'
    aePORT = 4242
    ae.requested_contexts = StoragePresentationContexts
    role = SCP_SCU_RoleSelectionNegotiation()
    role.sop_class_uid = CTImageStorage
    role.scu_role = True
    role.scp_role = True

    assoc = ae.associate(aeIP, aePORT, ext_neg=[role], ae_title='TEST')
    if assoc.is_established:
        ds = dcmread(path_img, force=True)
        status = assoc.send_c_store(ds)
        if status:
            print('C-STORE request status: 0x{0:04x}'.format(status.Status))
        else:
            print('Connection timed out, was aborted or received invalid response')

        assoc.release()
    print(f'Image transfer completed!')


if __name__ == '__main__':
    # dicomSend("/home/user/Desktop/generatedDicom/generated.dcm") # generated dicom
    # dicomSend("/home/user/Desktop/originalDicom/original_ct.dcm") # original CT

Error Message
While I’m sending the generated dicom, I’ve got below error;

ValueError: No presentation context for ‘CT Image Storage’ has been accepted by the peer with ‘JPEG 2000 Image Compression’ transfer syntax for the SCU role

Orthanc Configuration

{
  "Name" : "ORTHANC",
  "StorageDirectory" : "/var/lib/orthanc/db",
  "IndexDirectory" : "/var/lib/orthanc/db",
  "StorageCompression" : true,
  "MaximumStorageSize" : 0,
  "MaximumPatientCount" : 0,
  "LuaScripts" : [
  ],
  "Plugins" : [
    "/usr/share/orthanc/plugins", 
    "/usr/local/share/orthanc/plugins"
  ],
  "PythonScript" : "/etc/orthanc/sample.py",
  "PythonVerbose" : false,
  "ConcurrentJobs" : 2,
  "HttpServerEnabled" : true,
  "OrthancExplorerEnabled" : true,
  "HttpPort" : 8042,
  "HttpDescribeErrors" : true,
  "HttpCompressionEnabled" : true,
  "WebDavEnabled" : true,
  "WebDavDeleteAllowed" : false,
  "WebDavUploadAllowed" : true,
  "DicomServerEnabled" : true,
  "DicomAet" : "ORTHANC",
  "DicomCheckCalledAet" : true,
  "DicomPort" : 4242,
  "DefaultEncoding" : "Latin1",
  "DeflatedTransferSyntaxAccepted"     : true,
  "JpegTransferSyntaxAccepted"         : true,
  "Jpeg2000TransferSyntaxAccepted"     : true,
  "JpegLosslessTransferSyntaxAccepted" : true,
  "JpipTransferSyntaxAccepted"         : true,
  "Mpeg2TransferSyntaxAccepted"        : true,
  "RleTransferSyntaxAccepted"          : true,
  "AcceptedTransferSyntaxes" : [ "1.2.840.10008.1.*" ],
  //"AcceptedTransferSyntaxes" : [ "1.2.840.10008.1.2.4.91" ],
  "UnknownSopClassAccepted" : false,
  "DicomScpTimeout" : 30,
  "RemoteAccessAllowed" : true,
  "SslEnabled" : false,
  "SslCertificate" : "certificate.pem",
  "SslMinimumProtocolVersion" : 4,
  "SslVerifyPeers" : false,
  "SslTrustedClientCertificates" : "trustedClientCertificates.pem",
  "AuthenticationEnabled" : true,
  "RegisteredUsers" : {
    "alice" : "alicePassword"
  },
  "DicomTlsEnabled" : false,
  "DicomTlsRemoteCertificateRequired" : true,
  "DicomAlwaysAllowEcho" : true,
  "DicomAlwaysAllowStore" : true,
  "DicomAlwaysAllowFind" : false,
  "DicomAlwaysAllowFindWorklist" : false,
  "DicomAlwaysAllowGet" : false,
  "DicomAlwaysAllowMove" : false,
  "DicomCheckModalityHost" : true,
  "DicomModalities" : {
    "test" : [ "TEST", "xx.xxx.xx.xx", 4242]
  },
  "DicomModalitiesInDatabase" : false,
  //"DicomEchoChecksFind" : false,
  "DicomScuTimeout" : 10,
  "DicomScuPreferredTransferSyntax" : "1.2.840.10008.1.2.4.90",
  "DicomThreadsCount" : 4,
  "OrthancPeers" : {
  },
  "OrthancPeersInDatabase" : false,
  "HttpProxy" : "",
  "HttpVerbose" : false,
  "HttpTimeout" : 60,
  "HttpsVerifyPeers" : true,
  "HttpsCACertificates" : "/etc/ssl/certs/ca-certificates.crt",
  "UserMetadata" : {
    // "Sample" : 1024
  },
  "UserContentType" : {
    // "sample" : 1024
    // "sample2" : [ 1025, "application/pdf" ]
  },
  "StableAge" : 60,
  "StrictAetComparison" : false,
  "StoreMD5ForAttachments" : true,
  "LimitFindResults" : 0,
  "LimitFindInstances" : 0,
  //"LimitJobs" : 10,
  "LogExportedResources" : false,
  "KeepAlive" : true,
  "TcpNoDelay" : true,
  "HttpThreadsCount" : 50,
  "StoreDicom" : true,
  "DicomAssociationCloseDelay" : 5,
  "QueryRetrieveSize" : 100,
  "CaseSensitivePN" : false,
  "LoadPrivateDictionary" : true,
  // "Locale" : "en_US.UTF-8",
  "Dictionary" : {
  },
  "SynchronousCMove" : true,
  "JobsHistorySize" : 100,
  "SaveJobs" : true,
  "OverwriteInstances" : false,
  "MediaArchiveSize" : 1,
  "StorageAccessOnFind" : "Always",
  "MetricsEnabled" : true,
  "ExecuteLuaEnabled" : false,
  "HttpRequestTimeout" : 30,
  "DefaultPrivateCreator" : "",
  "StorageCommitmentReportsSize" : 100,
  "TranscodeDicomProtocol" : true,
  "BuiltinDecoderTranscoderOrder" : "After",
  "IngestTranscoding" : "1.2.840.10008.1.2.4.91",
  "IngestTranscodingOfUncompressed" : true,
  "IngestTranscodingOfCompressed" : true,
  "DicomLossyTranscodingQuality" : 90,
  "SyncStorageArea" : true,
  "MallocArenaMax" : 5,
  "DeidentifyLogs" : true,
  "DeidentifyLogsDicomVersion" : "2021b",
  "MaximumPduLength" : 16384,
  "CheckRevisions" : false,
  "SynchronousZipStream" : true,
  "ZipLoaderThreads": 0,
  "Warnings" : {
    "W001_TagsBeingReadFromStorage": true,
    "W002_InconsistentDicomTagsInDb": true
  }
}

Best regards,
Semih

Hello,

Have you tried uploading /home/user/Desktop/generatedDicom/generated.dcm to Orthanc through the GUI ? (or REST API) Does it work ?

You might want to check your DICOM file with dciodvfy. Maybe it’s not conformant? dciodvfy is part of the DCMTK package (for instance, sudo apt install dcmtk on Debian or Ubuntu).

If no errors are displayed and the file can be sent to Orthanc by other means, you might want to attempt a DICOM transfer with another DCMTK tool, with :

storescu -v -aet YOUR_AET -aec ORTHANC <ORTHANC IP> 4242 /home/user/Desktop/generatedDicom/generated.dcm

(not tested, so maybe a flag is missing, but you get the idea)

HTH

Hello @benjamin.golinvaux,

thank you for your kind response.

Yes, I’m able to do that through Orthanc and REST API.

After awhile I found that why I could not completed the sending generated dicom.

I was getting below error;

– ValueError: No presentation context for ‘CT Image Storage’ has been accepted by the peer with ‘JPEG 2000 Image Compression’ transfer syntax for the SCU role

and it’s related with the “Transfer Syntax UID”. When I changed the Transfer Sytanx UID type of generated dicom, the problem has solved.

TransferSyntaxUID = ExplicitVRLittleEndian

Best Regards,
Semih

1 Like