Counting Studies, Series and Instances

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:

The less good news is:

What queries are available?

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

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)


We use cookies to give you the best possible experience on our website. By continuing to use this website, you agree with our use of cookies. for more information please click HERE