Search code examples
pythondicompydicom

Unable to access PACS using pynetdicom3


I'm trying to connect to a PACS server using Python (specifically pynetdicom3), however I'm unable to do so using the method specified in the documentation. I am able to access this server using dcm4che. E.g. running findscu -c AETitle@serverIP:port on the command line works (when run from the dcm4che folder).

However, when I try to connect to the server with pynetdicom3 using the code from the docs (slightly modified of course), I get an error regarding the "called AE title". This is the code:

from pynetdicom3 import AE, VerificationSOPClass

ae = AE(ae_title='AETitle',
        port=port,
        scu_sop_class=[VerificationSOPClass])

assoc = ae.associate(serverIP, port)

if assoc.is_established:
    print('Connection established')

Where AETitle, port, and serverIP are the same as the ones I use to access the server in dcm4che, provided by the administrator.

This is the error:

E: Association Rejected:
E: Result: Rejected Permanent, Source: Service User
E: Reason: Called AE title not recognised

The output from running the dcm4che command specifies that the "called AE title" is the same as the one I've used in the command and code. Is this the correct way to specify AE title in pynetdicom3, and if not, what is?


Solution

  • You are currently defining the local Application Entity, i.e. your own python code with the AE title "AETitle".

    In basic terms your application at the moment is saying "I am AETitle", not "I want to talk to AETitle" as it should, because the server is not recognising the called AE title.

    You have to add the called AE title as a third argument on your association method call.

    assoc = ae.associate(serverIP, port, "AEtitle")
    

    Otherwise pynetdicom3 will use some kind of internal default or empty value for the called AE title.