chore(prettier): full repo linting and code reformatting once and for all (#3627)
This commit is contained in:
1 parent
01500a2d4c
commit
9045ddaedc
656 files changed
+21737
-20628
No files matched your search
@@ -41,21 +41,12 @@ function calculateSuvPeak(
|
||||
}
|
||||
|
||||
if (labelmap.scalarData.length !== referenceVolume.scalarData.length) {
|
||||
throw new Error(
|
||||
'labelmap and referenceVolume must have the same number of pixels'
|
||||
);
|
||||
throw new Error('labelmap and referenceVolume must have the same number of pixels');
|
||||
}
|
||||
|
||||
const {
|
||||
scalarData: labelmapData,
|
||||
dimensions,
|
||||
imageData: labelmapImageData,
|
||||
} = labelmap;
|
||||
const { scalarData: labelmapData, dimensions, imageData: labelmapImageData } = labelmap;
|
||||
|
||||
const {
|
||||
scalarData: referenceVolumeData,
|
||||
imageData: referenceVolumeImageData,
|
||||
} = referenceVolume;
|
||||
const { scalarData: referenceVolumeData, imageData: referenceVolumeImageData } = referenceVolume;
|
||||
|
||||
let boundsIJK;
|
||||
// Todo: using the first annotation for now
|
||||
@@ -69,10 +60,7 @@ function calculateSuvPeak(
|
||||
return ijk as Types.Point3;
|
||||
});
|
||||
|
||||
boundsIJK = utilities.boundingBox.getBoundingBoxAroundShape(
|
||||
rectangleCornersIJK,
|
||||
dimensions
|
||||
);
|
||||
boundsIJK = utilities.boundingBox.getBoundingBoxAroundShape(rectangleCornersIJK, dimensions);
|
||||
}
|
||||
|
||||
let max = 0;
|
||||
@@ -96,16 +84,9 @@ function calculateSuvPeak(
|
||||
}
|
||||
};
|
||||
|
||||
utilities.pointInShapeCallback(
|
||||
labelmapImageData,
|
||||
() => true,
|
||||
callback,
|
||||
boundsIJK
|
||||
);
|
||||
utilities.pointInShapeCallback(labelmapImageData, () => true, callback, boundsIJK);
|
||||
|
||||
const direction = labelmapImageData
|
||||
.getDirection()
|
||||
.slice(0, 3) as Types.Point3;
|
||||
const direction = labelmapImageData.getDirection().slice(0, 3) as Types.Point3;
|
||||
|
||||
/**
|
||||
* 2. Find the bottom and top of the great circle for the second sphere (1cc sphere)
|
||||
@@ -120,10 +101,7 @@ function calculateSuvPeak(
|
||||
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 [
|
||||
Types.Point3,
|
||||
Types.Point3
|
||||
];
|
||||
const suvPeakCirclePoints = [bottomWorld, topWorld] as [Types.Point3, Types.Point3];
|
||||
|
||||
/**
|
||||
* 3. Find the Mean and Max of the 1cc sphere centered on the suv Max of the previous
|
||||
|
||||
@@ -11,10 +11,7 @@ import { utilities } from '@cornerstonejs/tools';
|
||||
* @param {number} segmentIndex
|
||||
* @returns {number} TMTV in ml
|
||||
*/
|
||||
function calculateTMTV(
|
||||
labelmaps: Array<Types.IImageVolume>,
|
||||
segmentIndex = 1
|
||||
): number {
|
||||
function calculateTMTV(labelmaps: Array<Types.IImageVolume>, segmentIndex = 1): number {
|
||||
const volumeId = 'mergedLabelmap';
|
||||
|
||||
const mergedLabelmap = utilities.segmentation.createMergedLabelmapForIndex(
|
||||
@@ -24,10 +21,7 @@ function calculateTMTV(
|
||||
);
|
||||
|
||||
const { imageData, spacing } = mergedLabelmap;
|
||||
const values = imageData
|
||||
.getPointData()
|
||||
.getScalars()
|
||||
.getData();
|
||||
const values = imageData.getPointData().getScalars().getData();
|
||||
|
||||
// count non-zero values inside the outputData, this would
|
||||
// consider the overlapping regions to be only counted once
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,7 +1,4 @@
|
||||
export default function createAndDownloadTMTVReport(
|
||||
segReport,
|
||||
additionalReportRows
|
||||
) {
|
||||
export default function createAndDownloadTMTVReport(segReport, additionalReportRows) {
|
||||
const firstReport = segReport[Object.keys(segReport)[0]];
|
||||
const columns = Object.keys(firstReport);
|
||||
const csv = [columns.join(',')];
|
||||
@@ -11,9 +8,7 @@ export default function createAndDownloadTMTVReport(
|
||||
columns.forEach(column => {
|
||||
// if it is array then we need to replace , with space to avoid csv parsing error
|
||||
row.push(
|
||||
Array.isArray(segmentation[column])
|
||||
? segmentation[column].join(' ')
|
||||
: segmentation[column]
|
||||
Array.isArray(segmentation[column]) ? segmentation[column].join(' ') : segmentation[column]
|
||||
);
|
||||
});
|
||||
csv.push(row.join(','));
|
||||
|
||||
@@ -98,15 +98,9 @@ function initializeDataset(annotations, metadataProvider) {
|
||||
const rtSOPInstanceUID = DicomMetaDictionary.uid();
|
||||
|
||||
// get the first annotation data
|
||||
const {
|
||||
referencedImageId: imageId,
|
||||
FrameOfReferenceUID,
|
||||
} = annotations[0].metadata;
|
||||
const { referencedImageId: imageId, FrameOfReferenceUID } = annotations[0].metadata;
|
||||
|
||||
const { studyInstanceUID } = metadataProvider.get(
|
||||
'generalSeriesModule',
|
||||
imageId
|
||||
);
|
||||
const { studyInstanceUID } = metadataProvider.get('generalSeriesModule', imageId);
|
||||
|
||||
const patientModule = getPatientModule(imageId, metadataProvider);
|
||||
const rtSeriesModule = getRTSeriesModule(imageId, metadataProvider);
|
||||
@@ -136,23 +130,11 @@ function initializeDataset(annotations, metadataProvider) {
|
||||
}
|
||||
|
||||
function getPatientModule(imageId, metadataProvider) {
|
||||
const generalSeriesModule = metadataProvider.get(
|
||||
'generalSeriesModule',
|
||||
imageId
|
||||
);
|
||||
const generalStudyModule = metadataProvider.get(
|
||||
'generalStudyModule',
|
||||
imageId
|
||||
);
|
||||
const patientStudyModule = metadataProvider.get(
|
||||
'patientStudyModule',
|
||||
imageId
|
||||
);
|
||||
const generalSeriesModule = metadataProvider.get('generalSeriesModule', imageId);
|
||||
const generalStudyModule = metadataProvider.get('generalStudyModule', imageId);
|
||||
const patientStudyModule = metadataProvider.get('patientStudyModule', imageId);
|
||||
const patientModule = metadataProvider.get('patientModule', imageId);
|
||||
const patientDemographicModule = metadataProvider.get(
|
||||
'patientDemographicModule',
|
||||
imageId
|
||||
);
|
||||
const patientDemographicModule = metadataProvider.get('patientDemographicModule', imageId);
|
||||
|
||||
return {
|
||||
Modality: generalSeriesModule.modality,
|
||||
@@ -169,11 +151,7 @@ function getPatientModule(imageId, metadataProvider) {
|
||||
};
|
||||
}
|
||||
|
||||
function getReferencedFrameOfReferenceSequence(
|
||||
toolData,
|
||||
metadataProvider,
|
||||
dataset
|
||||
) {
|
||||
function getReferencedFrameOfReferenceSequence(toolData, metadataProvider, dataset) {
|
||||
const { referencedImageId: imageId, FrameOfReferenceUID } = toolData.metadata;
|
||||
const instance = metadataProvider.get('instance', imageId);
|
||||
const { SeriesInstanceUID } = instance;
|
||||
@@ -190,9 +168,7 @@ function getReferencedFrameOfReferenceSequence(
|
||||
RTReferencedSeriesSequence: [
|
||||
{
|
||||
SeriesInstanceUID,
|
||||
ContourImageSequence: [
|
||||
...ReferencedSeriesSequence[0].ReferencedInstanceSequence,
|
||||
],
|
||||
ContourImageSequence: [...ReferencedSeriesSequence[0].ReferencedInstanceSequence],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -209,10 +185,7 @@ function getReferencedSeriesSequence(toolData, index, metadataProvider) {
|
||||
|
||||
const ReferencedSeriesSequence = [];
|
||||
if (SeriesInstanceUID) {
|
||||
const series = DicomMetadataStore.getSeries(
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID
|
||||
);
|
||||
const series = DicomMetadataStore.getSeries(StudyInstanceUID, SeriesInstanceUID);
|
||||
|
||||
const ReferencedSeries = {
|
||||
SeriesInstanceUID,
|
||||
|
||||
+2
-7
@@ -20,18 +20,13 @@ class AnnotationToPointData {
|
||||
const toolClass = AnnotationToPointData.TOOL_NAMES[toolName];
|
||||
|
||||
if (!toolClass) {
|
||||
throw new Error(
|
||||
`Unknown tool type: ${toolName}, cannot convert to RTSSReport`
|
||||
);
|
||||
throw new Error(`Unknown tool type: ${toolName}, cannot convert to RTSSReport`);
|
||||
}
|
||||
|
||||
// Each toolData should become a list of contours, ContourSequence
|
||||
// contains a list of contours with their pointData, their geometry
|
||||
// type and their length.
|
||||
const ContourSequence = toolClass.getContourSequence(
|
||||
annotation,
|
||||
metadataProvider
|
||||
);
|
||||
const ContourSequence = toolClass.getContourSequence(annotation, metadataProvider);
|
||||
|
||||
// Todo: random rgb color for now, options should be passed in
|
||||
const color = [
|
||||
|
||||
+1
-6
@@ -29,12 +29,7 @@ function getPointData(points) {
|
||||
// Since this is a closed contour, the order of the points is important.
|
||||
// re-order the points to be in the correct order clockwise
|
||||
// Spread to make sure Float32Arrays are converted to arrays
|
||||
const orderedPoints = [
|
||||
...points[0],
|
||||
...points[1],
|
||||
...points[3],
|
||||
...points[2],
|
||||
];
|
||||
const orderedPoints = [...points[0], ...points[1], ...points[3], ...points[2]];
|
||||
const pointsArray = orderedPoints.flat();
|
||||
|
||||
// reduce the precision of the points to 2 decimal places
|
||||
|
||||
@@ -3,10 +3,7 @@ import * as csTools from '@cornerstonejs/tools';
|
||||
function getRoiStats(referencedVolume, annotations) {
|
||||
// roiStats
|
||||
const { imageData } = referencedVolume;
|
||||
const values = imageData
|
||||
.getPointData()
|
||||
.getScalars()
|
||||
.getData();
|
||||
const values = imageData.getPointData().getScalars().getData();
|
||||
|
||||
// Todo: add support for other strategies
|
||||
const { fn, baseValue } = _getStrategyFn('max');
|
||||
@@ -59,9 +56,10 @@ function getThresholdValues(
|
||||
};
|
||||
}
|
||||
|
||||
function _getStrategyFn(
|
||||
statistic
|
||||
): { fn: (a: number, b: number) => number; baseValue: number } {
|
||||
function _getStrategyFn(statistic): {
|
||||
fn: (a: number, b: number) => number;
|
||||
baseValue: number;
|
||||
} {
|
||||
const baseValue = -Infinity;
|
||||
const fn = (number, maxValue) => {
|
||||
if (number > maxValue) {
|
||||
|
||||
+2
-10
@@ -10,11 +10,7 @@ const RectangleROIStartEndThreshold = {
|
||||
* @param {Object} cornerstone Cornerstone event data
|
||||
* @return {Measurement} Measurement instance
|
||||
*/
|
||||
toMeasurement: (
|
||||
csToolsEventDetail,
|
||||
displaySetService,
|
||||
cornerstoneViewportService
|
||||
) => {
|
||||
toMeasurement: (csToolsEventDetail, displaySetService, cornerstoneViewportService) => {
|
||||
const { annotation, viewportId } = csToolsEventDetail;
|
||||
const { metadata, data, annotationUID } = annotation;
|
||||
|
||||
@@ -30,11 +26,7 @@ const RectangleROIStartEndThreshold = {
|
||||
throw new Error('Tool not supported');
|
||||
}
|
||||
|
||||
const {
|
||||
SOPInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
StudyInstanceUID,
|
||||
} = getSOPInstanceAttributes(
|
||||
const { SOPInstanceUID, SeriesInstanceUID, StudyInstanceUID } = getSOPInstanceAttributes(
|
||||
referencedImageId,
|
||||
cornerstoneViewportService,
|
||||
viewportId
|
||||
|
||||
Reference in new issue
Block a user