Skip to content

Meniscus measures#48

Merged
gattia merged 17 commits intomainfrom
meniscus_measures
Oct 31, 2025
Merged

Meniscus measures#48
gattia merged 17 commits intomainfrom
meniscus_measures

Conversation

@gattia
Copy link
Owner

@gattia gattia commented Oct 30, 2025

Add new MeniscusMesh class and functions to compute meniscal extrusion and meniscal coverage.

Coverage uses the bone surface. It gets the area where cartilage is above the tibia bone. Then it gets the sub-area of the cartilage where the meniscus is above. It can report these individual areas, or the percent coverage (how much of cartilage is covered in meniscus).

Extrusion gets the middle x% (10% by default) of the med or lat tibial cartilage. In this region, it gets the most medial (or lateral) edge of the cartilage projected onto the bone. It then in the sam region, gets the most medial (or lateral) meniscus. It uses the difference between men/cart to compute extrusion.

This can also use an atlas segmentation/labelmap to make it more robust (for the cartialge regions).

Introduced `get_distance_other_surface_at_points_along_unit_vector` to compute distances from a surface to another along a specified unit vector. The function includes parameters for ray casting length and handling cases with no intersection. Updated documentation for clarity.
…tionality

Created new helper function:
_get_distance_with_directions

This iterates over points and a direction vector per point to project rays along the vector, detect intersection(s) and return the distances.

This is then wrapped by two other functions that project vectors normal to the surface, and project vectors using a fixed direction.
- Introduced MeniscusMesh class for creating and analyzing meniscus meshes, including extrusion and coverage metrics.... this MeniscusMesh class isnt really used. Maybe remove? or figure out if/how should update it individually?
- Updated the mesh module to import MeniscusMesh and integrate it with existing functionality.
- Added new functions for computing meniscal extrusion and meniscal coverage
- Enhanced BoneMesh class to support meniscal outcomes computation and caching.
    - Directly call the new meniscal analysis functions to get extrusion/coverage.
- Added tests for meniscal coverage and extrusion calculations, both individually as well as in the BoneMesh class.
- Bumped minimum required Python version from 3.7 to 3.9 in pyproject.toml.
- Dropped support for Python 3.7 and 3.8 in build configurations due to end-of-life status and compatibility issues.
- Updated GitHub Actions workflows to use macOS 14 and removed deprecated macOS 13, ensuring compatibility with Apple Silicon and improved testing across Python versions 3.9 to 3.12.
@gattia gattia requested a review from Copilot October 30, 2025 21:36
Copy link
Contributor

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.

Pull Request Overview

This PR implements meniscal analysis functionality for computing meniscal extrusion (how far the meniscus extends beyond cartilage) and coverage (percentage of cartilage covered by meniscus). The implementation includes:

  • New MeniscusMesh class and analysis functions in mesh_meniscus.py
  • Enhanced BoneMesh class with meniscal analysis methods and properties
  • Convenience API using dict_cartilage_labels to reduce repetitive parameter passing
  • Test suite with comprehensive tests including synthetic shift validation
  • Updated Python version requirements (dropped 3.7-3.8 support)

Reviewed Changes

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

Show a summary per file
File Description
pymskt/mesh/mesh_meniscus.py New module implementing meniscal analysis functions and MeniscusMesh class
pymskt/mesh/meshes.py Added meniscal analysis methods to BoneMesh, dict_cartilage_labels support, lazy-evaluation properties
pymskt/mesh/meshTools.py Refactored distance calculation to support custom direction vectors for IS-axis ray casting
testing/mesh/meshMeniscus/compute_meniscal_extrusion_test.py Comprehensive test suite validating extrusion calculations with synthetic shifts
testing/mesh/meshMeniscus/compute_meniscal_coverage_test.py Placeholder tests for coverage computation (TODO)
testing/mesh/meshMeniscus/MeniscusMesh_create_test.py Placeholder tests for MeniscusMesh class (TODO)
pyproject.toml Updated Python version requirements (>=3.9, dropped 3.7-3.8)
.github/workflows/ Updated CI to use macos-14 runners and Python 3.9-3.12
README.md Added meniscal analysis usage example
Comments suppressed due to low confidence (2)

pymskt/mesh/mesh_meniscus.py:1

  • Using assertions for input validation in production code is not recommended. Assertions can be disabled with Python's -O flag. Replace with explicit if check and raise ValueError instead.
"""

pymskt/mesh/meshes.py:1

  • [nitpick] The order of values extracted from dict_cartilage_labels is not guaranteed in Python <3.7 (though dicts are ordered in 3.7+). Since the minimum version is now 3.9, this is fine, but consider documenting that the order matches insertion order or using explicit ordering (e.g., sorted keys) if specific ordering is required.
import os

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1399 to +1401
copy_._meniscus_meshes = self._meniscus_meshes.copy()
copy_._meniscal_outcomes = self._meniscal_outcomes
copy_._meniscal_cart_labels = self._meniscal_cart_labels
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

Shallow copy is performed for _meniscus_meshes dictionary, but _meniscal_outcomes and _meniscal_cart_labels are simply assigned by reference. If these contain mutable objects (dictionaries), modifications to the copy will affect the original. Consider whether deep copying is needed for these attributes as well, consistent with the deep parameter.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

gattia and others added 6 commits October 30, 2025 15:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI commented Oct 30, 2025

@gattia I've opened a new pull request, #49, to work on those changes. Once the pull request is ready, I'll request review from you.

gattia and others added 5 commits October 30, 2025 15:07
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…_measures

Merging server development with mac development.
@gattia gattia merged commit 0f56f05 into main Oct 31, 2025
10 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