Skip to content

Commit

Permalink
feat: Add Sphere scissor and SUV PeakTool and refactor ROI computations
Browse files Browse the repository at this point in the history
* feat: Add 3D sphere scissor tool for orthogonal viewports

* feat: Refactor the common logic for ROI computations

* feat: Add SUV peakTool for PET

* fix: removed unnecessary canvas coordinates in the toolData for circle and sphere

* fix: Resolve incorrect dependency

* fix: changed dcmjs version

* fix: Resolve build error

* Address review comments
  • Loading branch information
sedghi authored and swederik committed Mar 22, 2022
1 parent 2ed5809 commit a854cf4
Show file tree
Hide file tree
Showing 25 changed files with 2,128 additions and 523 deletions.
5 changes: 5 additions & 0 deletions packages/cornerstone-tools/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ import {
CrosshairsTool,
RectangleScissorsTool,
CircleScissorsTool,
SphereScissorsTool,
RectangleRoiThreshold,
SUVPeakTool,
} from './tools'
import { ToolBindings, ToolModes, CornerstoneTools3DEvents } from './enums'

Expand Down Expand Up @@ -87,7 +89,10 @@ export {
// Segmentation Tools
RectangleScissorsTool,
CircleScissorsTool,
SphereScissorsTool,
RectangleRoiThreshold,
// PET annotation
SUVPeakTool,
// Synchronizers
synchronizers,
Synchronizer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ import {
import getWorldWidthAndHeightFromTwoPoints from '../../util/planar/getWorldWidthAndHeightFromTwoPoints'
import { ToolSpecificToolData, Point3, Point2 } from '../../types'
import triggerAnnotationRenderForViewportUIDs from '../../util/triggerAnnotationRenderForViewportUIDs'
import pointInShapeCallback from '../../util/planar/pointInShapeCallback'

interface EllipticalRoiSpecificToolData extends ToolSpecificToolData {
export interface EllipticalRoiSpecificToolData extends ToolSpecificToolData {
data: {
invalidated: boolean
handles: {
points: [Point3, Point3, Point3, Point3] // [bottom, top, left, right]
activeHandleIndex: number | null
textBox: {
textBox?: {
hasMoved: boolean
worldPosition: Point3
worldBoundingBox: {
Expand Down Expand Up @@ -85,12 +86,21 @@ export default class EllipticalRoiTool extends BaseAnnotationTool {
isDrawing: boolean
isHandleOutsideImage: boolean

constructor(toolConfiguration = {}) {
super(toolConfiguration, {
constructor(
toolConfiguration: Record<string, any>,
defaultToolConfiguration = {
name: 'EllipticalRoi',
supportedInteractionTypes: ['Mouse', 'Touch'],
configuration: { shadow: true, preventHandleOutsideImage: false },
})
configuration: {
strategies: {},
defaultStrategy: undefined,
activeStrategy: undefined,
shadow: true,
preventHandleOutsideImage: false,
},
}
) {
super(toolConfiguration, defaultToolConfiguration)

this._throttledCalculateCachedStats = throttle(
this._calculateCachedStats,
Expand Down Expand Up @@ -1052,20 +1062,42 @@ export default class EllipticalRoiTool extends BaseAnnotationTool {
}
}

mean /= count
pointInShapeCallback(
[
[iMin, iMax],
[jMin, jMax],
[kMin, kMax],
],
viewport.worldToCanvas,
scalarData,
imageData,
dimensions,
(canvasCoords) => pointInEllipse(ellipse, canvasCoords),
meanCalculator
)

for (let k = kMin; k <= kMax; k++) {
for (let j = jMin; j <= jMax; j++) {
for (let i = iMin; i <= iMax; i++) {
const value = scalarData[k * zMultiple + j * yMultiple + i]
mean /= count

const valueMinusMean = value - mean
const stdCalculator = (canvasCoords, ijkCoords, index, value) => {
const valueMinusMean = value - mean

stdDev += valueMinusMean * valueMinusMean
}
}
stdDev += valueMinusMean * valueMinusMean
}

pointInShapeCallback(
[
[iMin, iMax],
[jMin, jMax],
[kMin, kMax],
],
viewport.worldToCanvas,
scalarData,
imageData,
dimensions,
(canvasCoords) => pointInEllipse(ellipse, canvasCoords),
stdCalculator
)

stdDev /= count
stdDev = Math.sqrt(stdDev)

Expand Down
Loading

0 comments on commit a854cf4

Please sign in to comment.