Skip to content

Conversation

@Hendrik-code
Copy link
Owner

No description provided.

@Hendrik-code Hendrik-code self-assigned this Jun 11, 2025
@Hendrik-code Hendrik-code requested a review from Copilot June 11, 2025 14:21
@Hendrik-code Hendrik-code added the enhancement New feature or request label Jun 11, 2025
@Hendrik-code Hendrik-code linked an issue Jun 11, 2025 that may be closed by this pull request
@Hendrik-code Hendrik-code marked this pull request as draft June 11, 2025 14:25

This comment was marked as outdated.

@Hendrik-code Hendrik-code marked this pull request as ready for review July 16, 2025 08:41
@Hendrik-code Hendrik-code requested a review from Copilot July 16, 2025 08:41
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 "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))))
Copy link

Copilot AI Jul 16, 2025

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.

Suggested change
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)))

Copilot uses AI. Check for mistakes.
Comment on lines +192 to +200
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]),
Copy link

Copilot AI Jul 16, 2025

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.

Copilot uses AI. Check for mistakes.
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")
Copy link

Copilot AI Jul 16, 2025

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.

Suggested change
print(f"{subject_name}: 28 in {actual_labels} but no 19")
logger.print(f"{subject_name}: 28 in {actual_labels} but no 19")

Copilot uses AI. Check for mistakes.
@property
def has_tea(self) -> bool:
if not self.has_anomaly_entry:
return None
Copy link

Copilot AI Jul 16, 2025

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.

Suggested change
return None
return False

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Hendrik-code Hendrik-code merged commit 45363b2 into main Jul 16, 2025
8 of 9 checks passed
@Hendrik-code Hendrik-code deleted the labelingupdate branch July 16, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

To many T12

3 participants