Skip to content

Commit

Permalink
add option to update nodes' probabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
JoOkuma committed Oct 2, 2024
1 parent 645fd60 commit b734749
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ultrack/core/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ultrack.core.segmentation.processing import segment
from ultrack.core.solve.processing import solve
from ultrack.imgproc.flow import add_flow
from ultrack.ml.classification import add_nodes_prob
from ultrack.utils.deprecation import rename_argument


Expand Down Expand Up @@ -153,3 +154,11 @@ def to_tracks_layer(self, *args, **kwargs) -> Tuple[pd.DataFrame, Dict]:
def export_by_extension(self, filename: str, overwrite: bool = False) -> None:
self._assert_solved()
export_tracks_by_extension(self.config, filename, overwrite=overwrite)

@functools.wraps(add_nodes_prob)
def add_nodes_prob(
self,
indices: ArrayLike,
probs: ArrayLike,
) -> None:
add_nodes_prob(self.config, indices, probs)
Empty file added ultrack/ml/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions ultrack/ml/classification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from numpy.typing import ArrayLike

from ultrack.config.config import MainConfig
from ultrack.core.database import set_node_values


def add_nodes_prob(
config: MainConfig,
indices: ArrayLike,
probs: ArrayLike,
) -> None:
"""
Add nodes' probabilities to the segmentation/tracking database.
Parameters
----------
config : MainConfig
Main configuration parameters.
indices : ArrayLike
Nodes' indices database index.
probs : ArrayLike
Nodes' probabilities.
"""
set_node_values(
config.data_config,
indices,
node_prob=probs,
)

0 comments on commit b734749

Please sign in to comment.