Skip to content

Commit

Permalink
Minor changes to make contours more consistent/predictable
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbb committed Jul 5, 2024
1 parent d883598 commit 830967c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions caiman/utils/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ def get_contours(A, dims, thr=0.9, thr_method='nrg', swap_dim=False, slice_dim:
if 'csc_matrix' not in str(type(A)):
A = csc_matrix(A)
d, nr = np.shape(A)
d1, d2 = dims[:2]

coordinates = []

Expand Down Expand Up @@ -443,6 +442,7 @@ def get_contours(A, dims, thr=0.9, thr_method='nrg', swap_dim=False, slice_dim:

def get_slice_coords(B: np.ndarray) -> np.ndarray:
"""Get contour coordinates for a 2D slice"""
d1, d2 = B.shape
vertices = find_contours(B.T, thr)
# this fix is necessary for having disjoint figures and borders plotted correctly
v = np.atleast_2d([np.nan, np.nan])
Expand All @@ -451,8 +451,8 @@ def get_slice_coords(B: np.ndarray) -> np.ndarray:
if num_close_coords < 2:
if num_close_coords == 0:
# case angle
newpt = np.round(vtx[-1, :] / [d2, d1]) * [d2, d1]
vtx = np.concatenate((vtx, newpt[np.newaxis, :]), axis=0)
newpt = np.round(np.mean(vtx[[0, -1], :], axis=0) / [d2, d1]) * [d2, d1]
vtx = np.concatenate((newpt[np.newaxis, :], vtx, newpt[np.newaxis, :]), axis=0)
else:
# case one is border
vtx = np.concatenate((vtx, vtx[0, np.newaxis]), axis=0)
Expand Down

0 comments on commit 830967c

Please sign in to comment.