# HG changeset patch # User Sebastien Jodogne # Date 1764773994 -3600 # Node ID c2c58aeec40bd5f1d932d4a10247f3760786f0c7 # Parent 0633b2841e442adce9ab31cf98138489eb98f9cf added safeguard for multiple US regions diff -r 0633b2841e44 -r c2c58aeec40b OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp --- a/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp Wed Dec 03 15:40:46 2025 +0100 +++ b/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp Wed Dec 03 15:59:54 2025 +0100 @@ -258,19 +258,42 @@ dataset.GetSequenceSize(size, Orthanc::DicomPath(DICOM_TAG_SEQUENCE_OF_ULTRASOUND_REGIONS)) && size >= 1) { - int directionX, directionY; + bool found = false; double deltaX, deltaY; - if (reader.GetIntegerValue(directionX, Orthanc::DicomPath(DICOM_TAG_SEQUENCE_OF_ULTRASOUND_REGIONS, - 0, DICOM_TAG_PHYSICAL_UNITS_X_DIRECTION)) && - reader.GetIntegerValue(directionY, Orthanc::DicomPath(DICOM_TAG_SEQUENCE_OF_ULTRASOUND_REGIONS, - 0, DICOM_TAG_PHYSICAL_UNITS_Y_DIRECTION)) && - reader.GetDoubleValue(deltaX, Orthanc::DicomPath(DICOM_TAG_SEQUENCE_OF_ULTRASOUND_REGIONS, - 0, DICOM_TAG_PHYSICAL_DELTA_X)) && - reader.GetDoubleValue(deltaY, Orthanc::DicomPath(DICOM_TAG_SEQUENCE_OF_ULTRASOUND_REGIONS, - 0, DICOM_TAG_PHYSICAL_DELTA_Y)) && - directionX == 0x0003 && // Centimeters - directionY == 0x0003) // Centimeters + for (size_t j = 0; j < size; j++) + { + int directionX, directionY; + double dx, dy; + + // TODO: We only keep one region expressed in centimeters, but there might be multiple US regions. + if (reader.GetIntegerValue(directionX, Orthanc::DicomPath(DICOM_TAG_SEQUENCE_OF_ULTRASOUND_REGIONS, + j, DICOM_TAG_PHYSICAL_UNITS_X_DIRECTION)) && + reader.GetIntegerValue(directionY, Orthanc::DicomPath(DICOM_TAG_SEQUENCE_OF_ULTRASOUND_REGIONS, + j, DICOM_TAG_PHYSICAL_UNITS_Y_DIRECTION)) && + reader.GetDoubleValue(dx, Orthanc::DicomPath(DICOM_TAG_SEQUENCE_OF_ULTRASOUND_REGIONS, + j, DICOM_TAG_PHYSICAL_DELTA_X)) && + reader.GetDoubleValue(dy, Orthanc::DicomPath(DICOM_TAG_SEQUENCE_OF_ULTRASOUND_REGIONS, + j, DICOM_TAG_PHYSICAL_DELTA_Y)) && + directionX == 0x0003 && // Centimeters + directionY == 0x0003) // Centimeters + { + if (found) + { + LOG(ERROR) << "Image with multiple US regions expressed in centimeters, annotations will use pixels"; + found = false; + break; + } + else + { + found = true; + deltaX = dx; + deltaY = dy; + } + } + } + + if (found) { // Scene coordinates are expressed in millimeters => multiplication by 10 SetPixelSpacing(10.0 * deltaX, 10.0 * deltaY);