Number of Images When Perfomring a Query

Good Day All,
When performing a REST call against modalities//query is there a way to retrieve the number of images within the returned studies?

The way that I do this is to perform a query at the Instance level (https://api.orthanc-server.com/#tag/Networking/paths/~1modalities~1{id}~1query/post) rather than the study level. You can then get the answers to the query by using https://api.orthanc-server.com/#tag/Networking/paths/~1queries~1{id}~1answers/get. You can then count the number of instances by the number of responses or use the expand parameter to inspect further detail.

James

Hello,

The DICOM standard specifies “Additional Query/Retrieve Attributes” that can be used to that end:
http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.3.4.html

For instance:

$ curl http://localhost:8042/modalities/sample/query -d ‘{“Level”:“Study”,“Query”:{“NumberOfStudyRelatedInstances”:“”,“NumberOfStudyRelatedSeries”:“”}}’

{
“ID” : “c0efd0e0-4fd0-4f79-a354-f0330ced6d4a”,
“Path” : “/queries/c0efd0e0-4fd0-4f79-a354-f0330ced6d4a”
}

$ curl ‘http://localhost:8042/queries/c0efd0e0-4fd0-4f79-a354-f0330ced6d4a/answers?expand&simplify’
[
{
“AccessionNumber” : “XXX”,
“NumberOfStudyRelatedInstances” : “1”,
“NumberOfStudyRelatedSeries” : “1”,
“PatientID” : “XXX”,
“QueryRetrieveLevel” : “STUDY”,
“RetrieveAETitle” : “ORTHANC”,
“SpecificCharacterSet” : “ISO_IR 100”,
“StudyInstanceUID” : “XXX”
},
{
“AccessionNumber” : “XXX”,
“NumberOfStudyRelatedInstances” : “46”,
“NumberOfStudyRelatedSeries” : “2”,
“PatientID” : “XXX”,
“QueryRetrieveLevel” : “STUDY”,
“RetrieveAETitle” : “ORTHANC”,
“SpecificCharacterSet” : “ISO_IR 100”,
“StudyInstanceUID” : “XXX”
}
]

HTH,
SĂ©bastien-

Sorry to dig an old topic, but checking the API I see /studies/{id}/statistics that displays a nice

"CountInstances" : 736,

Getting /studies/{id}/instances and counting the resulting objects I see the same number.

Is the former endpoint safe to count images per studyInstanceUID?

yes !

1 Like

Still on this matter I am now facing multi frame Instances,
is there an endpoint to count the number of frames and could this additional info be added to the /statistics endpoint?

Hello,

The /statistics endpoint is there to provide high-level information about the database, but counting the number of frames would require looping over all the DICOM instances.

If this feature is useful to you, you could overwrite the /statistics endpoint by a plugin (e.g. in Python) that would call /instances/{id}/frames to retrieve the number of frames in each instance of your database.

As an example, here is how to get the number of frames in one multi-frame instance on our demo server:

$ curl https://orthanc.uclouvain.be/demo/instances/6a75616c-e39d96cb-e752cdd5-4f65d1b1-dee0451e/file

Regards,
SĂ©bastien-