From 79e7215371da8314e68568a345c06705c8f48e55 Mon Sep 17 00:00:00 2001 From: Igor Octaviano Date: Fri, 27 Oct 2023 11:45:17 -0300 Subject: [PATCH] Run linting --- src/annotation.js | 2 +- src/bulkAnnotations/getExtendedROI.js | 38 +++++------ src/bulkAnnotations/utils.js | 36 +++++------ src/viewer.js | 91 +++++++++++++-------------- 4 files changed, 82 insertions(+), 85 deletions(-) diff --git a/src/annotation.js b/src/annotation.js index b6306e58..6962666b 100644 --- a/src/annotation.js +++ b/src/annotation.js @@ -794,5 +794,5 @@ export { _getCommonZCoordinate, _getCoordinateDimensionality, _getPoint, - _getCoordinates, + _getCoordinates } diff --git a/src/bulkAnnotations/getExtendedROI.js b/src/bulkAnnotations/getExtendedROI.js index a9f5acb6..eaf6ccc5 100644 --- a/src/bulkAnnotations/getExtendedROI.js +++ b/src/bulkAnnotations/getExtendedROI.js @@ -1,14 +1,14 @@ import dcmjs from 'dcmjs' const getExtendedROI = ({ feature, roi, metadata }) => { - const annotationGroupUID = feature.get("annotationGroupUID") + const annotationGroupUID = feature.get('annotationGroupUID') const annotationGroupMetadata = metadata.AnnotationGroupSequence.find( (item) => item.AnnotationGroupUID === annotationGroupUID ) if (annotationGroupUID == null || annotationGroupMetadata == null) { throw new Error( - "Could not obtain information of annotation from " + + 'Could not obtain information of annotation from ' + `annotation group "${annotationGroupUID}".` ) } @@ -19,16 +19,16 @@ const getExtendedROI = ({ feature, roi, metadata }) => { roi.addEvaluation( new dcmjs.sr.valueTypes.CodeContentItem({ name: new dcmjs.sr.coding.CodedConcept({ - value: "276214006", - meaning: "Finding category", - schemeDesignator: "SCT", + value: '276214006', + meaning: 'Finding category', + schemeDesignator: 'SCT' }), value: new dcmjs.sr.coding.CodedConcept({ value: findingCategory.CodeValue, meaning: findingCategory.CodeMeaning, - schemeDesignator: findingCategory.CodingSchemeDesignator, + schemeDesignator: findingCategory.CodingSchemeDesignator }), - relationshipType: dcmjs.sr.valueTypes.RelationshipTypes.HAS_CONCEPT_MOD, + relationshipType: dcmjs.sr.valueTypes.RelationshipTypes.HAS_CONCEPT_MOD }) ) } @@ -39,16 +39,16 @@ const getExtendedROI = ({ feature, roi, metadata }) => { roi.addEvaluation( new dcmjs.sr.valueTypes.CodeContentItem({ name: new dcmjs.sr.coding.CodedConcept({ - value: "121071", - meaning: "Finding", - schemeDesignator: "DCM", + value: '121071', + meaning: 'Finding', + schemeDesignator: 'DCM' }), value: new dcmjs.sr.coding.CodedConcept({ value: findingType.CodeValue, meaning: findingType.CodeMeaning, - schemeDesignator: findingType.CodingSchemeDesignator, + schemeDesignator: findingType.CodingSchemeDesignator }), - relationshipType: dcmjs.sr.valueTypes.RelationshipTypes.HAS_CONCEPT_MOD, + relationshipType: dcmjs.sr.valueTypes.RelationshipTypes.HAS_CONCEPT_MOD }) ) } @@ -70,25 +70,25 @@ const getExtendedROI = ({ feature, roi, metadata }) => { name: new dcmjs.sr.coding.CodedConcept({ value: name.CodeValue, meaning: name.CodeMeaning, - schemeDesignator: name.CodingSchemeDesignator, + schemeDesignator: name.CodingSchemeDesignator }), unit: new dcmjs.sr.coding.CodedConcept({ value: unit.CodeValue, meaning: unit.CodeMeaning, - schemeDesignator: unit.CodingSchemeDesignator, + schemeDesignator: unit.CodingSchemeDesignator }), - relationshipType: dcmjs.sr.valueTypes.RelationshipTypes.CONTAINS, + relationshipType: dcmjs.sr.valueTypes.RelationshipTypes.CONTAINS }) if (measurementItem.ReferencedImageSequence != null) { const ref = measurementItem.ReferencedImageSequence[0] const image = new dcmjs.sr.valueTypes.ImageContentItem({ name: new dcmjs.sr.coding.CodedConcept({ - value: "121112", - meaning: "Source of Measurement", - schemeDesignator: "DCM", + value: '121112', + meaning: 'Source of Measurement', + schemeDesignator: 'DCM' }), referencedSOPClassUID: ref.ReferencedSOPClassUID, - referencedSOPInstanceUID: ref.ReferencedSOPInstanceUID, + referencedSOPInstanceUID: ref.ReferencedSOPInstanceUID }) if (ref.ReferencedOpticalPathIdentifier != null) { image.ReferencedSOPSequence[0].ReferencedOpticalPathIdentifier = diff --git a/src/bulkAnnotations/utils.js b/src/bulkAnnotations/utils.js index f4ac5031..d59e4b14 100644 --- a/src/bulkAnnotations/utils.js +++ b/src/bulkAnnotations/utils.js @@ -1,13 +1,13 @@ -import PointGeometry from "ol/geom/Point" -import PolygonGeometry from "ol/geom/Polygon" -import Feature from "ol/Feature" -import { getTopLeft, getBottomRight } from "ol/extent" +import PointGeometry from 'ol/geom/Point' +import PolygonGeometry from 'ol/geom/Polygon' +import Feature from 'ol/Feature' +import { getTopLeft, getBottomRight } from 'ol/extent' -import { _getCentroid, _getCoordinates } from "../annotation" +import { _getCoordinates } from '../annotation' import { _scoord3dCoordinates2geometryCoordinates, - _geometryCoordinates2scoord3dCoordinates, -} from "../scoord3dUtils" + _geometryCoordinates2scoord3dCoordinates +} from '../scoord3dUtils' /** * Get viewport bounding box @@ -26,7 +26,7 @@ export const getViewportBoundingBox = ({ view, pyramid, affine }) => { ) return { topLeft: scoord3DCoords[0], - bottomRight: scoord3DCoords[1], + bottomRight: scoord3DCoords[1] } } @@ -66,7 +66,7 @@ export const getPolygonFeature = ({ affineInverse, commonZCoordinate, coordinateDimensionality, - annotationGroupUID, + annotationGroupUID }) => { const offset = graphicIndex[annotationIndex] - 1 @@ -92,7 +92,7 @@ export const getPolygonFeature = ({ } return new Feature({ - geometry: new PolygonGeometry([polygonCoordinates]), + geometry: new PolygonGeometry([polygonCoordinates]) }) } @@ -112,7 +112,7 @@ export const getPointFeature = ({ affineInverse, commonZCoordinate, coordinateDimensionality, - annotationGroupUID, + annotationGroupUID }) => { const offset = graphicIndex[annotationIndex] - 1 const coordinate = _getCoordinates(graphicData, offset, commonZCoordinate) @@ -122,7 +122,7 @@ export const getPointFeature = ({ affineInverse ) return new Feature({ - geometry: new PointGeometry(renderableCoordinate), + geometry: new PointGeometry(renderableCoordinate) }) } @@ -140,7 +140,7 @@ export const getFeaturesFromBulkAnnotations = ({ affineInverse, view, featureFunction, - isHighResolution, + isHighResolution }) => { console.info('create features from bulk annotations') @@ -179,14 +179,14 @@ export const getFeaturesFromBulkAnnotations = ({ affineInverse, commonZCoordinate, coordinateDimensionality, - annotationGroupUID, + annotationGroupUID }) feature.setId(annotationGroupUID + '-' + annotationIndex) - feature.set("annotationGroupUID", annotationGroupUID, true) + feature.set('annotationGroupUID', annotationGroupUID, true) measurements.forEach((measurement, measurementIndex) => { - const key = "measurementValue" + measurementIndex + const key = 'measurementValue' + measurementIndex const value = measurement.values[annotationIndex] /** * Needed for the WebGL renderer. This is required for the point layer which uses webgl @@ -199,12 +199,12 @@ export const getFeaturesFromBulkAnnotations = ({ } return features -}; +} export default { getFeaturesFromBulkAnnotations, getPointFeature, getPolygonFeature, isCoordinateInsideBoundingBox, - getViewportBoundingBox, + getViewportBoundingBox } diff --git a/src/viewer.js b/src/viewer.js index d9a42a1c..37d2b2bc 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -45,11 +45,8 @@ import { _fetchGraphicData, _fetchGraphicIndex, _fetchMeasurements, - _getCentroid, _getCommonZCoordinate, - _getCoordinateDimensionality, - _getCoordinates, - _getPoint + _getCoordinateDimensionality } from './annotation.js' import { ColormapNames, @@ -75,8 +72,7 @@ import { _generateUID, _getUnitSuffix, doContentItemsMatch, - createWindow, - rgb2hex + createWindow } from './utils.js' import { _scoord3dCoordinates2geometryCoordinates, @@ -784,7 +780,7 @@ class VolumeImageViewer { } } - if (this[_options].annotationOptions) { + if (this[_options].annotationOptions) { this[_annotationOptions] = this[_options].annotationOptions } @@ -3109,7 +3105,7 @@ class VolumeImageViewer { if (item.GraphicType === 'POLYLINE') { /* - * We represent graphics as polygons in low zoom levels + * We represent graphics as polygons in low zoom levels * or centroid points when in high zoom levels, but it's unclear whether * the centroid of a polyline would be meaningful. */ @@ -3125,7 +3121,7 @@ class VolumeImageViewer { // TODO: figure out how to use "loader" with bbox or tile "strategy"? const annotationGroupIndex = annotationGroup.annotationGroup.number - 1 const metadataItem = annotationGroup.metadata.AnnotationGroupSequence[annotationGroupIndex] - + /** * Bulkdata may not be available, since it's possible that all information * has been included into the metadata by value as InlineBinary. It must @@ -3138,7 +3134,7 @@ class VolumeImageViewer { } /** - * The number of Annotations in this Annotation Group. + * The number of Annotations in this Annotation Group. * Each point, open polyline or closed polygon, circle, * ellipse or rectangle is counted as one Annotation. */ @@ -3153,8 +3149,8 @@ class VolumeImageViewer { const commonZCoordinate = _getCommonZCoordinate(metadataItem) let areBulkAnnotationsProcessed = false - const cacheBulkAnnotations = (id, data) => this[_retrievedBulkdata][id] = data - const getCachedBulkAnnotations = (id) => this[_retrievedBulkdata][id] + const cacheBulkAnnotations = (id, data) => (this[_retrievedBulkdata][id] = data) + const getCachedBulkAnnotations = (id) => (this[_retrievedBulkdata][id]) const bulkAnnotationsLoader = function (featureFunction, success, failure) { console.info('load bulk annotations layer') @@ -3162,8 +3158,8 @@ class VolumeImageViewer { const processBulkAnnotations = (retrievedBulkdata) => { console.info('process bulk annotations') areBulkAnnotationsProcessed = true - - const [ graphicData, graphicIndex, measurements ] = retrievedBulkdata + + const [graphicData, graphicIndex, measurements] = retrievedBulkdata console.info( 'compute statistics for measurement values ' + @@ -3214,12 +3210,12 @@ class VolumeImageViewer { console.info('number of annotations:', numberOfAnnotations) } - let cachedBulkAnnotations = getCachedBulkAnnotations(annotationGroupUID) + const cachedBulkAnnotations = getCachedBulkAnnotations(annotationGroupUID) if (cachedBulkAnnotations) { try { console.info('use cached bulk annotations') processBulkAnnotations(cachedBulkAnnotations) - } catch(error) { + } catch (error) { console.error('Failed to process cached bulk annotations', error) failure(error) } @@ -3255,11 +3251,11 @@ class VolumeImageViewer { } /** - * The loader function used to load features, from a remote source for example. - * The 'featuresloadend' and 'featuresloaderror' events will only fire if the success + * The loader function used to load features, from a remote source for example. + * The 'featuresloadend' and 'featuresloaderror' events will only fire if the success * and failure callbacks are used. * https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html - * + * * In the loader function "this" is bound to the vector source. */ function pointsLoader (extent, resolution, projection, success, failure) { @@ -3309,8 +3305,8 @@ class VolumeImageViewer { console.info('load high resolution bulk annotations') bulkAnnotationsLoader.call( polygonsSource, - getPolygonFeature, - onLayerLoadSuccess, + getPolygonFeature, + onLayerLoadSuccess, onLayerLoadFailure ) } @@ -3346,14 +3342,14 @@ class VolumeImageViewer { opacity: annotationGroup.style.opacity }), fill: new Fill({ - color: 'rgba(0, 0, 255, 0)', - }), + color: 'rgba(0, 0, 255, 0)' + }) }) annotationGroup.layers = [] annotationGroup.layers[0] = new VectorLayer({ source: polygonsSource, - style: [ polygonStyle ], + style: [polygonStyle] }) annotationGroup.layers[1] = new PointsLayer({ source: pointsSource, @@ -3364,8 +3360,9 @@ class VolumeImageViewer { const initActiveLayer = () => { const polygonsLayer = annotationGroup.layers[0] const pointsLayer = annotationGroup.layers[1] - annotationGroup.activeLayer = isHighResolution() - ? polygonsLayer : pointsLayer + annotationGroup.activeLayer = isHighResolution() + ? polygonsLayer + : pointsLayer } initActiveLayer() @@ -3580,21 +3577,21 @@ class VolumeImageViewer { ) } - const markerType = 'circle' - const topLayerIndex = 0 - const topLayerPixelSpacing = this[_pyramid].pixelSpacings[topLayerIndex] - const baseLayerIndex = this[_pyramid].metadata.length - 1 - const baseLayerPixelSpacing = this[_pyramid].pixelSpacings[baseLayerIndex] - const diameter = 5 * 10 ** -3 // micometer - const markerSize = [ - 'interpolate', - ['exponential', 2], - ['zoom'], - 1, - Math.max(diameter / topLayerPixelSpacing[0], 1), - this[_pyramid].resolutions.length, - Math.min(diameter / baseLayerPixelSpacing[0], 50) - ] + // const markerType = 'circle' + // const topLayerIndex = 0 + // const topLayerPixelSpacing = this[_pyramid].pixelSpacings[topLayerIndex] + // const baseLayerIndex = this[_pyramid].metadata.length - 1 + // const baseLayerPixelSpacing = this[_pyramid].pixelSpacings[baseLayerIndex] + // const diameter = 5 * 10 ** -3 // micometer + // const markerSize = [ + // 'interpolate', + // ['exponential', 2], + // ['zoom'], + // 1, + // Math.max(diameter / topLayerPixelSpacing[0], 1), + // this[_pyramid].resolutions.length, + // Math.min(diameter / baseLayerPixelSpacing[0], 50) + // ] const name = styleOptions.measurement if (name) { @@ -3656,15 +3653,15 @@ class VolumeImageViewer { opacity: annotationGroup.style.opacity }), fill: new Fill({ - color: 'rgba(0, 0, 255, 0)', - }), + color: 'rgba(0, 0, 255, 0)' + }) }) /** Update polygons layer */ const previousPolygonsLayer = annotationGroup.layers[0] const newPolygonsLayer = new VectorLayer({ source: previousPolygonsLayer.getSource(), - style: [ polygonStyle ], + style: [polygonStyle], visible: previousPolygonsLayer.getVisible() }) this[_map].addLayer(newPolygonsLayer) @@ -3726,15 +3723,15 @@ class VolumeImageViewer { opacity: annotationGroup.style.opacity }), fill: new Fill({ - color: 'rgba(0, 0, 255, 0)', - }), + color: 'rgba(0, 0, 255, 0)' + }) }) /** Update polygons layer */ const previousPolygonsLayer = annotationGroup.layers[0] const newPolygonsLayer = new VectorLayer({ source: previousPolygonsLayer.getSource(), - style: [ polygonStyle ], + style: [polygonStyle], visible: previousPolygonsLayer.getVisible() }) this[_map].addLayer(newPolygonsLayer)