Skip to content

Commit

Permalink
fix(calculate-suv): A zero PatientWeight should be considered as if i…
Browse files Browse the repository at this point in the history
…t is missing (#19)
  • Loading branch information
jbocce authored Sep 7, 2023
1 parent d6d69d8 commit f2c4fda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/calculateSUVScalingFactors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export default function calculateSUVScalingFactors(
);
}

if (PatientWeight === null || PatientWeight === undefined) {
// Treat null, undefined and zero as a missing PatientWeight.
if (!PatientWeight) {
throw new Error(
'PatientWeight value is missing. It is not possible to calculate the SUV factors'
);
Expand Down
10 changes: 10 additions & 0 deletions test/calculateSUVScalingFactors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ describe('calculateSUVScalingFactor Error Handling', () => {
}).toThrowError('Decay time cannot be less than zero');
});

it('throws an Error if the PatientWeight is zero', () => {
input[0].PatientWeight = 0;

expect(() => {
calculateSUVScalingFactors(input);
}).toThrowError(
`PatientWeight value is missing. It is not possible to calculate the SUV factors`
);
});

it('throws an Error if series-level metadata are different', () => {
expect(() => {
calculateSUVScalingFactors(multiInput);
Expand Down

0 comments on commit f2c4fda

Please sign in to comment.