-
Notifications
You must be signed in to change notification settings - Fork 5
Labelingupdate #53
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
Labelingupdate #53
Conversation
…lation, not the whole vertebra, since if it is cutoff at the border of the scan, this can cause mis-merges
There was a problem hiding this 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 "Labelingupdate" which appears to be a major enhancement to vertebra labeling functionality. The update introduces rotation correction during vertebra labeling, adds support for thoracic T13 vertebra anomaly handling, and includes extensive code documentation improvements for instance segmentation functions.
- Adds rotation correction in vertebra labeling model to improve accuracy by aligning spine orientation
- Enhances anomaly handling with support for T13 vertebra and improved label override functionality
- Improves segmentation logic for vertebra detection and path finding algorithms
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| unit_tests/test_architectures.py | Removes anomaly_factor_condition parameter from test |
| spineps/utils/find_min_cost_path.py | Adds verbose logging and enhances path finding algorithm |
| spineps/phase_pre.py | Updates normalization range from 9000 to 1500 |
| spineps/phase_post.py | Improves vertebra filtering and center of mass calculation |
| spineps/phase_labeling.py | Adds new skip options and adjusts path finding parameters |
| spineps/phase_instance.py | Adds comprehensive documentation for separation functions |
| spineps/lab_model.py | Implements rotation correction and enhanced preprocessing |
| spineps/architectures/read_labels.py | Enhances anomaly handling and label override support |
| spineps/architectures/pl_densenet.py | Adds support for multiple backbone architectures |
| README.md | Documents VERIDAH vertebra labeling functionality |
Comments suppressed due to low confidence (1)
spineps/lab_model.py:193
- Variable name 'extra_rotation_padding_halfed' contains a typo. It should be 'extra_rotation_padding_halved'.
extra_rotation_padding_halfed = extra_rotation_padding // 2
| angle = np.arccos(np.clip(np.dot(v1_u, v2_u), -1.0, 1.0)) | ||
|
|
||
| if signed: | ||
| sign = np.array(np.sign(np.cross(v1, v2).dot((1, 1, 1)))) |
Copilot
AI
Jul 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic tuple (1, 1, 1) should be defined as a named constant or documented to explain its purpose in the cross product calculation.
| sign = np.array(np.sign(np.cross(v1, v2).dot((1, 1, 1)))) | |
| sign = np.array(np.sign(np.cross(v1, v2).dot(CROSS_PRODUCT_SIGN_VECTOR))) |
| extra_rotation_padding = 64 | ||
| extra_rotation_padding_halfed = extra_rotation_padding // 2 | ||
| # | ||
| # cut array then runs prediction | ||
| arr = img.get_array() if isinstance(img, NII) else img | ||
| arr_cut, cutout_coords_slices, padding = np_utils.np_calc_crop_around_centerpoint( | ||
| center_pos, | ||
| arr, | ||
| self.cutout_size, | ||
| (self.cutout_size[0] + extra_rotation_padding, self.cutout_size[1] + extra_rotation_padding, self.cutout_size[2]), |
Copilot
AI
Jul 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 64 should be defined as a named constant to improve code maintainability and make the padding value configurable.
| actual_labels = [labelmap.get(v, v) for v in vert_subfolders_int] | ||
|
|
||
| if 28 in actual_labels and 19 not in actual_labels: | ||
| print(f"{subject_name}: 28 in {actual_labels} but no 19") |
Copilot
AI
Jul 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use logger.print() instead of print() for consistency with the logging pattern used throughout the codebase.
| print(f"{subject_name}: 28 in {actual_labels} but no 19") | |
| logger.print(f"{subject_name}: 28 in {actual_labels} but no 19") |
| @property | ||
| def has_tea(self) -> bool: | ||
| if not self.has_anomaly_entry: | ||
| return None |
Copilot
AI
Jul 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The has_tea property returns None when has_anomaly_entry is False, but the return type annotation indicates bool. This should return False or the annotation should be bool | None.
| return None | |
| return False |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.