There are many times when users need to know how many objects there of a given type, without needing to enumerate each one. The good news is:

  • DICOM does allow such queries
  • Such queries are possible using DicomObjects

The less good news is:

  • The feature is optional (though strongly recommended) so many PACS do not support it
  • It is not a default feature of DicomObjects queries (due to the load placed on the server), so a little work is required to enable it.

What queries are available?

Basically all six of the queries you could expect are available in the 4-level DICOM hierarchy:

  • At Patient Level

    • How many studies are there for this patient
    • How many Series are there for this patient (in all studies)
    • How many Instances (images) are there for this patient (in all series)
  • At Study Level (Patient and Study roots)

    • How many Series are there in this study
    • How many Instances (images) are there in this study (in all series)
  • At Series Level

    • How many Instances (images) are there in this series

There is also a special query (even less supported the the others) to query for the list of SOP classes in a study

What are the DICOM attributes?

Attribute Name Tag Attribute Description
Number of Patient Related Studies (0020,1200) The number of studies that match the Patient level Query/Retrieve search criteria
Number of Patient Related Series (0020,1202) The number of series that match the Patient level Query/Retrieve search criteria
Number of Patient Related Instances (0020,1204) The number of composite object instances that match the Patient level Query/Retrieve search criteria
Number of Study Related Series (0020,1206) The number of series that match the Study level Query/Retrieve search criteria
Number of Study Related Instances (0020,1208) The number of composite object instances that match the Study level Query/Retrieve search criteria
Number of Series Related Instances (0020,1209) The number of composite object instances in a Series that match the Series level Query/Retrieve search criteria
SOP Classes in Study (0008,0062) The SOP Classes contained in the Study.

Note that all the above attributes are only valid in C-FIND queries, and are not valid within instances.

How do I use these in DicomObjects?

Because these attributes are not in the default list of items requested by DicomObjects, they must be added explicitly. The details vary slightly between the COM and .NET versions, but are basically similar.

DicomObjects.NET

The method needed is DicomQuery.Find(dataset) but to make life easier, and avoid the need to make your own query from scratch, you can use the default query as a starting point, using the QueryDataSet method. e.g. having set up a query for study level, if you wished to query in addition for the number of instances in each study then you would replace this line:

set results = query.Find()

by this:

queryDS = query.QueryDataSet() ' queryDS is a DicomDataSet
queryDS.Add(&h0020,&h1208,"")
results = query.Find(queryDS)

DicomObjects.COM

The method needed is DicomQuery.DoRawQuery, but to make life easier, and avoid the need to make your own query from scratch, you can use the default query as a starting point, using the QueryDataSet method. e.g. having set up a query for study level, if you wished to query in addition for the number of instances in each study then you would replace this line:

set results = query.DoQuery()

by this:

set queryDS = query.QueryDataSet() ' queryDS is a DicomDataSet
queryDS.Attributes.Add(&h0020,&h1208,"")
set results = query.DoRawQuery(queryDS)