Skip to content

Commit

Permalink
fix: Remove untracked measurements from tracking filter
Browse files Browse the repository at this point in the history
  • Loading branch information
wayfarer3130 committed Nov 25, 2024
1 parent 04cbc18 commit a9c9755
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
10 changes: 0 additions & 10 deletions extensions/cornerstone-dicom-sr/src/commandsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ const commandsModule = (props: withAppTypes) => {
window.location.assign(objectUrl);
},

/**
* Download the CSV report for the measurements.
*/
downloadCSVMeasurementsReport: ({ measurementFilter }) => {
utils.downloadCSVReport(measurementService.getMeasurements(measurementFilter));
},

/**
*
* @param measurementData An array of measurements from the measurements service
Expand Down Expand Up @@ -160,9 +153,6 @@ const commandsModule = (props: withAppTypes) => {
storeMeasurements: {
commandFn: actions.storeMeasurements,
},
downloadCSVMeasurementsReport: {
commandFn: actions.downloadCSVMeasurementsReport,
},
};

return {
Expand Down
18 changes: 16 additions & 2 deletions extensions/cornerstone/src/commandsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,22 @@ function commandsModule({
toggleVisibilityMeasurement: ({ uid }) => {
measurementService.toggleVisibilityMeasurement(uid);
},

/**
* Clear the measurements
*/
clearMeasurements: ({ measurementFilter }) => {
measurementService.clearMeasurements(measurementFilter);
clearMeasurements: options => {
const { measurementFilter } = options;
measurementService.clearMeasurements(
measurementFilter ? measurementFilter.bind(options) : null
);
},

/**
* Download the CSV report for the measurements.
*/
downloadCSVMeasurementsReport: ({ measurementFilter }) => {
utils.downloadCSVReport(measurementService.getMeasurements(measurementFilter));
},

// Retrieve value commands
Expand Down Expand Up @@ -1313,6 +1324,9 @@ function commandsModule({
toggleVisibilityMeasurement: {
commandFn: actions.toggleVisibilityMeasurement,
},
downloadCSVMeasurementsReport: {
commandFn: actions.downloadCSVMeasurementsReport,
},
setViewportWindowLevel: {
commandFn: actions.setViewportWindowLevel,
},
Expand Down
2 changes: 1 addition & 1 deletion extensions/cornerstone/src/getPanelModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const getPanelModule = ({ commandsManager, servicesManager, extensionManager }:
name: 'panelMeasurement',
iconName: 'tab-linear',
iconLabel: 'Measure',
label: 'Measurement',
label: 'All Measurements',
component: wrappedPanelMeasurement,
},
{
Expand Down
4 changes: 2 additions & 2 deletions extensions/cornerstone/src/panels/PanelMeasurement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export default function PanelMeasurementTable({
servicesManager,
commandsManager,
customHeader,
measurementFilters,
measurementFilters = { measurementFilter: filterAny },
}: withAppAndFilters): React.ReactNode {
const measurementsPanelRef = useRef(null);

const { measurementService, customizationService } = servicesManager.services;

const displayMeasurements = useMeasurements(servicesManager, {
measurementFilter: filterAny,
measurementFilter: measurementFilters.measurementFilter.bind(measurementFilters),
});

useEffect(() => {
Expand Down
5 changes: 3 additions & 2 deletions modes/basic-test-mode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const ohif = {
wsiSopClassHandler:
'@ohif/extension-cornerstone.sopClassHandlerModule.DicomMicroscopySopClassHandler',
thumbnailList: '@ohif/extension-default.panelModule.seriesList',
measurements: '@ohif/extension-default.panelModule.measurements',
};

const tracked = {
Expand Down Expand Up @@ -46,6 +45,7 @@ const dicomSeg = {

const cornerstone = {
panel: '@ohif/extension-cornerstone.panelModule.panelSegmentation',
measurements: '@ohif/extension-cornerstone.panelModule.panelMeasurement',
};

const dicomPmap = {
Expand Down Expand Up @@ -150,7 +150,8 @@ function modeFactory() {
// leftPanels: [ohif.thumbnailList],
// rightPanels: [dicomSeg.panel, ohif.measurements],
leftPanels: [tracked.thumbnailList],
rightPanels: [cornerstone.panel, tracked.measurements],
// Can use cornerstone.measurements for all measurements
rightPanels: [cornerstone.panel, tracked.measurements, cornerstone.measurements],
// rightPanelClosed: true, // optional prop to start with collapse panels
viewports: [
{
Expand Down
12 changes: 7 additions & 5 deletions platform/core/src/utils/measurementFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ export function filterNone(_measurement) {
}

/**
* Filters the measurements which are found in any of the filters in the provided
* object. This can be used to query for any matching of a set.
* This passes the this argument to the child function(s)
* Filters the measurements which are found in any of the specified
* filters. Strings will be looked up by name.
*/
export function filterOr(measurementFilters) {
export function filterOr(...filters) {
return function (item) {
for (const filter of Object.values(measurementFilters)) {
for (let filter of filters) {
if (typeof filter === 'string') {
filter = this[filter];
}
if (typeof filter !== 'function') {
continue;
}
Expand Down

0 comments on commit a9c9755

Please sign in to comment.