Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
store matrices as np.arrays instead of lists
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrofelder committed Jun 14, 2022
1 parent 6c183ea commit 7e5f532
Showing 1 changed file with 35 additions and 32 deletions.
67 changes: 35 additions & 32 deletions napari_btrack/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,41 @@ class Matrices:
default_sigmas: List[float] = field(
default_factory=lambda: [1.0, 1.0, 150.0, 15.0, 5.0]
)
unscaled_matrices: Dict[str, List[float]] = field(
unscaled_matrices: Dict[str, npt.NDArray[np.float64]] = field(
default_factory=lambda: dict(
# stop black from reformatting here
# so we can read the matrix entries
# fmt: off
A_cell=[1, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0,
0, 0, 1, 0, 0, 1,
0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 1
],
A_particle=[1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 1],
H=[1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0],
P=[0.1, 0, 0, 0, 0, 0,
0, 0.1, 0, 0, 0, 0,
0, 0, 0.1, 0, 0, 0,
0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 1],
G=[0.5, 0.5, 0.5, 1, 1, 1],
R=[1, 0, 0,
0, 1, 0,
0, 0, 1],
# fmt: on
A_cell=np.array(
[
[1, 0, 0, 1, 0, 0],
[0, 1, 0, 0, 1, 0],
[0, 0, 1, 0, 0, 1],
[0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1],
]
),
A_particle=np.array(
[
[1, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1],
]
),
H=np.array([[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]),
P=np.array(
[
[0.1, 0, 0, 0, 0, 0],
[0, 0.1, 0, 0, 0, 0],
[0, 0, 0.1, 0, 0, 0],
[0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1],
]
),
G=np.array([[0.5, 0.5, 0.5, 1, 1, 1]]),
R=np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]),
)
)

Expand Down Expand Up @@ -114,7 +117,7 @@ def get_sigma(cls, name: str, scaled_matrix: npt.NDArray[np.float64]) -> float:
"""
if name == "A":
name = "A_cell" # doesn't matter which A we use here, as [0][0] is the same
return scaled_matrix[0][0] / cls().unscaled_matrices[name][0]
return scaled_matrix[0][0] / cls().unscaled_matrices[name][0][0]


def run_tracker(
Expand Down

0 comments on commit 7e5f532

Please sign in to comment.