Processing metadata from remote PACS
See original GitHub issueHi, I’m working on a project where I need to process the metadata from studies in a PACS server and write them to a table (either CSV or Excel). I specifically need the Patient Names, Study Dates and Study Instance UIDs of all the studies in a particular date range.
I tried using FindSCU in dcm4che, and while that does return the relevant data, it’s not in a format that’s easy to work with.
This is the command I used in dcm4che (which works):
findscu -L STUDY -r PatientName -r StudyDate -r StudyInstanceUID -c AETitle@serverIP:port -m StudyDate = "date1-date2"
So now I’m trying to do this using PyDicom, specifically pynetdicom3, since it seems like the best way to do this is programmatically (pulling data from the network and writing to an Excel file). I am able to associate with this network using the code in the docs, and this script (slightly modified from the docs) to run a FindSCU query is working:
from pydicom.dataset import Dataset
from pynetdicom3 import AE
from pynetdicom3 import QueryRetrieveSOPClassList
ae = AE(scu_sop_class=QueryRetrieveSOPClassList)
print('Requesting Association with the peer')
assoc = ae.associate('serverIP', port, 'AETitle')
if assoc.is_established:
print('Association accepted by the peer')
dataset = Dataset()
dataset.PatientName = 'some patient name'
dataset.QueryRetrieveLevel = 'STUDY'
responses = assoc.send_c_find(dataset, query_model='S')
for (result) in responses:
print(result)
assoc.release()
While this code is working, I’m not sure how to access specific data values from the results. If I try print(result.StudyInstanceUID)
I get an error: AttributeError: 'tuple' object has no attribute 'StudyInstanceUID'
The question is, how exactly do I access specific attributes of studies using FindSCU in pynetdicom3? Is there any way to get dataset objects from the server like those generated from DICOM files by PyDicom? And if this can’t be accomplished using PyDicom, is there any other tool I can use?
Sorry for the length of the issue, I’m new to Python and working with DICOM and PACS, just wanted to provide all the necessary info.
My environment:
- Windows-10-10.0.17134-SP0
- Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]
- pydicom 1.0.2
- pynetdicom3 0.9.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
To get data returned in your C-FIND you need to include them in your dataset, but with a blank value.
So you will need to add PatientName, StudyInstanceUID etc to your query dataset.
For modality, see the note at the bottom of the page scaramallion linked to.
Thank you so much! That worked perfectly. Thank you @scaramallion for spending time in explaining this to me.