Skip to content

Commit

Permalink
fix(general): enhancements and bug fixes (#4018)
Browse files Browse the repository at this point in the history
  • Loading branch information
IbrahimCSAE authored Apr 10, 2024
1 parent ac0e1c0 commit 2b83393
Show file tree
Hide file tree
Showing 30 changed files with 708 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ const OHIFCornerstoneViewport = React.memo(props => {
actions={viewportDialogState.actions}
onSubmit={viewportDialogState.onSubmit}
onOutsideClick={viewportDialogState.onOutsideClick}
onKeyPress={viewportDialogState.onKeyPress}
/>
)}
</div>
Expand Down
130 changes: 130 additions & 0 deletions extensions/cornerstone/src/getCustomizationModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,136 @@ function getCustomizationModule() {
step: 1,
},
},
{
id: 'cornerstone.measurements',
Angle: {
displayText: [],
report: [],
},
CobbAngle: {
displayText: [],
report: [],
},
ArrowAnnotate: {
displayText: [],
report: [],
},
RectangleROi: {
displayText: [],
report: [],
},
CircleROI: {
displayText: [],
report: [],
},
EllipticalROI: {
displayText: [],
report: [],
},
Bidirectional: {
displayText: [],
report: [],
},
Length: {
displayText: [],
report: [],
},
LivewireContour: {
displayText: [],
report: [],
},
SplineROI: {
displayText: [
{
displayName: 'Area',
value: 'area',
type: 'value',
},
{
value: 'areaUnit',
for: ['area'],
type: 'unit',
},
/**
{
displayName: 'Modality',
value: 'Modality',
type: 'value',
},
*/
],
report: [
{
displayName: 'Area',
value: 'area',
type: 'value',
},
{
displayName: 'Unit',
value: 'areaUnit',
type: 'value',
},
],
},
PlanarFreehandROI: {
displayText: [
{
displayName: 'Mean',
value: 'mean',
type: 'value',
},
{
displayName: 'Max',
value: 'max',
type: 'value',
},
{
displayName: 'Area',
value: 'area',
type: 'value',
},
{
value: 'modalityUnit',
for: ['mean', 'max' /** 'stdDev **/],
type: 'unit',
},
{
value: 'areaUnit',
for: ['area'],
type: 'unit',
},
/**
{
displayName: 'Std Dev',
value: 'stdDev',
type: 'value',
},
*/
],
report: [
{
displayName: 'Mean',
value: 'mean',
type: 'value',
},
{
displayName: 'Max',
value: 'max',
type: 'value',
},
{
displayName: 'Area',
value: 'area',
type: 'value',
},
{
displayName: 'Unit',
value: 'unit',
type: 'value',
},
],
},
},
],
},
];
Expand Down
35 changes: 30 additions & 5 deletions extensions/cornerstone/src/initMeasurementService.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const CORNERSTONE_3D_TOOLS_SOURCE_VERSION = '0.1';
const initMeasurementService = (
measurementService,
displaySetService,
cornerstoneViewportService
cornerstoneViewportService,
customizationService
) => {
/* Initialization */
const {
Expand All @@ -30,10 +31,13 @@ const initMeasurementService = (
CobbAngle,
RectangleROI,
PlanarFreehandROI,
SplineROI,
LivewireContour,
} = measurementServiceMappingsFactory(
measurementService,
displaySetService,
cornerstoneViewportService
cornerstoneViewportService,
customizationService
);
const csTools3DVer1MeasurementSource = measurementService.createSource(
CORNERSTONE_3D_TOOLS_SOURCE_NAME,
Expand Down Expand Up @@ -127,6 +131,14 @@ const initMeasurementService = (
PlanarFreehandROI.toMeasurement
);

measurementService.addMapping(
csTools3DVer1MeasurementSource,
'SplineROI',
SplineROI.matchingCriteria,
SplineROI.toAnnotation,
SplineROI.toMeasurement
);

// On the UI side, the Calibration Line tool will work almost the same as the
// Length tool
measurementService.addMapping(
Expand All @@ -137,16 +149,29 @@ const initMeasurementService = (
Length.toMeasurement
);

measurementService.addMapping(
csTools3DVer1MeasurementSource,
'LivewireContour',
LivewireContour.matchingCriteria,
LivewireContour.toAnnotation,
LivewireContour.toMeasurement
);

return csTools3DVer1MeasurementSource;
};

const connectToolsToMeasurementService = servicesManager => {
const { measurementService, displaySetService, cornerstoneViewportService } =
servicesManager.services;
const {
measurementService,
displaySetService,
cornerstoneViewportService,
customizationService,
} = servicesManager.services;
const csTools3DVer1MeasurementSource = initMeasurementService(
measurementService,
displaySetService,
cornerstoneViewportService
cornerstoneViewportService,
customizationService
);
connectMeasurementServiceToTools(
measurementService,
Expand Down
5 changes: 1 addition & 4 deletions extensions/cornerstone/src/utils/callInputDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,10 @@ export function callLabelAutocompleteDialog(uiDialogService, callback, dialogCon

uiDialogService.create({
id: 'select-annotation',
centralize: true,
isDraggable: false,
showOverlay: true,
content: LabellingFlow,
defaultPosition: {
x: window.innerWidth / 2,
y: window.innerHeight / 2,
},
contentProps: {
labellingDoneCallback: labellingDoneCallback,
measurementData: { label: '' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const Angle = {
csToolsEventDetail,
displaySetService,
CornerstoneViewportService,
getValueTypeFromToolType
getValueTypeFromToolType,
customizationService
) => {
const { annotation, viewportId } = csToolsEventDetail;
const { metadata, data, annotationUID } = annotation;
Expand Down Expand Up @@ -54,8 +55,9 @@ const Angle = {

const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);

const displayText = getDisplayText(mappedAnnotations, displaySet);
const getReport = () => _getReport(mappedAnnotations, points, FrameOfReferenceUID);
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
const getReport = () =>
_getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);

return {
uid: annotationUID,
Expand Down Expand Up @@ -127,7 +129,7 @@ This function is used to convert the measurement data to a format that is
suitable for the report generation (e.g. for the csv report). The report
returns a list of columns and corresponding values.
*/
function _getReport(mappedAnnotations, points, FrameOfReferenceUID) {
function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService) {
const columns = [];
const values = [];

Expand Down Expand Up @@ -160,7 +162,7 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID) {
};
}

function getDisplayText(mappedAnnotations, displaySet) {
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
if (!mappedAnnotations || !mappedAnnotations.length) {
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const Length = {
csToolsEventDetail,
displaySetService,
cornerstoneViewportService,
getValueTypeFromToolType
getValueTypeFromToolType,
customizationService
) => {
const { annotation, viewportId } = csToolsEventDetail;
const { metadata, data, annotationUID } = annotation;
Expand Down Expand Up @@ -52,7 +53,7 @@ const Length = {

const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);

const displayText = getDisplayText(mappedAnnotations, displaySet);
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);

return {
uid: annotationUID,
Expand Down Expand Up @@ -106,7 +107,7 @@ function getMappedAnnotations(annotation, displaySetService) {
return annotations;
}

function getDisplayText(mappedAnnotations, displaySet) {
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
if (!mappedAnnotations) {
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const Bidirectional = {
csToolsEventDetail,
displaySetService,
cornerstoneViewportService,
getValueTypeFromToolType
getValueTypeFromToolType,
customizationService
) => {
const { annotation, viewportId } = csToolsEventDetail;
const { metadata, data, annotationUID } = annotation;
Expand Down Expand Up @@ -49,8 +50,9 @@ const Bidirectional = {

const mappedAnnotations = getMappedAnnotations(annotation, displaySetService);

const displayText = getDisplayText(mappedAnnotations, displaySet);
const getReport = () => _getReport(mappedAnnotations, points, FrameOfReferenceUID);
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
const getReport = () =>
_getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);

return {
uid: annotationUID,
Expand Down Expand Up @@ -122,7 +124,7 @@ This function is used to convert the measurement data to a format that is
suitable for the report generation (e.g. for the csv report). The report
returns a list of columns and corresponding values.
*/
function _getReport(mappedAnnotations, points, FrameOfReferenceUID) {
function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService) {
const columns = [];
const values = [];

Expand Down Expand Up @@ -155,7 +157,7 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID) {
};
}

function getDisplayText(mappedAnnotations, displaySet) {
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
if (!mappedAnnotations || !mappedAnnotations.length) {
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const CircleROI = {
csToolsEventDetail,
DisplaySetService,
CornerstoneViewportService,
getValueTypeFromToolType
getValueTypeFromToolType,
customizationService
) => {
const { annotation, viewportId } = csToolsEventDetail;
const { metadata, data, annotationUID } = annotation;
Expand Down Expand Up @@ -47,8 +48,9 @@ const CircleROI = {

const mappedAnnotations = getMappedAnnotations(annotation, DisplaySetService);

const displayText = getDisplayText(mappedAnnotations, displaySet);
const getReport = () => _getReport(mappedAnnotations, points, FrameOfReferenceUID);
const displayText = getDisplayText(mappedAnnotations, displaySet, customizationService);
const getReport = () =>
_getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService);

return {
uid: annotationUID,
Expand Down Expand Up @@ -125,7 +127,7 @@ This function is used to convert the measurement data to a format that is
suitable for the report generation (e.g. for the csv report). The report
returns a list of columns and corresponding values.
*/
function _getReport(mappedAnnotations, points, FrameOfReferenceUID) {
function _getReport(mappedAnnotations, points, FrameOfReferenceUID, customizationService) {
const columns = [];
const values = [];

Expand Down Expand Up @@ -163,7 +165,7 @@ function _getReport(mappedAnnotations, points, FrameOfReferenceUID) {
};
}

function getDisplayText(mappedAnnotations, displaySet) {
function getDisplayText(mappedAnnotations, displaySet, customizationService) {
if (!mappedAnnotations || !mappedAnnotations.length) {
return '';
}
Expand Down
Loading

0 comments on commit 2b83393

Please sign in to comment.