Skip to content

Commit 82d82d8

Browse files
mix3dJamesAPetts
authored andcommitted
fix: πŸ› improve insertSlice Function
fix: πŸ› improve insertSlice Function
1 parent e4733ac commit 82d82d8

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

β€Žsrc/lib/data/insertSlice.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,21 @@ export default function insertSlice(imageData, index, image) {
3535
}
3636

3737
function _getScalingFunctionForModality(image) {
38-
const patientStudyModule = cornerstone.metaData.get(
39-
'patientStudyModule',
40-
image.imageId
41-
);
38+
const { slope, intercept } = image;
39+
4240
const seriesModule = cornerstone.metaData.get(
4341
'generalSeriesModule',
4442
image.imageId
4543
);
4644

47-
const { slope, intercept } = image;
48-
49-
if (!patientStudyModule) {
50-
throw new Error('patientStudyModule metadata is required');
51-
}
52-
53-
if (!seriesModule) {
54-
throw new Error('seriesModule metadata is required');
55-
}
56-
57-
const modality = seriesModule.modality;
58-
59-
if (modality === 'PT') {
45+
if (seriesModule && seriesModule.modality === 'PT') {
46+
const patientStudyModule = cornerstone.metaData.get(
47+
'patientStudyModule',
48+
image.imageId
49+
);
50+
if (!patientStudyModule) {
51+
throw new Error('patientStudyModule metadata is required');
52+
}
6053
const patientWeight = patientStudyModule.patientWeight; // In kg
6154

6255
if (!patientWeight) {
@@ -112,7 +105,7 @@ function _getScalingFunctionForModality(image) {
112105
}
113106

114107
function _getSUV(slope, intercept, patientWeight, correctedDose, pixel) {
115-
const modalityPixelValue = pixel * slope + intercept;
108+
const modalityPixelValue = _getModalityScaledPixel(slope, intercept, pixel);
116109

117110
return (1000 * modalityPixelValue * patientWeight) / correctedDose;
118111
}

0 commit comments

Comments
Β (0)