Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ const workerFn = () => {
});
};

const getViewportVolumeHistogram = async (viewport, volume, options?) => {
workerManager.registerWorker('histogram-worker', workerFn, WorkerOptions);
// Register worker once at module load time
workerManager.registerWorker('histogram-worker', workerFn, WorkerOptions);

const getViewportVolumeHistogram = async (viewport, volume, options?) => {
const volumeImageData = viewport.getImageData(volume.volumeId);

if (!volumeImageData) {
Expand All @@ -29,8 +30,7 @@ const getViewportVolumeHistogram = async (viewport, volume, options?) => {
let scalarData = volume.scalarData;

if (volume.numTimePoints > 1) {
const targetTimePoint = volume.numTimePoints - 1; // or any other time point you need
scalarData = volume.voxelManager.getTimePointScalarData(targetTimePoint);
scalarData = volume.voxelManager.getDimensionGroupScalarData(volume.numTimePoints);
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument passed to getDimensionGroupScalarData appears incorrect. The previous code used getTimePointScalarData(targetTimePoint) where targetTimePoint was set to volume.numTimePoints - 1 (a zero-based index). Now volume.numTimePoints (the total count) is being passed, which would be an out-of-bounds index if this method expects a zero-based time point index. This could result in undefined behavior or runtime errors when processing multi-timepoint volumes.

Suggested change
scalarData = volume.voxelManager.getDimensionGroupScalarData(volume.numTimePoints);
const targetTimePoint = volume.numTimePoints - 1;
scalarData = volume.voxelManager.getDimensionGroupScalarData(targetTimePoint);

Copilot uses AI. Check for mistakes.
} else {
scalarData = volume.voxelManager.getCompleteScalarDataArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { getViewportVolumeHistogram } from './getViewportVolumeHistogram';
* Gets node opacity from volume actor
*/
export const getNodeOpacity = (volumeActor, nodeIndex) => {
if (!volumeActor) {
return undefined;
}

const volumeOpacity = volumeActor.getProperty().getScalarOpacity(0);
const nodeValue = [];

Expand All @@ -19,6 +23,10 @@ export const getNodeOpacity = (volumeActor, nodeIndex) => {
* Checks if the opacity applied to the PET volume follows a specific pattern
*/
export const isPetVolumeWithDefaultOpacity = (volumeId: string, volumeActor) => {
if (!volumeActor) {
return false;
}

const volume = cs3DCache.getVolume(volumeId);

if (!volume || volume.metadata.Modality !== 'PT') {
Expand Down Expand Up @@ -59,6 +67,10 @@ export const isPetVolumeWithDefaultOpacity = (volumeId: string, volumeActor) =>
* Checks if volume has constant opacity
*/
export const isVolumeWithConstantOpacity = volumeActor => {
if (!volumeActor) {
return false;
}

const volumeOpacity = volumeActor.getProperty().getScalarOpacity(0);
const opacitySize = volumeOpacity.getSize();
const firstNodeValue = [];
Expand Down Expand Up @@ -91,7 +103,7 @@ export const getWindowLevelsData = async (

const volumeIds = (viewport as Types.IBaseVolumeViewport).getAllVolumeIds();
const viewportProperties = viewport.getProperties();
const { voiRange } = viewportProperties;
const { voiRange } = viewportProperties || {};
const viewportVoi = voiRange
? {
windowWidth: voiRange.upper - voiRange.lower,
Expand Down
14 changes: 10 additions & 4 deletions extensions/default/src/getSopClassHandlerModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { id } from './id';
import getDisplaySetMessages from './getDisplaySetMessages';
import getDisplaySetsFromUnsupportedSeries from './getDisplaySetsFromUnsupportedSeries';
import { chartHandler } from './SOPClassHandlers/chartSOPClassHandler';
import { metaData } from '@cornerstonejs/core';

const {
isImage,
Expand Down Expand Up @@ -50,11 +51,16 @@ function getDisplaySetInfo(instances) {
const timePoint = timePoints[0];
const instancesMap = new Map();

// O(n) to convert it into a map and O(1) to find each instance
instances.forEach(instance => instancesMap.set(instance.imageId, instance));

const firstTimePointInstances = timePoint.map(imageId => instancesMap.get(imageId));
let firstTimePointInstances;

if (instances[0].NumberOfFrames > 1 && timePoints.length > 1) {
// handle multiframe dynamic volume
firstTimePointInstances = timePoints[0].map(imageId => metaData.get('instance', imageId));
} else {
// O(n) to convert it into a map and O(1) to find each instance
instances.forEach(instance => instancesMap.set(instance.imageId, instance));
firstTimePointInstances = timePoint.map(imageId => instancesMap.get(imageId));
}
displaySetInfo = isDisplaySetReconstructable(firstTimePointInstances, appConfig);
} else {
displaySetInfo = isDisplaySetReconstructable(instances, appConfig);
Expand Down
11 changes: 8 additions & 3 deletions modes/preclinical-4d/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,14 @@ function modeFactory({ modeConfiguration }) {
cornerstoneViewportService.EVENTS.VIEWPORT_VOLUMES_CHANGED,
() => {
const viewportId = viewportGridService.getActiveViewportId();
const csViewport = cornerstoneViewportService.getCornerstoneViewport(viewportId);
cineService.playClip(csViewport.element, { viewportId });
// cineService.setIsCineEnabled(true);

if (!viewportId) {
return;
}

const frameRate = 24;
cineService.setIsCineEnabled(true);
cineService.setCine({ id: viewportId, isPlaying: true, frameRate });

unsubscribe();
}
Expand Down
8 changes: 8 additions & 0 deletions platform/ui-next/src/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,11 @@ input[type='number']::-webkit-outer-spin-button {
input[type='number'] {
-moz-appearance: textfield; /* For Firefox */
}

/* disabled class - used for icons and divs based on context */
.ohif-disabled {
pointer-events: none;
cursor: not-allowed;
user-select: none;
opacity: 0.5;
}