Search code examples
pythondicomdcmtk

Difficulty using 'findscu' then 'movescu' then repeat iteratively over multiple accession numbers


I have written a code that is used to pull DICOM files from my internal server, but I am having difficulty running it repeatedly for different accession numbers.

Summary of the workflow: Given a certain accession number,

  1. use findscu to get information on the accession number,
  2. parse the output file to a dataframe to organize the information,
  3. Choose specific series descriptions from the data frame,
  4. use movescu to download the scans
  5. Perform processing on the downloaded DICOM scan

Then repeat for a new accession number.

The problem occurs when executing findscu the second time, it will tell me that there is no acccession number information on the database as if the accession number doesn't exist. But this is not possible, because when I stop the code and iterate manually the next accession number does exist on the database.

findscu command:

'findscu -v -S  -k 0008,0052=SERIES -k 0010,0010="" -k 0010,0020="" -k 0008,0050=<acc_num> -k 0008,1030="" -k 0020,000D="" -k 0008,0020="" -k 0008,103e="" -k 0020,0011="" -k 0020,000E="" -k 0020,1002="" -aet <my_aet> -aec <remote_aet> <remote_ip> <remote_port> > F:\\FGTCategoryQuantification_mhas\\findscu_acc_num_SERIES.txt'

movescu command:

'movescu -S +P 4006 -k 0008,0052=IMAGE -k 0010,0010="" -k 0010,0020="" -k 0008,0050=<acc_num> -k 0008,1030="" -k 0020,000D=1.2.826.0.1.3680043.2.1009.1465932691.20300.142.76.30.2008137300 -k 0008,0020="" -k 0008,103e="" -k 0020,0011="" -k 0020,000E=1.2.826.0.1.3680043.2.1009.1465932803.545000130.20070116 -k 0020,1002="" -aet <my_Aet> -aec <remote_aet> <remote_ip> <remote_port> -od F:\\FGTCategoryQuantification_mhas\\DICOMacc_numX01 > F:\\FGTCategoryQuantification_mhas\\DICOMacc_numX01\\movescu_acc_numPh1SagVIBRANTMPH.txt'

I am thinking that there is some connection possibly open still that interupts the second findscu execution? or some other problem? I don't have a lot of experience with dcmtlk. Any advice would be much appreciated.

Thank you in advance - Grey


Solution

  • Jörg Riesmeier is right saying that DICOM does not allow retrieval by accession number - it requires identifying the study you want to retrieve by its Study Instance UID (0020,000D).

    However the server you are communicating with seems to support retrieval by accession number in general. If timing of your requests matters, the server might accept only one association at a time. However the error message should then be part of the response to the second association request rather than to the second C-FIND request and indicate that the connection limit is exceeded. The server's DICOM implementation does not seem to be entirely correct...

    Maybe a look at the DICOM Conformance Statement helps answering your question. If you like, you can disclose the particular product you are communicating with then we could have a look at it.