Skip to content

feat(segmentStatsCalculator): for calculation of statistics #1881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Mar 11, 2025

Conversation

sedghi
Copy link
Member

@sedghi sedghi commented Mar 7, 2025

Introducing Instantiable Calculators

Sometimes, a static calculator just isn't enough. For example, if you want to loop through all the labelmap data and calculate statistics for each segment, you'll need to use separate calculators for each one.

Segment Statistics Calculation:

  • Introduced SegmentStatsCalculator to manage statistics for multiple segments, supporting both individual and collective modes for more versatile statistics calculations.

sedghi added 4 commits March 4, 2025 11:40
…individual and collective modes

This commit introduces a more flexible approach to calculating segmentation statistics by:
- Adding a new SegmentStatsCalculator to manage segment-specific statistics
- Supporting both 'individual' and 'collective' computation modes
- Refactoring VolumetricCalculator and BasicStatsCalculator to support more dynamic statistical analysis
- Updating segmentation statistics worker to use the new calculation method
- Improving example code to demonstrate new statistics calculation features
Copy link

netlify bot commented Mar 7, 2025

Deploy Preview for cornerstone-3d-docs canceled.

Name Link
🔨 Latest commit 62e9a1a
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/67cf80e08d4cd7000856e9ed

@sedghi sedghi changed the title feat/multi getStats feat(segmentStatsCalculator): for calculation of statistics Mar 7, 2025
}
): NamedStatistics {
const { spacing } = options;
const volumeUnit = spacing ? 'mm³' : 'voxels³';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add methods to getCalibratedLengthUnitsAndScale to get the appropriate volume unit. Also, voxel is the unit, voxels^3 would be a 9 dimensional hyper cube.

…tion statistics

- Add volume unit and calibration support to getCalibratedLengthUnitsAndScale
- Update VolumetricCalculator and SegmentStatsCalculator to include calibration and pixel spacing options
- Improve volume statistics calculation with more flexible unit and scaling
@sedghi sedghi requested a review from Copilot March 10, 2025 19:53
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR introduces an instantiable segment statistics calculator to compute statistics for segmentation data either collectively or individually. Key changes include:

  • Adding a new class (SegmentStatsCalculator) to create and manage per‐segment or combined volumetric calculators.
  • Adapting the compute worker and related utility functions to work with the new calculator API.
  • Refactoring existing basic statistics calculators and updating examples and helpers to support the new mode parameter.

Reviewed Changes

File Description
packages/tools/src/utilities/segmentation/SegmentStatsCalculator.ts New class to manage individual and collective segment statistics
packages/tools/src/utilities/segmentation/VolumetricCalculator.ts Refactored state management and statistics calculation for volumes
packages/tools/src/utilities/segmentation/getStatistics.ts Added mode parameter handling (collective vs individual)
packages/tools/examples/labelmapStatistics/index.ts Updated UI to include direct control for individual/collective modes
packages/tools/src/utilities/math/basic/BasicStatsCalculator.ts Refactored to use a state-based approach for accumulating stats
packages/tools/src/workers/computeWorker.js Switched to using SegmentStatsCalculator in place of VolumetricCalculator
packages/tools/src/utilities/getCalibratedUnits.ts Updated to provide calibrated volume units
packages/tools/src/utilities/segmentation/index.ts Updated exports to include the new SegmentStatsCalculator

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

sedghi added 10 commits March 10, 2025 16:02
This commit adds screenshot test images for various segmentation tools (circular brush, scissor, eraser, and sphere brush) across Chromium and WebKit browsers. It also removes two deprecated threshold brush tests for bone and fat segmentation.
@sedghi sedghi force-pushed the feat/multi-getStats branch from 921e458 to 7030468 Compare March 10, 2025 23:18
@sedghi sedghi merged commit cf25a4f into main Mar 11, 2025
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants