lint(curly): consistent use of curly brackets in codebase (#3584)

This commit is contained in:
Alireza authored and GitHub committed 2023-08-09 10:07:33 -04:00
1 parent 9ae3d9f769
commit 5d435424e2
113 files changed
+1501 -1056

No files matched your search

@@ -2,13 +2,12 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { Icon, Tooltip } from '@ohif/ui';
export default function _getStatusComponent({ isHydrated, onStatusClick }) {
let ToolTipMessage = null;
let StatusIcon = null;
const {t} = useTranslation("Common");
const loadStr = t("LOAD");
const { t } = useTranslation('Common');
const loadStr = t('LOAD');
switch (isHydrated) {
case true:
@@ -18,7 +17,7 @@ export default function _getStatusComponent({ isHydrated, onStatusClick }) {
<div>This Segmentation is loaded in the segmentation panel</div>
);
break;
case false:
case false:
StatusIcon = () => <Icon name="status-untracked" />;
ToolTipMessage = () => <div>Click LOAD to load segmentation.</div>;
@@ -42,7 +41,6 @@ export default function _getStatusComponent({ isHydrated, onStatusClick }) {
</div>
);
return (
<>
{ToolTipMessage && (
@@ -308,8 +308,9 @@ function _measurementReferencesSOPInstanceUID(
measurement.coords[0].ReferencedSOPSequence[0]?.ReferencedFrameNumber) ||
1;
if (frameNumber && Number(frameNumber) !== Number(ReferencedFrameNumber))
if (frameNumber && Number(frameNumber) !== Number(ReferencedFrameNumber)) {
return false;
}
for (let j = 0; j < coords.length; j++) {
const coord = coords[j];
@@ -670,7 +671,9 @@ function _getReferencedImagesList(ImagingMeasurementReportContentSequence) {
_getSequenceAsArray(ImageLibraryGroup.ContentSequence).forEach(item => {
const { ReferencedSOPSequence } = item;
if (!ReferencedSOPSequence) return;
if (!ReferencedSOPSequence) {
return;
}
for (const ref of _getSequenceAsArray(ReferencedSOPSequence)) {
if (ref.ReferencedSOPClassUID) {
const { ReferencedSOPClassUID, ReferencedSOPInstanceUID } = ref;
@@ -687,7 +690,9 @@ function _getReferencedImagesList(ImagingMeasurementReportContentSequence) {
}
function _getSequenceAsArray(sequence) {
if (!sequence) return [];
if (!sequence) {
return [];
}
return Array.isArray(sequence) ? sequence : [sequence];
}
@@ -314,18 +314,16 @@ export default class DICOMSRDisplayTool extends AnnotationTool {
);
let canvasCorners;
if (rotation == 90 || rotation == 270) {
canvasCorners = <Array<Types.Point2>>(
utilities.math.ellipse.getCanvasEllipseCorners([
canvasCoordinates[2],
canvasCoordinates[3],
canvasCoordinates[0],
canvasCoordinates[1],
])
);
canvasCorners = utilities.math.ellipse.getCanvasEllipseCorners([
canvasCoordinates[2],
canvasCoordinates[3],
canvasCoordinates[0],
canvasCoordinates[1],
]) as Array<Types.Point2>;
} else {
canvasCorners = <Array<Types.Point2>>(
utilities.math.ellipse.getCanvasEllipseCorners(canvasCoordinates)
);
canvasCorners = utilities.math.ellipse.getCanvasEllipseCorners(
canvasCoordinates
) as Array<Types.Point2>;
}
const lineUID = `${index}`;
@@ -3,12 +3,16 @@ import { DisplaySetService, classes } from '@ohif/core';
const ImageSet = classes.ImageSet;
const findInstance = (measurement, displaySetService: DisplaySetService) => {
const { displaySetInstanceUID, ReferencedSOPInstanceUID: sopUid } =
measurement;
const {
displaySetInstanceUID,
ReferencedSOPInstanceUID: sopUid,
} = measurement;
const referencedDisplaySet = displaySetService.getDisplaySetByUID(
displaySetInstanceUID
);
if (!referencedDisplaySet.images) return;
if (!referencedDisplaySet.images) {
return;
}
return referencedDisplaySet.images.find(it => it.SOPInstanceUID === sopUid);
};
@@ -24,8 +28,12 @@ const findReferencedInstances = (
const instanceById = {};
for (const measurement of displaySet.measurements) {
const { imageId } = measurement;
if (!imageId) continue;
if (instanceById[imageId]) continue;
if (!imageId) {
continue;
}
if (instanceById[imageId]) {
continue;
}
const instance = findInstance(measurement, displaySetService);
if (!instance) {
@@ -9,7 +9,9 @@ const findInstanceMetadataBySopInstanceUID = (displaySets, SOPInstanceUID) => {
let instanceFound;
displaySets.find(displaySet => {
if (!displaySet.images) return false;
if (!displaySet.images) {
return false;
}
instanceFound = displaySet.images.find(
instanceMetadata =>
@@ -12,20 +12,26 @@ const CORNERSTONE_3D_TOOLS_SOURCE_VERSION = '0.1';
const supportedLegacyCornerstoneTags = ['cornerstoneTools@^4.0.0'];
const convertCode = (codingValues, code) => {
if (!code || code.CodingSchemeDesignator === 'CORNERSTONEJS') return;
if (!code || code.CodingSchemeDesignator === 'CORNERSTONEJS') {
return;
}
const ref = `${code.CodingSchemeDesignator}:${code.CodeValue}`;
const ret = { ...codingValues[ref], ref, ...code, text: code.CodeMeaning };
return ret;
};
const convertSites = (codingValues, sites) => {
if (!sites || !sites.length) return;
if (!sites || !sites.length) {
return;
}
const ret = [];
// Do as a loop to convert away from Proxy instances
for (let i = 0; i < sites.length; i++) {
// Deal with irregular conversion from dcmjs
const site = convertCode(codingValues, sites[i][0] || sites[i]);
if (site) ret.push(site);
if (site) {
ret.push(site);
}
}
return (ret.length && ret) || undefined;
};
@@ -287,7 +293,7 @@ function _mapLegacyDataSet(dataset) {
return dataset;
}
const toArray = function (x) {
const toArray = function(x) {
return Array.isArray(x) ? x : [x];
};
@@ -445,7 +445,9 @@ function _subscribeToJumpToMeasurementEvents(
props => {
cacheJumpToMeasurementEvent = props;
const { viewportIndex: jumpIndex, measurement, isConsumed } = props;
if (!measurement || isConsumed) return;
if (!measurement || isConsumed) {
return;
}
if (cacheJumpToMeasurementEvent.cornerstoneViewport === undefined) {
// Decide on which viewport should handle this
cacheJumpToMeasurementEvent.cornerstoneViewport = cornerstoneViewportService.getViewportIndexToJump(
@@ -482,7 +484,9 @@ function _checkForCachedJumpToMeasurementEvents(
viewportGridService,
cornerstoneViewportService
) {
if (!cacheJumpToMeasurementEvent) return;
if (!cacheJumpToMeasurementEvent) {
return;
}
if (cacheJumpToMeasurementEvent.isConsumed) {
cacheJumpToMeasurementEvent = null;
return;
@@ -490,7 +494,9 @@ function _checkForCachedJumpToMeasurementEvents(
const displaysUIDs = displaySets.map(
displaySet => displaySet.displaySetInstanceUID
);
if (!displaysUIDs?.length) return;
if (!displaysUIDs?.length) {
return;
}
// Jump to measurement if the measurement exists
const { measurement } = cacheJumpToMeasurementEvent;
@@ -36,8 +36,9 @@ function CornerstoneOverlays(props) {
}
if (viewportData) {
const viewportInfo =
cornerstoneViewportService.getViewportInfoByIndex(viewportIndex);
const viewportInfo = cornerstoneViewportService.getViewportInfoByIndex(
viewportIndex
);
if (viewportInfo?.viewportOptions?.customViewportProps?.hideOverlays) {
return null;
+12 -4
View File
@@ -35,9 +35,15 @@ const DEFAULT_CONTEXT_MENU_CLICKS = {
function getEventName(evt) {
const button = evt.detail.event.which;
const nameArr = [];
if (evt.detail.event.altKey) nameArr.push('alt');
if (evt.detail.event.ctrlKey) nameArr.push('ctrl');
if (evt.detail.event.shiftKey) nameArr.push('shift');
if (evt.detail.event.altKey) {
nameArr.push('alt');
}
if (evt.detail.event.ctrlKey) {
nameArr.push('ctrl');
}
if (evt.detail.event.shiftKey) {
nameArr.push('shift');
}
nameArr.push('button');
nameArr.push(button);
return nameArr.join('');
@@ -73,7 +79,9 @@ function initContextMenu({
function elementEnabledHandler(evt) {
const { viewportId, element } = evt.detail;
const viewportInfo = cornerstoneViewportService.getViewportInfo(viewportId);
if (!viewportInfo) return;
if (!viewportInfo) {
return;
}
const viewportIndex = viewportInfo.getViewportIndex();
// TODO check update upstream
setEnabledElement(viewportIndex, element);
@@ -21,9 +21,15 @@ const DEFAULT_DOUBLE_CLICK = {
*/
function getDoubleClickEventName(evt: CustomEvent) {
const nameArr = [];
if (evt.detail.event.altKey) nameArr.push('alt');
if (evt.detail.event.ctrlKey) nameArr.push('ctrl');
if (evt.detail.event.shiftKey) nameArr.push('shift');
if (evt.detail.event.altKey) {
nameArr.push('alt');
}
if (evt.detail.event.ctrlKey) {
nameArr.push('ctrl');
}
if (evt.detail.event.shiftKey) {
nameArr.push('shift');
}
nameArr.push('doubleClick');
return nameArr.join('');
}
@@ -190,18 +190,26 @@ class CornerstoneViewportService extends PubSubService
public setPresentations(viewport, presentations?: Presentations): void {
const properties = presentations?.lutPresentation?.properties;
if (properties) viewport.setProperties(properties);
if (properties) {
viewport.setProperties(properties);
}
const camera = presentations?.positionPresentation?.camera;
if (camera) viewport.setCamera(camera);
if (camera) {
viewport.setCamera(camera);
}
}
public getPresentation(viewportIndex: number): Presentation {
const viewportInfo = this.viewportsInfo.get(viewportIndex);
if (!viewportInfo) return;
if (!viewportInfo) {
return;
}
const { viewportType, presentationIds } = viewportInfo.getViewportOptions();
const csViewport = this.getCornerstoneViewportByIndex(viewportIndex);
if (!csViewport) return;
if (!csViewport) {
return;
}
const properties = csViewport.getProperties();
if (properties.isComputedVOI) {
@@ -408,7 +416,9 @@ class CornerstoneViewportService extends PubSubService
viewport.setStack(imageIds, initialImageIndexToUse).then(() => {
viewport.setProperties(properties);
const camera = presentations.positionPresentation?.camera;
if (camera) viewport.setCamera(camera);
if (camera) {
viewport.setCamera(camera);
}
});
}
@@ -745,7 +755,10 @@ class CornerstoneViewportService extends PubSubService
const viewport = this.getCornerstoneViewport(viewportId);
const viewportCamera = viewport.getCamera();
if (viewport instanceof VolumeViewport || viewport instanceof VolumeViewport3D) {
if (
viewport instanceof VolumeViewport ||
viewport instanceof VolumeViewport3D
) {
this._setVolumeViewport(viewport, viewportData, viewportInfo).then(() => {
if (keepCamera) {
viewport.setCamera(viewportCamera);
@@ -95,7 +95,9 @@ const dataContains = (
displaySetUID: string,
imageId?: string
): boolean => {
if (data.displaySetInstanceUID === displaySetUID) return true;
if (data.displaySetInstanceUID === displaySetUID) {
return true;
}
if (imageId && data.isCompositeStack && data.imageIds) {
return !!data.imageIds.find(dataId => dataId === imageId);
}
@@ -123,7 +125,9 @@ class ViewportInfo {
* OR if it is a composite stack and contains the given imageId
*/
public contains(displaySetUID: string, imageId: string): boolean {
if (!this.viewportData?.data) return false;
if (!this.viewportData?.data) {
return false;
}
if (this.viewportData.data.length) {
return !!this.viewportData.data.find(data =>
@@ -212,7 +212,9 @@ export default class DicomFileUploader extends PubSubService {
}
private _checkDicomFile(arrayBuffer: ArrayBuffer) {
if (arrayBuffer.length <= 132) return false;
if (arrayBuffer.length <= 132) {
return false;
}
const arr = new Uint8Array(arrayBuffer.slice(128, 132));
// bytes from 128 to 132 must be "DICM"
return Array.from('DICM').every((char, i) => char.charCodeAt(0) === arr[i]);
@@ -35,8 +35,9 @@ function callInputDialog(
const onSubmitHandler = ({ action, value }) => {
switch (action.id) {
case 'save':
if (typeof validateFunc === 'function' && !validateFunc(value.label))
if (typeof validateFunc === 'function' && !validateFunc(value.label)) {
return;
}
callback(value.label, action.id);
break;
@@ -7,8 +7,12 @@
* @returns [] reordered to be breadth first traversal of lists
*/
export default function interleave(lists) {
if (!lists || !lists.length) return [];
if (lists.length === 1) return lists[0];
if (!lists || !lists.length) {
return [];
}
if (lists.length === 1) {
return lists[0];
}
console.time('interleave');
const useLists = [...lists];
const ret = [];
@@ -3,7 +3,7 @@ import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
import { utils } from '@ohif/core';
const Angle = {
toAnnotation: measurement => { },
toAnnotation: measurement => {},
/**
* Maps cornerstone annotation event data to measurement service format.
@@ -198,7 +198,9 @@ function getDisplayText(mappedAnnotations, displaySet) {
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
if (angle === undefined) return displayText;
if (angle === undefined) {
return displayText;
}
const roundedAngle = utils.roundNumber(angle, 2);
displayText.push(
`${roundedAngle} ${unit} (S: ${SeriesNumber}${instanceText}${frameText})`
@@ -3,7 +3,7 @@ import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
import { utils } from '@ohif/core';
const CobbAngle = {
toAnnotation: measurement => { },
toAnnotation: measurement => {},
/**
* Maps cornerstone annotation event data to measurement service format.
@@ -198,7 +198,9 @@ function getDisplayText(mappedAnnotations, displaySet) {
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
if (angle === undefined) return displayText;
if (angle === undefined) {
return displayText;
}
const roundedAngle = utils.roundNumber(angle, 2);
displayText.push(
`${roundedAngle} ${unit} (S: ${SeriesNumber}${instanceText}${frameText})`
@@ -32,12 +32,15 @@ const Length = {
throw new Error('Tool not supported');
}
const { SOPInstanceUID, SeriesInstanceUID, StudyInstanceUID } =
getSOPInstanceAttributes(
referencedImageId,
cornerstoneViewportService,
viewportId
);
const {
SOPInstanceUID,
SeriesInstanceUID,
StudyInstanceUID,
} = getSOPInstanceAttributes(
referencedImageId,
cornerstoneViewportService,
viewportId
);
let displaySet;
@@ -101,8 +104,11 @@ function getMappedAnnotations(annotation, displaySetService) {
);
}
const { SOPInstanceUID, SeriesInstanceUID, frameNumber } =
getSOPInstanceAttributes(referencedImageId);
const {
SOPInstanceUID,
SeriesInstanceUID,
frameNumber,
} = getSOPInstanceAttributes(referencedImageId);
const displaySet = displaySetService.getDisplaySetForSOPInstanceUID(
SOPInstanceUID,
@@ -173,8 +179,12 @@ function getDisplayText(mappedAnnotations, displaySet) {
const displayText = [];
// Area is the same for all series
const { length, SeriesNumber, SOPInstanceUID, frameNumber } =
mappedAnnotations[0];
const {
length,
SeriesNumber,
SOPInstanceUID,
frameNumber,
} = mappedAnnotations[0];
const instance = displaySet.images.find(
image => image.SOPInstanceUID === SOPInstanceUID
@@ -188,7 +198,9 @@ function getDisplayText(mappedAnnotations, displaySet) {
const instanceText = InstanceNumber ? ` I: ${InstanceNumber}` : '';
const frameText = displaySet.isMultiFrame ? ` F: ${frameNumber}` : '';
if (length === null || length === undefined) return displayText;
if (length === null || length === undefined) {
return displayText;
}
const roundedLength = utils.roundNumber(length, 2);
displayText.push(
`${roundedLength} mm (S: ${SeriesNumber}${instanceText}${frameText})`
@@ -2,7 +2,7 @@ import SUPPORTED_TOOLS from './constants/supportedTools';
import getSOPInstanceAttributes from './utils/getSOPInstanceAttributes';
const PlanarFreehandROI = {
toAnnotation: measurement => { },
toAnnotation: measurement => {},
/**
* Maps cornerstone annotation event data to measurement service format.
@@ -25,12 +25,15 @@ const RectangleROI = {
throw new Error('Tool not supported');
}
const { SOPInstanceUID, SeriesInstanceUID, StudyInstanceUID } =
getSOPInstanceAttributes(
referencedImageId,
CornerstoneViewportService,
viewportId
);
const {
SOPInstanceUID,
SeriesInstanceUID,
StudyInstanceUID,
} = getSOPInstanceAttributes(
referencedImageId,
CornerstoneViewportService,
viewportId
);
let displaySet;
@@ -95,8 +98,11 @@ function getMappedAnnotations(annotation, DisplaySetService) {
);
}
const { SOPInstanceUID, SeriesInstanceUID, frameNumber } =
getSOPInstanceAttributes(referencedImageId);
const {
SOPInstanceUID,
SeriesInstanceUID,
frameNumber,
} = getSOPInstanceAttributes(referencedImageId);
const displaySet = DisplaySetService.getDisplaySetForSOPInstanceUID(
SOPInstanceUID,
@@ -46,7 +46,9 @@ function createDicomJSONApi(dicomJsonConfig) {
const implementation = {
initialize: async ({ query, url }) => {
if (!url) url = query.get('url');
if (!url) {
url = query.get('url');
}
let metaData = getMetaDataByURL(url);
// if we have already cached the data from this specific url
@@ -212,7 +214,9 @@ function createDicomJSONApi(dicomJsonConfig) {
return obj;
});
storeInstances(instances);
if (index === numberOfSeries - 1) setSuccessFlag();
if (index === numberOfSeries - 1) {
setSuccessFlag();
}
});
},
},
@@ -12,8 +12,12 @@ const END_MODALITIES = {
};
const compareValue = (v1, v2, def = 0) => {
if (v1 === v2) return def;
if (v1 < v2) return -1;
if (v1 === v2) {
return def;
}
if (v1 < v2) {
return -1;
}
return 1;
};
@@ -1,4 +1,4 @@
export default function (wadoRoot) {
export default function(wadoRoot) {
return {
series: (StudyInstanceUID, SeriesInstanceUID) => {
return new Promise((resolve, reject) => {
@@ -15,7 +15,7 @@ export default function (wadoRoot) {
console.log(xhr);
xhr.onreadystatechange = function () {
xhr.onreadystatechange = function() {
//Call a function when the state changes.
if (xhr.readyState == 4) {
switch (xhr.status) {
@@ -36,12 +36,16 @@ export default class StaticWadoClient extends api.DICOMwebClient {
* @returns
*/
async searchForStudies(options) {
if (!this.staticWado) return super.searchForStudies(options);
if (!this.staticWado) {
return super.searchForStudies(options);
}
const searchResult = await super.searchForStudies(options);
const { queryParams } = options;
if (!queryParams) return searchResult;
if (!queryParams) {
return searchResult;
}
const lowerParams = this.toLowerParams(queryParams);
const filtered = searchResult.filter(study => {
@@ -63,11 +67,15 @@ export default class StaticWadoClient extends api.DICOMwebClient {
}
async searchForSeries(options) {
if (!this.staticWado) return super.searchForSeries(options);
if (!this.staticWado) {
return super.searchForSeries(options);
}
const searchResult = await super.searchForSeries(options);
const { queryParams } = options;
if (!queryParams) return searchResult;
if (!queryParams) {
return searchResult;
}
const lowerParams = this.toLowerParams(queryParams);
const filtered = searchResult.filter(series => {
@@ -112,8 +120,12 @@ export default class StaticWadoClient extends api.DICOMwebClient {
actual = actual.Alphabetic;
}
if (typeof actual == 'string') {
if (actual.length === 0) return true;
if (desired.length === 0 || desired === '*') return true;
if (actual.length === 0) {
return true;
}
if (desired.length === 0 || desired === '*') {
return true;
}
if (desired[0] === '*' && desired[desired.length - 1] === '*') {
// console.log(`Comparing ${actual} to ${desired.substring(1, desired.length - 1)}`)
return actual.indexOf(desired.substring(1, desired.length - 1)) != -1;
@@ -131,9 +143,13 @@ export default class StaticWadoClient extends api.DICOMwebClient {
/** Compares a pair of dates to see if the value is within the range */
compareDateRange(range, value) {
if (!value) return true;
if (!value) {
return true;
}
const dash = range.indexOf('-');
if (dash === -1) return this.compareValues(range, value);
if (dash === -1) {
return this.compareValues(range, value);
}
const start = range.substring(0, dash);
const end = range.substring(dash + 1);
return (!start || value >= start) && (!end || value <= end);
@@ -150,11 +166,17 @@ export default class StaticWadoClient extends api.DICOMwebClient {
*/
filterItem(key: string, queryParams, study, sourceFilterMap) {
const altKey = sourceFilterMap[key] || key;
if (!queryParams) return true;
if (!queryParams) {
return true;
}
const testValue = queryParams[key] || queryParams[altKey];
if (!testValue) return true;
if (!testValue) {
return true;
}
const valueElem = study[key] || study[altKey];
if (!valueElem) return false;
if (!valueElem) {
return false;
}
if (valueElem.vr == 'DA') {
return this.compareDateRange(testValue, valueElem.Value[0]);
}
@@ -276,7 +276,9 @@ function _mapMeasurementToDisplay(measurement, index, types) {
if (findingSites) {
const siteText = [];
findingSites.forEach(site => {
if (site?.text !== label) siteText.push(site.text);
if (site?.text !== label) {
siteText.push(site.text);
}
});
displayText = [...siteText, ...displayText];
}
+6 -2
View File
@@ -9,12 +9,16 @@ function debounce(func, wait, immediate) {
args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
if (!immediate) {
func.apply(context, args);
}
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
if (callNow) {
func.apply(context, args);
}
};
}
@@ -40,8 +40,8 @@ NestedMenu.propTypes = {
};
NestedMenu.defaultProps = {
icon: "tool-more-menu",
label: "More",
icon: 'tool-more-menu',
label: 'More',
};
export default NestedMenu;
@@ -50,7 +50,7 @@ function ViewerLayout({
// dataSourceIdx === -1
// ? undefined
// : `datasources=${pathname.substring(dataSourceIdx + 1)}`;
// Todo: Handle parameters in a better way.
const query = new URLSearchParams(window.location.search);
const configUrl = query.get('configUrl');
@@ -69,7 +69,7 @@ function ViewerLayout({
navigate({
pathname: '/',
search: decodeURIComponent(searchQuery.toString())
search: decodeURIComponent(searchQuery.toString()),
});
};
+6 -2
View File
@@ -129,13 +129,17 @@ const commandsModule = ({
stage,
} = hangingProtocolService.getActiveProtocol();
const enableListener = button => {
if (!button.id) return;
if (!button.id) {
return;
}
const { commands, items } = button.props || button;
if (items) {
items.forEach(enableListener);
}
const hpCommand = commands?.find?.(isHangingProtocolCommand);
if (!hpCommand) return;
if (!hpCommand) {
return;
}
const { protocolId, stageIndex, stageId } = hpCommand.commandOptions;
const isActive =
(!protocolId || protocolId === protocol.id) &&
@@ -22,7 +22,9 @@ export const findOrCreateViewport = (
options: Record<string, unknown>
) => {
const byPositionViewport = viewportsByPosition?.[positionId];
if (byPositionViewport) return { ...byPositionViewport };
if (byPositionViewport) {
return { ...byPositionViewport };
}
const { protocolId, stageIndex } = hangingProtocolService.getState();
// Setup the initial in display correctly for initial view/select
@@ -83,17 +83,21 @@ export default function getCustomizationModule() {
*/
{
id: 'ohif.overlayItem',
content: function (props) {
if (this.condition && !this.condition(props)) return null;
content: function(props) {
if (this.condition && !this.condition(props)) {
return null;
}
const { instance } = props;
const value =
instance && this.attribute
? instance[this.attribute]
: this.contentF && typeof this.contentF === 'function'
? this.contentF(props)
: null;
if (!value) return null;
? this.contentF(props)
: null;
if (!value) {
return null;
}
return (
<span
@@ -117,7 +121,7 @@ export default function getCustomizationModule() {
* This function clones the object and child objects to prevent
* changes to the original customization object.
*/
transform: function (customizationService: CustomizationService) {
transform: function(customizationService: CustomizationService) {
// Don't modify the children, as those are copied by reference
const clonedObject = { ...this };
clonedObject.menus = this.menus.map(menu => ({ ...menu }));
+6 -2
View File
@@ -23,9 +23,13 @@ const getDirectURL = (config, params) => {
singlepart: fetchPart = 'video',
} = params;
const value = instance[tag];
if (!value) return undefined;
if (!value) {
return undefined;
}
if (value.DirectRetrieveURL) return value.DirectRetrieveURL;
if (value.DirectRetrieveURL) {
return value.DirectRetrieveURL;
}
if (value.InlineBinary) {
const blob = utils.b64toBlob(value.InlineBinary, defaultType);
value.DirectRetrieveURL = URL.createObjectURL(blob);
@@ -47,10 +47,14 @@ const reuseCachedLayout = (
for (let idx = 0; idx < state.viewports.length; idx++) {
const viewport = state.viewports[idx];
const { displaySetOptions, displaySetInstanceUIDs } = viewport;
if (!displaySetOptions) continue;
if (!displaySetOptions) {
continue;
}
for (let i = 0; i < displaySetOptions.length; i++) {
const displaySetUID = displaySetInstanceUIDs[i];
if (!displaySetUID) continue;
if (!displaySetUID) {
continue;
}
if (idx === activeViewportIndex && i === 0) {
displaySetSelectorMap[
`${activeStudyUID}:activeDisplaySet:0`
@@ -41,7 +41,9 @@ class DicomMicroscopyViewport extends Component {
const { microscopyService } = this.props.servicesManager.services;
this.microscopyService = microscopyService;
this.debouncedResize = debounce(() => {
if (this.viewer) this.viewer.resize();
if (this.viewer) {
this.viewer.resize();
}
}, 100);
}
@@ -107,8 +107,12 @@ const itemGenerator = (props: any) => {
props.formatTime = formatDICOMTime;
props.formatPN = formatPN;
props.formatNumberPrecision = formatNumberPrecision;
if (condition && !condition(props)) return null;
if (!contents && !valueFunc) return null;
if (condition && !condition(props)) {
return null;
}
if (!contents && !valueFunc) {
return null;
}
const value = valueFunc && valueFunc(props);
const contentsValue = (contents && contents(props)) || [
{ className: 'mr-1', value: title },
@@ -1,10 +1,16 @@
const listComponentGenerator = props => {
const { list, itemGenerator } = props;
if (!list) return;
if (!list) {
return;
}
return list.map(item => {
if (!item) return;
if (!item) {
return;
}
const generator = item.generator || itemGenerator;
if (!generator) throw new Error(`No generator for ${item}`);
if (!generator) {
throw new Error(`No generator for ${item}`);
}
return generator({ ...props, item });
});
};
@@ -22,7 +22,9 @@ export default function getCommandsModule({
deleteMeasurement: ({ uid }) => {
if (uid) {
const roiAnnotation = microscopyService.getAnnotation(uid);
if (roiAnnotation) microscopyService.removeAnnotation(roiAnnotation);
if (roiAnnotation) {
microscopyService.removeAnnotation(roiAnnotation);
}
}
},
@@ -72,7 +74,7 @@ export default function getCommandsModule({
].indexOf(toolName) >= 0
) {
// TODO: read from configuration
let options = {
const options = {
geometryType: toolName,
vertexEnabled: true,
styleOptions: styles.default,
@@ -140,7 +142,9 @@ export default function getCommandsModule({
);
let onoff = false; // true if this will toggle on
for (let i = 0; i < overlays.length; i++) {
if (i === 0) onoff = overlays.item(0).classList.contains('hidden');
if (i === 0) {
onoff = overlays.item(0).classList.contains('hidden');
}
overlays.item(i).classList.toggle('hidden');
}
@@ -5,7 +5,9 @@
* @returns {string} formatted name
*/
export default function formatDICOMPatientName(name) {
if (typeof name !== 'string') return;
if (typeof name !== 'string') {
return;
}
/**
* Convert the first ^ to a ', '. String.replace() only affects
@@ -56,7 +56,7 @@ export default class MicroscopyService extends PubSubService {
clear() {
this.managedViewers.forEach(managedViewer => managedViewer.destroy());
this.managedViewers.clear();
for (var key in this.annotations) {
for (const key in this.annotations) {
delete this.annotations[key];
}
@@ -124,7 +124,9 @@ export default class MicroscopyService extends PubSubService {
_onRoiModified(data) {
const { roiGraphic, managedViewer } = data;
const roiAnnotation = this.getAnnotation(roiGraphic.uid);
if (!roiAnnotation) return;
if (!roiAnnotation) {
return;
}
roiAnnotation.setRoiGraphic(roiGraphic);
roiAnnotation.setViewState(managedViewer.getViewState());
}
@@ -156,7 +158,10 @@ export default class MicroscopyService extends PubSubService {
_onRoiUpdated(data) {
const { roiGraphic, managedViewer } = data;
this.synchronizeViewers(managedViewer);
this._broadcastEvent(EVENTS.ANNOTATION_UPDATED, this.getAnnotation(roiGraphic.uid));
this._broadcastEvent(
EVENTS.ANNOTATION_UPDATED,
this.getAnnotation(roiGraphic.uid)
);
}
/**
@@ -170,8 +175,13 @@ export default class MicroscopyService extends PubSubService {
_onRoiSelected(data) {
const { roiGraphic } = data;
const selectedAnnotation = this.getAnnotation(roiGraphic.uid);
if (selectedAnnotation && selectedAnnotation !== this.getSelectedAnnotation()) {
if (this.selectedAnnotation) this.clearSelection();
if (
selectedAnnotation &&
selectedAnnotation !== this.getSelectedAnnotation()
) {
if (this.selectedAnnotation) {
this.clearSelection();
}
this.selectedAnnotation = selectedAnnotation;
this._broadcastEvent(EVENTS.ANNOTATION_SELECTED, selectedAnnotation);
}
@@ -183,11 +193,26 @@ export default class MicroscopyService extends PubSubService {
* @param {ViewerManager} managedViewer The viewer being added
*/
_addManagedViewerSubscriptions(managedViewer) {
managedViewer._roiAddedSubscription = managedViewer.subscribe(ViewerEvents.ADDED, this._onRoiAdded);
managedViewer._roiModifiedSubscription = managedViewer.subscribe(ViewerEvents.MODIFIED, this._onRoiModified);
managedViewer._roiRemovedSubscription = managedViewer.subscribe(ViewerEvents.REMOVED, this._onRoiRemoved);
managedViewer._roiUpdatedSubscription = managedViewer.subscribe(ViewerEvents.UPDATED, this._onRoiUpdated);
managedViewer._roiSelectedSubscription = managedViewer.subscribe(ViewerEvents.UPDATED, this._onRoiSelected);
managedViewer._roiAddedSubscription = managedViewer.subscribe(
ViewerEvents.ADDED,
this._onRoiAdded
);
managedViewer._roiModifiedSubscription = managedViewer.subscribe(
ViewerEvents.MODIFIED,
this._onRoiModified
);
managedViewer._roiRemovedSubscription = managedViewer.subscribe(
ViewerEvents.REMOVED,
this._onRoiRemoved
);
managedViewer._roiUpdatedSubscription = managedViewer.subscribe(
ViewerEvents.UPDATED,
this._onRoiUpdated
);
managedViewer._roiSelectedSubscription = managedViewer.subscribe(
ViewerEvents.UPDATED,
this._onRoiSelected
);
}
/**
@@ -196,11 +221,16 @@ export default class MicroscopyService extends PubSubService {
* @param {ViewerManager} managedViewer The viewer being removed
*/
_removeManagedViewerSubscriptions(managedViewer) {
managedViewer._roiAddedSubscription && managedViewer._roiAddedSubscription.unsubscribe();
managedViewer._roiModifiedSubscription && managedViewer._roiModifiedSubscription.unsubscribe();
managedViewer._roiRemovedSubscription && managedViewer._roiRemovedSubscription.unsubscribe();
managedViewer._roiUpdatedSubscription && managedViewer._roiUpdatedSubscription.unsubscribe();
managedViewer._roiSelectedSubscription && managedViewer._roiSelectedSubscription.unsubscribe();
managedViewer._roiAddedSubscription &&
managedViewer._roiAddedSubscription.unsubscribe();
managedViewer._roiModifiedSubscription &&
managedViewer._roiModifiedSubscription.unsubscribe();
managedViewer._roiRemovedSubscription &&
managedViewer._roiRemovedSubscription.unsubscribe();
managedViewer._roiUpdatedSubscription &&
managedViewer._roiUpdatedSubscription.unsubscribe();
managedViewer._roiSelectedSubscription &&
managedViewer._roiSelectedSubscription.unsubscribe();
managedViewer._roiAddedSubscription = null;
managedViewer._roiModifiedSubscription = null;
@@ -460,7 +490,9 @@ export default class MicroscopyService extends PubSubService {
* @param {RoiAnnotation} roiAnnotation The instance to be selected
*/
selectAnnotation(roiAnnotation) {
if (this.selectedAnnotation) this.clearSelection();
if (this.selectedAnnotation) {
this.clearSelection();
}
this.selectedAnnotation = roiAnnotation;
this._broadcastEvent(EVENTS.ANNOTATION_SELECTED, roiAnnotation);
@@ -83,7 +83,9 @@ export default function constructSR(
console.debug('[SR] storing evaluations...', evaluations);
console.debug('[SR] storing presentation state...', presentationState);
if (presentationState) presentationState.marker = marker;
if (presentationState) {
presentationState.marker = marker;
}
/** Avoid incompatibility with dcmjs */
measurements = measurements.map((measurement: any) => {
@@ -38,7 +38,9 @@ export default function coordinateFormatScoord3d2Geometry(
}
function _getPixelSpacing(metadata) {
if (metadata.PixelSpacing) return metadata.PixelSpacing;
if (metadata.PixelSpacing) {
return metadata.PixelSpacing;
}
const functionalGroup = metadata.SharedFunctionalGroupsSequence[0];
const pixelMeasures = functionalGroup.PixelMeasuresSequence[0];
return pixelMeasures.PixelSpacing;
@@ -4,8 +4,8 @@
* @param filename
*/
export function saveByteArray(buffer: ArrayBuffer, filename: string) {
var blob = new Blob([buffer], { type: 'application/dicom' });
var link = document.createElement('a');
const blob = new Blob([buffer], { type: 'application/dicom' });
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = filename;
link.click();
@@ -344,7 +344,9 @@ function _mapMeasurementToDisplay(measurement, types, displaySetService) {
if (findingSites) {
const siteText = [];
findingSites.forEach(site => {
if (site?.text !== label) siteText.push(site.text);
if (site?.text !== label) {
siteText.push(site.text);
}
});
displayText = [...siteText, ...displayText];
}
@@ -1 +1,4 @@
export default (study, extraData) => Math.max(...(extraData?.displaySets?.map?.(ds => (ds.numImageFrames ?? 0))) || [0]);
export default (study, extraData) =>
Math.max(
...(extraData?.displaySets?.map?.(ds => ds.numImageFrames ?? 0) || [0])
);
@@ -1 +1 @@
export default (study, extraData) => extraData?.displaySets?.length;
export default (study, extraData) => extraData?.displaySets?.length;
@@ -4,30 +4,37 @@
* From 'this', it uses:
* `sameAttribute` as the attribute name to look for
* `sameDisplaySetId` as the display set id to look for
* From `options`, it looks for
* From `options`, it looks for
*/
export default function (displaySet, options) {
export default function(displaySet, options) {
const { sameAttribute, sameDisplaySetId } = this;
if( !sameAttribute ) {
console.log("sameAttribute not defined in", this);
if (!sameAttribute) {
console.log('sameAttribute not defined in', this);
return `sameAttribute not defined in ${this.id}`;
}
if( !sameDisplaySetId ) {
console.log("sameDisplaySetId not defined in", this);
if (!sameDisplaySetId) {
console.log('sameDisplaySetId not defined in', this);
return `sameDisplaySetId not defined in ${this.id}`;
}
const { displaySetMatchDetails, displaySets } = options;
const match = displaySetMatchDetails.get(sameDisplaySetId);
if( !match ) {
console.log("No match for display set", sameDisplaySetId);
if (!match) {
console.log('No match for display set', sameDisplaySetId);
return false;
}
const { displaySetInstanceUID } = match;
const altDisplaySet = displaySets.find(it => it.displaySetInstanceUID==displaySetInstanceUID);
if( !altDisplaySet ) {
console.log("No display set found with", displaySetInstanceUID, "in", displaySets);
const altDisplaySet = displaySets.find(
it => it.displaySetInstanceUID == displaySetInstanceUID
);
if (!altDisplaySet) {
console.log(
'No display set found with',
displaySetInstanceUID,
'in',
displaySets
);
return false;
}
const testValue = altDisplaySet[sameAttribute];
return testValue===displaySet[sameAttribute];
}
return testValue === displaySet[sameAttribute];
}
@@ -2,9 +2,11 @@ const codeMenuItem = {
id: '@ohif/contextMenuAnnotationCode',
/** Applies the code value setup for this item */
transform: function (customizationService) {
transform: function(customizationService) {
const { code: codeRef } = this;
if (!codeRef) throw new Error(`item ${this} has no code ref`);
if (!codeRef) {
throw new Error(`item ${this} has no code ref`);
}
const codingValues = customizationService.get('codingValues');
const code = codingValues[codeRef];
return {
@@ -117,7 +117,7 @@ function calculateSuvPeak(
const secondaryCircleWorld = vec3.create();
const bottomWorld = vec3.create();
const topWorld = vec3.create();
referenceVolumeImageData.indexToWorld(<vec3>maxIJK, secondaryCircleWorld);
referenceVolumeImageData.indexToWorld(maxIJK as vec3, secondaryCircleWorld);
vec3.scaleAndAdd(bottomWorld, secondaryCircleWorld, direction, -diameter / 2);
vec3.scaleAndAdd(topWorld, secondaryCircleWorld, direction, diameter / 2);
const suvPeakCirclePoints = [bottomWorld, topWorld] as [