Skip to content
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

split_into_halves existed in atlas_commons; remove the copy here #26

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions atlas_densities/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Generic Atlas files tools"""

from typing import Dict, Tuple, Union
from typing import Dict, Union

import numpy as np
import scipy.ndimage
Expand Down Expand Up @@ -82,31 +82,6 @@ def get_region_mask(
return query_region_mask(region, annotation, region_map)


def split_into_halves(
volume: NumericArray,
halfway_offset: int = 0,
) -> Tuple[NumericArray, NumericArray]:
"""
Split input 3D volume into two halves along the z-axis.

Args:
volume: 3D numeric array.
halfway_offset: Optional offset used for the
splitting along the z-axis.
Returns:
tuple(left_volume, right_volume), the two halves of the
input volume. Each has the same shape as `volume`.
Voxels are zeroed for the z-values above, respectively
below, the half of the z-dimension.
"""
z_halfway = volume.shape[2] // 2 + halfway_offset
left_volume = volume.copy()
left_volume[..., z_halfway:] = 0
right_volume = volume.copy()
right_volume[..., :z_halfway] = 0
return left_volume, right_volume


def is_obtuse_angle(vector_field_1: NumericArray, vector_field_2: NumericArray) -> BoolArray:
"""
Returns a mask indicating which vector pairs form an obtuse angle.
Expand Down
30 changes: 0 additions & 30 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,36 +75,6 @@ def test_get_region_mask():
npt.assert_array_equal(mask, expected)


def test_split_into_halves():
volume = np.array(
[
[[0, 1, 2], [2, 3, 4]],
[[4, 5, 6], [7, 8, 9]],
],
dtype=np.int64,
)
halves = tested.split_into_halves(volume)
npt.assert_array_equal(
halves[0],
np.array(
[
[[0, 0, 0], [2, 0, 0]],
[[4, 0, 0], [7, 0, 0]],
],
dtype=np.int64,
),
)
npt.assert_array_equal(
halves[1],
np.array(
[
[[0, 1, 2], [0, 3, 4]],
[[0, 5, 6], [0, 8, 9]],
]
),
)


def test_is_obtuse_angle():
vector_field_1 = np.array(
[
Expand Down