Where to set "Move Storage port" in ctkDICOMRetrieve?

I am having problems implementing this code snippet for automatic data retrieval in our hospital network:

https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#query-and-retrieve-data-from-a-pacs-using-classic-dimse-dicom-networking

The code works well on my private laptop in a public network.

In the hospital I need to be able to set, besides the MoveDestinationAETitle, the StoragePort as in Slicers DICOM Query/Retrieve dialog here (11112)

image

The query works from the dialog window in hospital (using our local PACS access data), but access negotiations fail from the snippet. I think it is because the StoragePort needs to be defined in the python code because the PACS is configured to write to 11112

Any ideas ? Thank you !

Hi @rbumm -

Perhaps you have the same issue as discussed in this thread? @Amy_Morton also links to some documentation that helped explain the various requirements.

1 Like

Hi guys,

it turned out that setting the ā€œMove Storage Portā€ is not necessary but it was required to use setCallingAETitle, setCalledAETitle, setHost, setPort in the dicomRetrieve class to make this work with our GEPACS.

So I changed the code from the repository (@lassoan maybe update?) to:

# Query
dicomQuery = ctk.ctkDICOMQuery()
dicomQuery.callingAETitle = "SLICER"
dicomQuery.calledAETitle = "ANYAE"
dicomQuery.host = "dicomserver.co.uk"
dicomQuery.port = 11112
dicomQuery.preferCGET = True
dicomQuery.filters = {"Name":"Anon", "Modalities":"MR"}
# temporary in-memory database for storing query results
tempDb = ctk.ctkDICOMDatabase()
tempDb.openDatabase("")
dicomQuery.query(tempDb)

# Retrieve
dicomRetrieve = ctk.ctkDICOMRetrieve()
dicomRetrieve.setCallingAETitle(dicomQuery.callingAETitle)
dicomRetrieve.setCalledAETitle(dicomQuery.calledAETitle)
dicomRetrieve.setHost(dicomQuery.host)
dicomRetrieve.setPort(dicomQuery.port)
dicomRetrieve.setMoveDestinationAETitle("SLICER") 
dicomRetrieve.setDatabase(slicer.dicomDatabase)
for study in dicomQuery.studyInstanceUIDQueried:
  print(f"ctkDICOMRetrieveTest2: Retrieving {study}")
  slicer.app.processEvents()
  if dicomQuery.preferCGET:
    success = dicomRetrieve.getStudy(study)
  else:
    success = dicomRetrieve.moveStudy(study)
  print(f"  - {'success' if success else 'failed'}")
slicer.dicomDatabase.updateDisplayedFields()Ā“Ā“Ā“

and now this code works in the hospital setting.

On the dicomQuery side, a dicomQuery.setCallingAETitle seems not yet to be exposed to python and results in an error message.

Thanks for pointing out this inconsistency. The preferred way would be to use dicomRetrieve.callingAETitle = dicomQuery.callingAETitle since both classes have those values exposed as properties, but only ctkDICOMRetrieve exposes the Q_INVOKABLE versions. Probably at this point we should add Q_INVOKABLE to the corresponding methods in ctkDICOMQuery for consistency, but properties are usually better to use if where they exist.

The script repository does not need an update, there was just a copy-paste error in definition of the calledAETitle property in CTK: