# Where to set "Move Storage port" in ctkDICOMRetrieve?

**URL:** <https://discourse.slicer.org/t/where-to-set-move-storage-port-in-ctkdicomretrieve/18915>\
**Category:** Support\
**Created:** [July 25, 2021, 10:56am UTC](https://discourse.slicer.org/t/where-to-set-move-storage-port-in-ctkdicomretrieve/18915 "2021-07-25T10:56:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [July 25, 2021, 10:56am UTC](https://discourse.slicer.org/t/where-to-set-move-storage-port-in-ctkdicomretrieve/18915/1 "2021-07-25T10:56:06Z")

</div>

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](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](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/0/e0b987f842e15792cee71ec7ab32bc519c5f5385.png)

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 !

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 25, 2021, 7:28pm UTC](https://discourse.slicer.org/t/where-to-set-move-storage-port-in-ctkdicomretrieve/18915/2 "2021-07-25T19:28:33Z")

</div>

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.

> [@Configuration of the 3D Slicer DICOM Listener to Hospital CT](https://discourse.slicer.org/t/configuration-of-the-3d-slicer-dicom-listener-to-hospital-ct/13754):
>
> Operating system: Win 10 Slicer version: 4.10.2 Expected behavior: a dialog with accessible port configurations Actual behavior: none found Beyond the ‘Start Listener’ button in the DICOM module, I cannot configure the listener such that datasets can be pushed to my PC from the the hospital CT scanner (same LAN).

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [July 28, 2021, 4:29pm UTC](https://discourse.slicer.org/t/where-to-set-move-storage-port-in-ctkdicomretrieve/18915/3 "2021-07-28T16:29:12Z")

</div>

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:

```auto
# 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.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 28, 2021, 9:22pm UTC](https://discourse.slicer.org/t/where-to-set-move-storage-port-in-ctkdicomretrieve/18915/4 "2021-07-28T21:22:27Z")

</div>

> [@rbumm](#):
>
> 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](https://github.com/commontk/CTK/blob/master/Libs/DICOM/Core/ctkDICOMRetrieve.h) exposes the Q\_INVOKABLE versions. Probably at this point we should add Q\_INVOKABLE to the corresponding methods in [ctkDICOMQuery](https://github.com/commontk/CTK/blob/master/Libs/DICOM/Core/ctkDICOMQuery.h) for consistency, but properties are usually better to use if where they exist.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 1, 2021, 12:08pm UTC](https://discourse.slicer.org/t/where-to-set-move-storage-port-in-ctkdicomretrieve/18915/6 "2021-08-01T12:08:37Z")

</div>

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

> <https://github.com/commontk/CTK/pull/988/commits/949607ea154f9f73468782bfdd5bad7a3aff9f3f>
>
> Fixed copy-paste error.
