Skip to content

Commit

Permalink
changed examples
Browse files Browse the repository at this point in the history
  • Loading branch information
yfukai committed Jul 4, 2022
1 parent 0308d96 commit 796a6e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Example usage: tracking pre-detected spots

.. literalinclude:: ../examples/lap_tracking_example.py
:language: python
:emphasize-lines: 29-35
:emphasize-lines: 29-37
5 changes: 3 additions & 2 deletions examples/brownian_motion_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
from matplotlib import pyplot as plt

from laptrack import laptrack
from laptrack import LapTrack

track_length = 100
track_count = 10
Expand Down Expand Up @@ -41,7 +41,8 @@
plt.legend()

spots = [np.array([pos[t] for pos in brownian_poss]) for t in range(track_length)]
tree = laptrack(spots)
lt = LapTrack()
tree = lt.predict(spots)
#%% # noqa:
for edge in tree.edges():
if (edge[0][0] + 1 != edge[1][0]) or (edge[0][1] != edge[1][1]):
Expand Down
8 changes: 5 additions & 3 deletions examples/lap_tracking_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pandas as pd

from laptrack import laptrack
from laptrack import LapTrack

script_path = path.dirname(path.realpath(__file__))
filename = "../tests/data/trackmate_tracks_with_splitting_spots.csv"
Expand All @@ -26,13 +26,15 @@
# ]

max_distance = 15
track_tree = laptrack(
coords,
lt = LapTrack(
track_dist_metric="sqeuclidean",
splitting_dist_metric="sqeuclidean",
track_cost_cutoff=max_distance**2,
splitting_cost_cutoff=max_distance**2,
)
track_tree = lt.predict(
coords,
)

for edge in track_tree.edges():
print(edge)
Expand Down
7 changes: 4 additions & 3 deletions examples/napari_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from matplotlib import pyplot as plt
from skimage.feature import blob_log

from laptrack import laptrack
from laptrack import LapTrack

#%% # noqa:
viewer = napari.Viewer()
Expand Down Expand Up @@ -65,7 +65,8 @@

# %%
spots_for_tracking = [spots[spots[:, 0] == j][:, 1:] for j in range(track_length)]
track_tree = laptrack(spots_for_tracking)
lt = LapTrack()
track_tree = lt.predict(spots_for_tracking)

tracks = []
for i, segment in enumerate(nx.connected_components(track_tree)):
Expand Down Expand Up @@ -105,7 +106,7 @@
for j in np.sort(np.unique(extracted_spots[:, 0]))
]

test_track = laptrack(extracted_spots_for_tracking, gap_closing_cost_cutoff=False)
test_track = lt.predict(extracted_spots_for_tracking, gap_closing_cost_cutoff=False)
for edge in test_track.edges():
_e = np.array(edge)
pos = [extracted_spots_for_tracking[frame][ind] for frame, ind in edge]
Expand Down

0 comments on commit 796a6e2

Please sign in to comment.