Skip to content

Commit

Permalink
fix stdValue + optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Celian-abd committed Jul 3, 2024
1 parent 6102e5d commit 38509fe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions extensions/tmtv/src/commandsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,16 @@ const commandsModule = ({ servicesManager, commandsManager, extensionManager }:
voxelCount++;
}
}
const mean = segmentationValues.reduce((a, b) => a + b, 0) / voxelCount;

const stats = {
minValue: segmentationMin,
maxValue: segmentationMax,
meanValue: segmentationValues.reduce((a, b) => a + b, 0) / voxelCount,
meanValue: mean,
stdValue: Math.sqrt(
segmentationValues.reduce((a, b) => a + b * b, 0) / voxelCount -
segmentationValues.reduce((a, b) => a + b, 0) / voxelCount ** 2
),
segmentationValues
.map((k) => (k - mean) ** 2)
.reduce((acc, curr) => acc + curr, 0) / voxelCount),
volume: voxelCount * spacing[0] * spacing[1] * spacing[2] * 1e-3,
};

Expand Down

0 comments on commit 38509fe

Please sign in to comment.