question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Processing metadata from remote PACS

See original GitHub issue

Hi, 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:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
edmcdonaghcommented, Jun 13, 2018

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.

0reactions
RahulMukherjicommented, Jun 13, 2018

Thank you so much! That worked perfectly. Thank you @scaramallion for spending time in explaining this to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Processing metadata from remote PACS · Issue #177 - GitHub
Hi, I'm working on a project where I need to process the metadata from studies in a PACS server and write them to...
Read more >
Extracting DICOM metadata from PACS recursively over local ...
Purpose The objective of this study is to develop an automated method to address the problem of requiring DICOM metadata from PACS over...
Read more >
VirtualPACS—A Federating Gateway to Access Remote ...
This paper focuses on the problem of federating multiple image data resources such that clients can interact with them as if they are...
Read more >
DICOM Metadata Access, Consolidation and Usage in ...
On the other hand, the DICOM metadata indexing process can occur over files from different modalities and health care facilities PACS archives since...
Read more >
Connect a PACS to the Cloud Healthcare API
The adapter consists of two primary components: the import adapter and the export adapter. This guide shows how to use the import adapter...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found