Skip to content

Commit

Permalink
split_into_halves existed in atlas_commons; remove the copy here (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeplf authored Mar 21, 2023
1 parent 3b224e8 commit ab6eecb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 56 deletions.
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

0 comments on commit ab6eecb

Please sign in to comment.