Skip to content

Commit

Permalink
test two step
Browse files Browse the repository at this point in the history
  • Loading branch information
waltsims committed Nov 19, 2024
1 parent 87d5d63 commit 4ba0095
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions kwave/utils/matlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ def matlab_mask(arr: np.ndarray, mask: np.ndarray, diff: Optional[int] = None) -
"""

if mask.dtype == "uint8":
mask = mask.astype(np.int16)

if diff is None:
return np.expand_dims(arr.ravel(order="F")[mask.ravel(order="F")], axis=-1) # compatibility, n => [n, 1]
flat_mask = mask.ravel(order="F")
else:
return np.expand_dims(arr.ravel(order="F")[mask.ravel(order="F") + diff], axis=-1) # compatibility, n => [n, 1]
flat_mask = mask.ravel(order="F") + diff
return np.expand_dims(arr.ravel(order="F")[flat_mask], axis=-1) # compatibility, n => [n, 1]


def unflatten_matlab_mask(arr: np.ndarray, mask: np.ndarray, diff: Optional[int] = None) -> Tuple[Union[int, np.ndarray], ...]:
Expand Down

0 comments on commit 4ba0095

Please sign in to comment.