Skip to content

Commit

Permalink
Fixed key error for transforming annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorTatarnikov committed Jan 2, 2025
1 parent b4ceda3 commit b10f636
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion brainglobe_registration/elastix/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def run_registration(


def transform_annotation_image(
annotation_image: npt.NDArray,
annotation_image: npt.NDArray[np.uint32],
transform_parameters: itk.ParameterObject,
) -> npt.NDArray[np.uint32]:
"""
Expand Down
11 changes: 10 additions & 1 deletion brainglobe_registration/registration_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,17 @@ def _on_run_button_click(self):

data_in_atlas_space = transform_image(moving_image, inverse_parameters)

Check warning on line 428 in brainglobe_registration/registration_widget.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_registration/registration_widget.py#L428

Added line #L428 was not covered by tests

registered_annotation_image = transform_annotation_image(
# Creating fresh array is necessary to avoid a crash on Windows
# Otherwise self._atlas_annotations_layer.data.dtype.type returns
# np.uintc which is not supported by ITK. After creating a new array
# annotations.dtype.type returns np.uint32 which is supported by ITK.
annotation = np.array(

Check warning on line 434 in brainglobe_registration/registration_widget.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_registration/registration_widget.py#L434

Added line #L434 was not covered by tests
self._atlas_annotations_layer.data[current_atlas_slice, :, :],
dtype=np.uint32,
)

registered_annotation_image = transform_annotation_image(

Check warning on line 439 in brainglobe_registration/registration_widget.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_registration/registration_widget.py#L439

Added line #L439 was not covered by tests
annotation,
parameters,
)

Expand Down
3 changes: 2 additions & 1 deletion tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def atlas_reference(atlas, slice_number=SLICE_NUMBER):

@pytest.fixture(scope="module")
def atlas_annotation(atlas, slice_number=SLICE_NUMBER):
return atlas.annotation[slice_number, :, :]
# Need the astype call to avoid a crash on Windows
return atlas.annotation[slice_number, :, :].astype(np.uint32)


@pytest.fixture(scope="module")
Expand Down

0 comments on commit b10f636

Please sign in to comment.