Skip to content

Commit

Permalink
all tracks for label docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aelefebv committed Oct 3, 2024
1 parent d998cce commit 5766d60
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions nellie/tracking/all_tracks_for_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,42 @@


class LabelTracks:
"""
A class to track labeled objects over multiple timepoints in a microscopy image using flow interpolation.
Attributes
----------
im_info : ImInfo
An object containing image metadata and memory-mapped image data.
num_t : int
Number of timepoints in the image.
label_im_path : str
Path to the labeled instance image.
im_memmap : np.ndarray or None
Memory-mapped original image data.
label_memmap : np.ndarray or None
Memory-mapped labeled instance image data.
Methods
-------
initialize()
Initializes memory-mapped data for both the raw image and the labeled instance image.
run(label_num=None, start_frame=0, end_frame=None, min_track_num=0, skip_coords=1, max_distance_um=0.5)
Runs the tracking process for labeled objects across timepoints, both forward and backward.
"""
def __init__(self, im_info: ImInfo, num_t: int = None, label_im_path: str = None):
"""
Initializes the LabelTracks class with image metadata, timepoints, and label image path.
Parameters
----------
im_info : ImInfo
An instance of the ImInfo class containing image metadata and paths.
num_t : int, optional
Number of timepoints in the image (default is None, in which case it is inferred from the image metadata).
label_im_path : str, optional
Path to the labeled instance image. If not provided, defaults to the 'im_instance_label' path in `im_info`.
"""
self.im_info = im_info
self.num_t = num_t
if label_im_path is None:
Expand All @@ -19,10 +54,41 @@ def __init__(self, im_info: ImInfo, num_t: int = None, label_im_path: str = None
self.label_memmap = None

def initialize(self):
"""
Initializes memory-mapped data for both the raw image and the labeled instance image.
This method prepares the image data and the labeled data for processing, mapping them into memory.
"""
self.label_memmap = self.im_info.get_memmap(self.label_im_path)
self.im_memmap = self.im_info.get_memmap(self.im_info.im_path)

def run(self, label_num=None, start_frame=0, end_frame=None, min_track_num=0, skip_coords=1, max_distance_um=0.5):
"""
Runs the tracking process for labeled objects across timepoints, using flow interpolation.
This method uses forward and backward interpolation to track objects across multiple frames, starting from a given
frame. It can also track specific labels or all labels in the image.
Parameters
----------
label_num : int, optional
Label number to track. If None, all labels are tracked (default is None).
start_frame : int, optional
The starting frame from which to begin tracking (default is 0).
end_frame : int, optional
The ending frame for the tracking. If None, tracks until the last frame (default is None).
min_track_num : int, optional
Minimum track number to assign to the coordinates (default is 0).
skip_coords : int, optional
The interval at which coordinates are sampled (default is 1).
max_distance_um : float, optional
Maximum distance allowed for interpolation (in micrometers, default is 0.5).
Returns
-------
tuple
A list of tracks and a dictionary of track properties.
"""
if end_frame is None:
end_frame = self.num_t
num_frames = self.label_memmap.shape[0] - 1
Expand Down

0 comments on commit 5766d60

Please sign in to comment.