Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): support more values for the useSharedArrayBuffer #3688

Merged
merged 9 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion extensions/cornerstone-dicom-seg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/tools": "^1.16.4",
"@cornerstonejs/tools": "^1.19.3",
"react-color": "^2.19.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function _getDisplaySetsFromSeries(instances, servicesManager, extensionManager)
const referencedSeriesSequence = instance.ReferencedSeriesSequence;

if (!referencedSeriesSequence) {
throw new Error('ReferencedSeriesSequence is missing for the SEG');
console.error('ReferencedSeriesSequence is missing for the SEG');
return;
}

const referencedSeries = referencedSeriesSequence[0] || referencedSeriesSequence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
name: 'Radius (mm)',
id: 'brush-radius',
type: 'range',
min: 0.01,
max: 100,
min: 0.5,
max: 99.5,
value: state.Brush.brushSize,
step: 0.5,
onChange: value => onBrushSizeChange(value, 'Brush'),
Expand Down Expand Up @@ -281,8 +281,8 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
name: 'Radius (mm)',
type: 'range',
id: 'eraser-radius',
min: 0.01,
max: 100,
min: 0.5,
max: 99.5,
value: state.Eraser.brushSize,
step: 0.5,
onChange: value => onBrushSizeChange(value, 'Eraser'),
Expand Down Expand Up @@ -337,8 +337,8 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
name: 'Radius (mm)',
id: 'threshold-radius',
type: 'range',
min: 0.01,
max: 100,
min: 0.5,
max: 99.5,
value: state.ThresholdBrush.brushSize,
step: 0.5,
onChange: value => onBrushSizeChange(value, 'ThresholdBrush'),
Expand Down
6 changes: 3 additions & 3 deletions extensions/cornerstone-dicom-sr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.16.5",
"@cornerstonejs/core": "^1.16.5",
"@cornerstonejs/tools": "^1.16.5",
"@cornerstonejs/adapters": "^1.19.3",
"@cornerstonejs/core": "^1.19.3",
"@cornerstonejs/tools": "^1.19.3",
"classnames": "^2.3.2"
}
}
10 changes: 5 additions & 5 deletions extensions/cornerstone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.16.5",
"@cornerstonejs/dicom-image-loader": "^1.19.3",
"@ohif/core": "3.7.0-beta.87",
"@ohif/ui": "3.7.0-beta.87",
"dcmjs": "^0.29.6",
Expand All @@ -52,10 +52,10 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.16.5",
"@cornerstonejs/core": "^1.16.5",
"@cornerstonejs/streaming-image-volume-loader": "^1.16.5",
"@cornerstonejs/tools": "^1.16.5",
"@cornerstonejs/adapters": "^1.19.3",
"@cornerstonejs/core": "^1.19.3",
"@cornerstonejs/streaming-image-volume-loader": "^1.19.3",
"@cornerstonejs/tools": "^1.19.3",
"@kitware/vtk.js": "27.3.1",
"html2canvas": "^1.4.1",
"lodash.debounce": "4.0.8",
Expand Down
29 changes: 18 additions & 11 deletions extensions/cornerstone/src/init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ export default async function init({
appConfig,
}: Types.Extensions.ExtensionParams): Promise<void> {
// Note: this should run first before initializing the cornerstone
switch (appConfig.useSharedArrayBuffer) {
case 'AUTO':
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.AUTO);
break;
case 'FALSE':
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.FALSE);
break;
default:
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.TRUE);
// DO NOT CHANGE THE ORDER
const value = appConfig.useSharedArrayBuffer;
let sharedArrayBufferDisabled = false;

if (value === 'AUTO') {
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.AUTO);
} else if (value === 'FALSE' || value === false) {
jbocce marked this conversation as resolved.
Show resolved Hide resolved
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.FALSE);
sharedArrayBufferDisabled = true;
} else {
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.TRUE);
}

await cs3DInit({
Expand Down Expand Up @@ -99,10 +101,15 @@ export default async function init({
window.extensionManager = extensionManager;
window.commandsManager = commandsManager;

if (appConfig.showWarningMessageForCrossOrigin && !window.crossOriginIsolated) {
if (
appConfig.showWarningMessageForCrossOrigin &&
!window.crossOriginIsolated &&
!sharedArrayBufferDisabled
) {
uiNotificationService.show({
title: 'Cross Origin Isolation',
message: 'Cross Origin Isolation is not enabled, volume rendering will not work (e.g., MPR)',
message:
'Cross Origin Isolation is not enabled, read more about it here: https://docs.ohif.org/faq/',
type: 'warning',
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function MicroscopyPanel(props: IMicroscopyPanelProps) {
}
onSaveComplete({
title: 'SR Saved',
meassage: 'Measurements downloaded successfully',
message: 'Measurements downloaded successfully',
type: 'success',
});
} else {
Expand Down
4 changes: 2 additions & 2 deletions extensions/measurement-tracking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"start": "yarn run dev"
},
"peerDependencies": {
"@cornerstonejs/core": "^1.16.5",
"@cornerstonejs/tools": "^1.16.5",
"@cornerstonejs/core": "^1.19.3",
"@cornerstonejs/tools": "^1.19.3",
"@ohif/core": "3.7.0-beta.87",
"@ohif/extension-cornerstone-dicom-sr": "3.7.0-beta.87",
"@ohif/ui": "3.7.0-beta.87",
Expand Down
37 changes: 10 additions & 27 deletions platform/app/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,6 @@ Cypress.Commands.add('drag', { prevSubject: 'element' }, (...args) =>
DragSimulator.simulate(...args)
);

/**
* Command to perform two clicks into two different positions. Each position must be [x, y].
* The positions are considering the element as reference, therefore, top-left of the element will be (0, 0).
*
* @param {*} viewport - Selector for viewport we would like to interact with
* @param {number[]} firstClick - Click position [x, y]
* @param {number[]} secondClick - Click position [x, y]
*/
Cypress.Commands.add('addLine', (viewport, firstClick, secondClick) => {
const performClick = (alias, x, y) => {
cy.get(alias).as(`axu-${alias}`).click(x, y, { force: true, multiple: true }).wait(1000);
};

cy.get(viewport).as('viewportAlias');
const [x1, y1] = firstClick;
const [x2, y2] = secondClick;

// First click
performClick('@viewportAlias', x1, y1);

// Second click
performClick('@viewportAlias', x2, y2);

cy.wait(1000);
});

/**
* Command to perform three clicks into three different positions. Each position must be [x, y].
* The positions are considering the element as reference, therefore, top-left of the element will be (0, 0).
Expand Down Expand Up @@ -280,7 +254,16 @@ Cypress.Commands.add(

cy.get('@lengthButton').should('have.class', 'active');

cy.addLine('.cornerstone-canvas', firstClick, secondClick);
cy.get('@viewport').then($viewport => {
const [x1, y1] = firstClick;
const [x2, y2] = secondClick;

cy.wrap($viewport)
.click(x1, y1, { force: true })
.wait(1000)
.click(x2, y2, { force: true })
.wait(1000);
});
}
);

Expand Down
2 changes: 1 addition & 1 deletion platform/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.16.5",
"@cornerstonejs/dicom-image-loader": "^1.19.3",
"@ohif/core": "3.7.0-beta.87",
"@ohif/extension-cornerstone": "3.7.0-beta.87",
"@ohif/extension-cornerstone-dicom-rt": "3.7.0-beta.87",
Expand Down
2 changes: 1 addition & 1 deletion platform/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.16.5",
"@cornerstonejs/dicom-image-loader": "^1.19.3",
"@ohif/ui": "3.7.0-beta.87",
"cornerstone-math": "0.1.9",
"dicom-parser": "^1.8.21"
Expand Down
30 changes: 15 additions & 15 deletions platform/core/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import * as Extensions from '../extensions/ExtensionManager';
import * as HangingProtocol from './HangingProtocol';
import Services from './Services';
import Hotkey from '../classes/Hotkey';
import { DataSourceDefinition } from './DataSource';
import {
import type * as Extensions from '../extensions/ExtensionManager';
import type * as HangingProtocol from './HangingProtocol';
import type Services from './Services';
import type Hotkey from '../classes/Hotkey';
import type { DataSourceDefinition } from './DataSource';
import type {
BaseDataSourceConfigurationAPI,
BaseDataSourceConfigurationAPIItem,
} from './DataSourceConfigurationAPI';

export * from '../services/CustomizationService/types';
export type * from '../services/CustomizationService/types';
// Separate out some generic types
export * from './AppConfig';
export * from './Consumer';
export * from './Command';
export * from './DisplaySet';
export * from './StudyMetadata';
export * from './PanelModule';
export * from './IPubSub';
export * from './Color';
export type * from './AppConfig';
export type * from './Consumer';
export type * from './Command';
export type * from './DisplaySet';
export type * from './StudyMetadata';
export type * from './PanelModule';
export type * from './IPubSub';
export type * from './Color';

/**
* Export the types used within the various services and managers, but
Expand Down
2 changes: 1 addition & 1 deletion platform/docs/docs/configuration/configurationFiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Here are a list of some options available:
decoding. Defaults to minimum of `navigator.hardwareConcurrency` and
what is specified by `maxNumberOfWebWorkers`. Some windows machines require smaller values.
- `acceptHeader` : accept header to request specific dicom transfer syntax ex : [ 'multipart/related; type=image/jls; q=1', 'multipart/related; type=application/octet-stream; q=0.1' ]
- `requestTransferSyntaxUID` : Request a specific Tansfer syntax from dicom web server ex: 1.2.840.10008.1.2.4.80 (applied only if acceptHeader is not set)
- `requestTransferSyntaxUID` : Request a specific Transfer syntax from dicom web server ex: 1.2.840.10008.1.2.4.80 (applied only if acceptHeader is not set)
- `omitQuotationForMultipartRequest`: Some servers (e.g., .NET) require the `multipart/related` request to be sent without quotation marks. Defaults to `false`. If your server doesn't require this, then setting this flag to `true` might improve performance (by removing the need for preflight requests). Also note that
if auth headers are used, a preflight request is required.
- `maxNumRequests`: The maximum number of requests to allow in parallel. It is an object with keys of `interaction`, `thumbnail`, and `prefetch`. You can specify a specific number for each type.
Expand Down
5 changes: 5 additions & 0 deletions platform/docs/docs/deployment/cors.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ In particular, three of OHIF’s features depend on these configurations:
- [XMLHttpRequests to fetch data from data sources](#cors-in-ohif)



## SharedArrayBuffer
A `SharedArrayBuffer` is a JavaScript object that is similar to an `ArrayBuffer` but can be shared between web workers and the window that spawned them via the `postMessage` API. See [SharedArrayBuffer in MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) for more information.

:::tip
To turn off Shared Array Buffer completely, just set `useSharedArrayBuffer` to `false` in the [OHIF configuration](../configuration/configurationFiles.md). But keep in mind that you will not get the performance boost that Shared Array Buffer offers for decoding and rendering big volumes where web workers write to the same memory space.
:::

### Security Requirements

In order to use `SharedArrayBuffer` objects in the browser, the following security conditions must be met:
Expand Down
3 changes: 3 additions & 0 deletions platform/docs/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ If you have resources and would like to fund the development of a feature,
please [contact us](https://www.ohif.org) or work with community members that
offer [consulting services][commercial-support].

### Why do I keep seeing a Cross Origin Isolation warning
If you encounter a warning while running OHIF indicating that your application is not cross-origin isolated, it implies that volume rendering, such as MPR, will not function properly since they depend on Shared Array Buffers. To resolve this issue, we recommend referring to our comprehensive guide on Cross Origin Isolation available at [./deployment/cors.md](./deployment/cors.md).

### Who should I contact about Academic Collaborations?

[Gordon J. Harris](https://www.dfhcc.harvard.edu/insider/member-detail/member/gordon-j-harris-phd/)
Expand Down
11 changes: 10 additions & 1 deletion platform/docs/docs/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ conferences and "hackathons". In this page, we will provide the presentations
and other resources that we have provided to the community in the past:

## 2023

### ITCR 2023 Conference | September 11-13, 2023

Dr. Gordon Harris presented an update on OHIF in [NCI Informatics Technology for Cancer Research Annual Meeting](https://www.itcr2023.org/). You can find the slides and poster here:
[[Slides]](https://docs.google.com/presentation/d/1R38s95db_yZj0WoYdlUbaWGZsWVb3H-3u_hXBZXiTaE/edit?usp=sharing)[[Poster]](https://ohif-assets.s3.us-east-2.amazonaws.com/presentations/OHIF-ITCR-2023-FINAL-PRINT.pdf)




### SIIM 2023 Tech Tools Webinar | April 12th, 2023

Free, Open Source Tools for Research: MONAI and OHIF Viewer
[[Slides](https://docs.google.com/presentation/d/1afJ5Y9Tzukgn7eAbaO1oiCtN7XvIimFdmZP-HcOUofA/edit?usp=sharing)][[Video](https://www.youtube.com/watch?v=lo8J5w5jUJI)]


### [NA-MIC Project Week 38th 2023 - Remote]
### NA-MIC Project Week 38th 2023 - Remote

We participated in the 38th Project Week with three projects around OHIF. [[Website](https://projectweek.na-mic.org/PW38_2023_GranCanaria/)]

Expand Down
4 changes: 2 additions & 2 deletions platform/ui/src/components/AdvancedToolbox/ToolSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function ToolSettings({ options }) {
className="flex items-center"
key={option.id}
>
<div className="w-1/3 text-xs text-[13px]">{option.name}</div>
<div className="w-1/3 text-[13px]">{option.name}</div>
<div className="w-2/3">
<InputRange
minValue={option.min}
Expand All @@ -45,7 +45,7 @@ function ToolSettings({ options }) {
onChange={e => option.onChange(e)}
allowNumberEdit={true}
showAdjustmentArrows={false}
inputClassName="ml-2 w-4/5"
inputClassName="ml-1 w-4/5"
/>
</div>
</div>
Expand Down
19 changes: 16 additions & 3 deletions platform/ui/src/components/InputNumber/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ const InputNumber: React.FC<{
showAdjustmentArrows = true,
}) => {
const [numberValue, setNumberValue] = useState(value);
const [isFocused, setIsFocused] = useState(false);

const maxDigits = getMaxDigits(maxValue, step);
const inputWidth = Math.max(maxDigits * 10, showAdjustmentArrows ? 20 : 28);
const arrowWidth = showAdjustmentArrows ? 20 : 0;
const containerWidth = `${inputWidth + arrowWidth}px`;
const decimalPlaces = Number.isInteger(step) ? 0 : step.toString().split('.')[1].length;

useEffect(() => {
setNumberValue(value);
Expand Down Expand Up @@ -81,8 +83,17 @@ const InputNumber: React.FC<{
onChange(newValue);
};

const increment = () => updateValue(numberValue + step);
const decrement = () => updateValue(numberValue - step);
const handleFocus = () => {
setIsFocused(true);
};

const handleBlur = () => {
setIsFocused(false);
setNumberValue(parseFloat(numberValue).toFixed(decimalPlaces));
};

const increment = () => updateValue(parseFloat(numberValue) + step);
const decrement = () => updateValue(parseFloat(numberValue) - step);

return (
<div className="flex flex-1 flex-col">
Expand All @@ -101,8 +112,10 @@ const InputNumber: React.FC<{
<div className="flex">
<input
type="number"
value={numberValue}
value={isFocused ? numberValue : parseFloat(numberValue).toFixed(decimalPlaces)}
step={step}
onFocus={handleFocus}
onBlur={handleBlur}
onChange={handleChange}
className={'input-number w-full bg-black text-center text-[12px] text-white'}
style={{ width: inputWidth }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ InputNumber is a component that allows you to use as a number value
<Story
name="Overview"
args={{
step: 1,
value: 1000,
minValue: 0,
maxValue: 1000,
step: 0.5,
value: 15,
minValue: 0.5,
maxValue: 99.5,
size: 'sm',
showAdjustmentArrows: true,
onChange: () => console.log('input range change'),
Expand Down
Loading
Loading