Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0e6cdde
Bump dcmjs and fix metadata provider after dcmjs server update
igoroctaviano May 25, 2021
104fe98
Resolve format issues with slice thickness
igoroctaviano May 25, 2021
e2379f1
Resolve promise logic of dcm4chee reject of srs causing dialog to get…
igoroctaviano May 27, 2021
bf7346b
Merge branch 'feat/v2-main' of github.com:OHIF/Viewers into feat/anno…
igoroctaviano Jun 30, 2021
012f13e
Remove debugger
igoroctaviano Jun 30, 2021
869672a
Add mappings for rectangle and freehand
igoroctaviano Jul 8, 2021
06885d3
Merge branch 'feat/v2-main' of github.com:OHIF/Viewers into feat/anno…
igoroctaviano Jul 8, 2021
dc168fa
Merge branch 'feat/v2-main' of github.com:OHIF/Viewers into feat/anno…
igoroctaviano Jul 21, 2021
dc3c4e0
Merge branch 'feat/v2-main' of github.com:OHIF/Viewers into feat/anno…
igoroctaviano Aug 5, 2021
17e5aba
Merge branch 'feat/v2-main' of github.com:OHIF/Viewers into feat/anno…
igoroctaviano Aug 19, 2021
2837603
feat: Add Static WADO display (#2499)
wayfarer3130 Aug 20, 2021
7eb288e
docs: Remove UI components for now, we will use Storybook instead lat…
swederik Aug 24, 2021
5240047
fix: Revert Scrollbar visibility for now
sedghi Aug 24, 2021
4504d7d
Add scoord3d support (bounding box / score)
igoroctaviano Sep 7, 2021
032674e
Merge branch 'feat/v2-main' of github.com:OHIF/Viewers into feat/anno…
igoroctaviano Oct 14, 2021
2987d69
Merge branch 'v3-stable' of github.com:OHIF/Viewers into feat/annotat…
igoroctaviano Oct 14, 2021
2b99966
Update tests
igoroctaviano Oct 14, 2021
5efe39f
Rollback config change
igoroctaviano Oct 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extensions/cornerstone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"cornerstone-math": "0.1.9",
"cornerstone-tools": "6.0.2",
"cornerstone-wado-image-loader": "4.0.4",
"dcmjs": "0.16.1",
"dcmjs": "0.18.8",
"dicom-parser": "^1.8.9",
"hammerjs": "^2.0.8",
"prop-types": "^15.6.2",
Expand All @@ -45,8 +45,8 @@
},
"dependencies": {
"@babel/runtime": "7.7.6",
"lodash.merge": "^4.6.2",
"lodash.debounce": "4.0.8",
"lodash.merge": "^4.6.2",
"react-cornerstone-viewport": "4.1.2"
}
}
23 changes: 23 additions & 0 deletions extensions/cornerstone/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const TOOL_TYPES_WITH_CONTEXT_MENU = [
'SRBidirectional',
'SRArrowAnnotate',
'SREllipticalRoi',
'SRRectangleRoi',
];

const _refreshViewports = () =>
Expand Down Expand Up @@ -319,6 +320,8 @@ const _initMeasurementService = (MeasurementService, DisplaySetService) => {
Length,
Bidirectional,
EllipticalRoi,
RectangleRoi,
FreehandRoi,
ArrowAnnotate,
} = measurementServiceMappingsFactory(MeasurementService, DisplaySetService);
const csToolsVer4MeasurementSource = MeasurementService.createSource(
Expand Down Expand Up @@ -351,6 +354,22 @@ const _initMeasurementService = (MeasurementService, DisplaySetService) => {
EllipticalRoi.toMeasurement
);

MeasurementService.addMapping(
csToolsVer4MeasurementSource,
'RectangleRoi',
RectangleRoi.matchingCriteria,
RectangleRoi.toAnnotation,
RectangleRoi.toMeasurement
);

MeasurementService.addMapping(
csToolsVer4MeasurementSource,
'FreehandRoi',
FreehandRoi.matchingCriteria,
FreehandRoi.toAnnotation,
FreehandRoi.toMeasurement
);

MeasurementService.addMapping(
csToolsVer4MeasurementSource,
'ArrowAnnotate',
Expand Down Expand Up @@ -520,13 +539,17 @@ const _connectMeasurementServiceToTools = (
const TOOL_TYPE_TO_VALUE_TYPE = {
Length: POLYLINE,
EllipticalRoi: ELLIPSE,
RectangleRoi: POLYLINE,
FreehandRoi: POLYLINE,
Bidirectional: BIDIRECTIONAL,
ArrowAnnotate: POINT,
};

const VALUE_TYPE_TO_TOOL_TYPE = {
[POLYLINE]: 'Length',
[ELLIPSE]: 'EllipticalRoi',
[POLYLINE]: 'RectangleRoi',
[POLYLINE]: 'FreehandRoi',
[BIDIRECTIONAL]: 'Bidirectional',
[POINT]: 'ArrowAnnotate',
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import SUPPORTED_TOOLS from './constants/supportedTools';
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
import getHandlesFromPoints from './utils/getHandlesFromPoints';

const FreehandRoi = {
toAnnotation: (measurement, definition) => {},
toMeasurement: (
csToolsAnnotation,
DisplaySetService,
getValueTypeFromToolType
) => {
const { element, measurementData } = csToolsAnnotation;
const tool =
csToolsAnnotation.toolType ||
csToolsAnnotation.toolName ||
measurementData.toolType;

const validToolType = toolName => SUPPORTED_TOOLS.includes(toolName);

if (!validToolType(tool)) {
throw new Error('Tool not supported');
}

const {
SOPInstanceUID,
FrameOfReferenceUID,
SeriesInstanceUID,
StudyInstanceUID,
} = getSOPInstanceAttributes(element);

const displaySet = DisplaySetService.getDisplaySetForSOPInstanceUID(
SOPInstanceUID,
SeriesInstanceUID
);

const { cachedStats, handles } = measurementData;

const { start, end } = handles;

const halfXLength = Math.abs(start.x - end.x) / 2;
const halfYLength = Math.abs(start.y - end.y) / 2;

const points = [];
const center = { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 };

// To store similar to SR.
if (halfXLength > halfYLength) {
// X-axis major
// Major axis
points.push({ x: center.x - halfXLength, y: center.y });
points.push({ x: center.x + halfXLength, y: center.y });
// Minor axis
points.push({ x: center.x, y: center.y - halfYLength });
points.push({ x: center.x, y: center.y + halfYLength });
} else {
// Y-axis major
// Major axis
points.push({ x: center.x, y: center.y - halfYLength });
points.push({ x: center.x, y: center.y + halfYLength });
// Minor axis
points.push({ x: center.x - halfXLength, y: center.y });
points.push({ x: center.x + halfXLength, y: center.y });
}

let meanSUV;
let stdDevSUV;

if (
cachedStats &&
cachedStats.meanStdDevSUV &&
cachedStats.meanStdDevSUV.mean !== 0
) {
const { meanStdDevSUV } = cachedStats;

meanSUV = meanStdDevSUV.mean;
stdDevSUV = meanStdDevSUV.stdDev;
}

return {
id: measurementData.id,
SOPInstanceUID,
FrameOfReferenceUID,
referenceSeriesUID: SeriesInstanceUID,
referenceStudyUID: StudyInstanceUID,
displaySetInstanceUID: displaySet.displaySetInstanceUID,
label: measurementData.label,
description: measurementData.description,
unit: measurementData.unit,
area: cachedStats && cachedStats.area,
mean: cachedStats && cachedStats.mean,
stdDev: cachedStats && cachedStats.stdDev,
meanSUV,
stdDevSUV,
type: getValueTypeFromToolType(tool),
points,
};
},
};

export default FreehandRoi;
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import SUPPORTED_TOOLS from './constants/supportedTools';
import getHandlesFromPoints from './utils/getHandlesFromPoints';
import getPointsFromHandles from './utils/getPointsFromHandles';
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';

const RectangleRoi = {
toAnnotation: (measurement, definition) => {},

/**
* Maps cornerstone annotation event data to measurement service format.
*
* @param {Object} cornerstone Cornerstone event data
* @return {Measurement} Measurement instance
*/
toMeasurement: (
csToolsAnnotation,
DisplaySetService,
getValueTypeFromToolType
) => {
const { element, measurementData } = csToolsAnnotation;
const tool =
csToolsAnnotation.toolType ||
csToolsAnnotation.toolName ||
measurementData.toolType;

const validToolType = toolName => SUPPORTED_TOOLS.includes(toolName);

if (!validToolType(tool)) {
throw new Error('Tool not supported');
}

const {
SOPInstanceUID,
FrameOfReferenceUID,
SeriesInstanceUID,
StudyInstanceUID,
} = getSOPInstanceAttributes(element);

const displaySet = DisplaySetService.getDisplaySetForSOPInstanceUID(
SOPInstanceUID,
SeriesInstanceUID
);

return {
id: measurementData.id,
SOPInstanceUID,
FrameOfReferenceUID,
referenceSeriesUID: SeriesInstanceUID,
referenceStudyUID: StudyInstanceUID,
displaySetInstanceUID: displaySet.displaySetInstanceUID,
label: measurementData.label,
description: measurementData.description,
unit: measurementData.unit,
length: measurementData.length,
type: getValueTypeFromToolType(tool),
points: getPointsFromHandles(measurementData.handles),
};
},
};

export default RectangleRoi;

/**
* {
"data": [
{
"visible": true,
"active": false,
"invalidated": false,
"handles": {
"start": {
"x": 191.15890083632019,
"y": 108.51135005973717,
"highlight": true,
"active": false
},
"end": {
"x": 254.77658303464756,
"y": 150.71923536439667,
"highlight": true,
"active": false,
"moving": false
},
"initialRotation": 0,
"textBox": {
"active": false,
"hasMoved": false,
"movesIndependently": false,
"drawnIndependently": true,
"allowedOutsideImage": true,
"hasBoundingBox": true,
"x": 254.77658303464756,
"y": 129.61529271206692,
"boundingBox": {
"width": 149.6158905029297,
"height": 65,
"left": 625,
"top": 179.39062500000003
}
}
},
"uuid": "71509b93-1c6f-4acb-88ba-b67a4debc8a3",
"cachedStats": {
"area": 1364.6373162386578,
"count": 2752,
"mean": -483.00981104651163,
"variance": 169503.0307903713,
"stdDev": 411.7074577784222,
"min": -1024,
"max": 1386
},
"unit": "HU"
}
]
}
*/
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export default ['Length', 'EllipticalRoi', 'Bidirectional', 'ArrowAnnotate'];
export default [
'Length',
'EllipticalRoi',
'RectangleRoi',
'FreehandRoi',
'Bidirectional',
'ArrowAnnotate',
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Length from './Length';
import Bidirectional from './Bidirectional';
import ArrowAnnotate from './ArrowAnnotate';
import EllipticalRoi from './EllipticalRoi';
import RectangleRoi from './RectangleRoi';
import FreehandRoi from './FreehandRoi';

const measurementServiceMappingsFactory = (
MeasurementService,
Expand All @@ -23,12 +25,14 @@ const measurementServiceMappingsFactory = (
BIDIRECTIONAL,
} = MeasurementService.VALUE_TYPES;

// TODO -> I get why this was attemped, but its not nearly flexible enough.
// TODO -> I get why this was attempted, but its not nearly flexible enough.
// A single measurement may have an ellipse + a bidirectional measurement, for instances.
// You can't define a bidirectional tool as a single type..
const TOOL_TYPE_TO_VALUE_TYPE = {
Length: POLYLINE,
EllipticalRoi: ELLIPSE,
RectangleRoi: POLYLINE,
FreehandRoi: POLYLINE,
Bidirectional: BIDIRECTIONAL,
ArrowAnnotate: POINT,
};
Expand Down Expand Up @@ -88,6 +92,55 @@ const measurementServiceMappingsFactory = (
},
],
},
FreehandRoi: {
toAnnotation: FreehandRoi.toAnnotation,
toMeasurement: csToolsAnnotation =>
FreehandRoi.toMeasurement(
csToolsAnnotation,
DisplaySetService,
_getValueTypeFromToolType
),
matchingCriteria: [
{
valueType: MeasurementService.VALUE_TYPES.POLYLINE,
properties: ['stdDev'],
// attributes: [
// {
// codeValue: '386136009',
// codeMeaning: 'Standard Deviation',
// codingSchemeDesignator: 'SCT',
// },
// ],
},
],
},
RectangleRoi: {
toAnnotation: RectangleRoi.toAnnotation,
toMeasurement: csToolsAnnotation =>
RectangleRoi.toMeasurement(
csToolsAnnotation,
DisplaySetService,
_getValueTypeFromToolType
),
matchingCriteria: [
{
valueType: MeasurementService.VALUE_TYPES.POLYLINE,
points: 2,
},
{
valueType: MeasurementService.VALUE_TYPES.POLYLINE,
points: 2,
},
{
valueType: MeasurementService.VALUE_TYPES.POLYLINE,
points: 2,
},
{
valueType: MeasurementService.VALUE_TYPES.POLYLINE,
points: 2,
},
],
},
EllipticalRoi: {
toAnnotation: EllipticalRoi.toAnnotation,
toMeasurement: csToolsAnnotation =>
Expand Down
2 changes: 1 addition & 1 deletion extensions/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"peerDependencies": {
"@ohif/core": "^0.50.0",
"@ohif/i18n": "^0.52.8",
"dcmjs": "0.16.1",
"dcmjs": "0.18.8",
"dicomweb-client": "^0.6.0",
"prop-types": "^15.6.2",
"react": "^16.13.1",
Expand Down
Loading