Skip to content

Commit

Permalink
fix: passing metadata to getTextLines callback in annotation tools (#…
Browse files Browse the repository at this point in the history
…1710)

* passing metadata to getTextLines callback in annotation tools

* add second parameter in defaultGetTexlines to show it as intentional

* add context object
  • Loading branch information
salimkanoun authored Dec 18, 2024
1 parent 2f69ded commit 67618fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class CircleROIStartEndThresholdTool extends CircleROITool {

for (let i = 0; i < annotations.length; i++) {
const annotation = annotations[i] as CircleROIStartEndThresholdAnnotation;
const { annotationUID, data } = annotation;
const { annotationUID, data, metadata } = annotation;
const { startCoordinate, endCoordinate } = data;
const { points, activeHandleIndex } = data.handles;

Expand Down Expand Up @@ -502,7 +502,7 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
};
continue;
}
const textLines = this.configuration.getTextLines(data);
const textLines = this.configuration.getTextLines(data, { metadata });
if (!textLines || textLines.length === 0) {
continue;
}
Expand Down Expand Up @@ -881,9 +881,9 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
* target volume enclosed by the rectangle.
*
* @param data - The annotation tool-specific data.
* @param targetId - The volumeId of the volume to display the stats for.
* @param _context - Associated data to annotation.
*/
function defaultGetTextLines(data): string[] {
function defaultGetTextLines(data, _context = {}): string[] {
const cachedVolumeStats = data.cachedStats.statistics;

const { area, mean, max, stdDev, areaUnit, modalityUnit } = cachedVolumeStats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
const annotation = annotations[
i
] as RectangleROIStartEndThresholdAnnotation;
const { annotationUID, data } = annotation;
const { annotationUID, data, metadata } = annotation;
const { startCoordinate, endCoordinate } = data;
const { points, activeHandleIndex } = data.handles;

Expand Down Expand Up @@ -693,7 +693,7 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
continue;
}

const textLines = this.configuration.getTextLines(data);
const textLines = this.configuration.getTextLines(data, { metadata });
if (!textLines || textLines.length === 0) {
continue;
}
Expand Down Expand Up @@ -804,9 +804,9 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
* target volume enclosed by the rectangle.
*
* @param data - The annotation tool-specific data.
* @param targetId - The volumeId of the volume to display the stats for.
* @param _context - Associated data to annotation.
*/
function defaultGetTextLines(data): string[] {
function defaultGetTextLines(data, _context = {}): string[] {
const cachedVolumeStats = data.cachedStats.statistics;

const { area, mean, max, stdDev, areaUnit, modalityUnit } = cachedVolumeStats;
Expand Down

0 comments on commit 67618fa

Please sign in to comment.