traccuracy.loaders
Subpackage for loading tracking data into memory
This subpackage contains functions for loading ground truth or tracking method outputs into memory as TrackingGraph objects. Each loading function must return one TrackingGraph object which has a track graph and optionally contains a corresponding segmentation.
Package Contents
Functions
|
Read the CTC segmentations and track file and create a TrackingGraph. |
|
Load a directory of individual frames into a stack. |
|
Load a graph into memory from a geff file |
|
Load point-based tracking data into a TrackingGraph from a csv-like file |
- traccuracy.loaders.load_ctc_data(data_dir: str, track_path: str | None = None, name: str | None = None, run_checks: bool = True) traccuracy._tracking_graph.TrackingGraph[source]
Read the CTC segmentations and track file and create a TrackingGraph.
- Parameters:
data_dir (str) – Path to directory containing CTC tiffs.
track_path (optional, str) – Path to CTC track file. If not passed, finds
*_track.txtin data_dir.name (optional, str) – Name of data to store in TrackingGraph
run_checks (optional, bool) – If set to
True(default), runs checks on the data to ensure valid CTC format.
- Returns:
TrackingGraph object containing segmentations and graph.
- Return type:
- Raises:
ValueError – If the tracks file is not found. If
run_checksis True, whenever any of the CTC format checks are violated. Ifrun_checksis False, whenever any other Exception occurs while creating the graph.
- traccuracy.loaders.load_tiffs(data_dir: str) numpy.ndarray[source]
Load a directory of individual frames into a stack.
- Parameters:
data_dir (str) – Path to directory of tiff files
- Raises:
FileNotFoundError – No tif files found in data_dir
- Returns:
4D array with dims TYXC
- Return type:
np.array
- traccuracy.loaders.load_geff_data(geff_path: str, load_geff_seg: bool = False, seg_path: str | None = None, seg_property: str | None = None, name: str | None = None, load_all_props: bool = False) traccuracy._tracking_graph.TrackingGraph[source]
Load a graph into memory from a geff file
Segmentations can be optionally loaded either from a related object specified in the geff (
load_geff_seg=True) or with a path to a zarr arrayseg_pathandseg_property- Parameters:
geff_path (str) – Path to a geff group inside of a zarr,
load_geff_seg (bool, optional) – Load segmentation based on a geff metadata of related segmentation. Defaults to False.
seg_path (str | None, optional) – Path to a zarr array containing segmentation data. We assume that the axes order in your segmentation array matches the axes in your geff. If this is not true please load the segmentation yourself and add it to TrackingGraph.segmentation. Defaults to None.
seg_property (str | None, optional) – If seg_path provided, this is the corresponding property on the geff graph that contains the segmentation key. Defaults to None.
name (str | None, optional) – Optional name to store on TrackingGraph for identification. Defaults to None.
load_all_props (bool, optional) – If True, load all node and edge properties on the graph. Defaults to False and only spatiotemporal and segmentation node properties are loaded.
- traccuracy.loaders.load_point_data(path: str | None = None, df: pandas.DataFrame | None = None, parent_column: str = 'parent', id_column: str = 'node_id', pos_columns: tuple[str, Ellipsis] = ('z', 'y', 'x'), time_column: str = 't', seg_id_column: str | None = None, name: str | None = None, sep: str | None = None) traccuracy._tracking_graph.TrackingGraph[source]
Load point-based tracking data into a TrackingGraph from a csv-like file
Assumes each row contains:
time
position, e.g. three columns ‘z’, ‘y’, ‘x’
parent, a reference to the node in the previous time frame. A node without a parent can be indicated by -1
- Parameters:
path (str | None, optional) – Path to the csv-like file to load. Defaults to None.
df (pd.DataFrame | None, optional) – A dataframe that has already been loaded. Defaults to None.
parent_column (str | None, optional) – A reference to the parent node in the previous time frame. Defaults to “parent”.
id_column (str, optional) – Column used to specify node ids. Node IDs should be unique positive integers. Defaults to ‘node_id’
pos_columns (tuple[str], optional) – A tuple of columns to use for position. Defaults to (“z”, “y”, “x”).
time_column (str, optional) – The column to use for time. Defaults to “t”.
seg_id_column (str | None, optional) – Name of an optional column containing a segmentation label id. Defaults to None.
name (str | None, optional) – Optional string to name/describe the dataset. Defaults to None.
sep (str | None, optional) – Passed to pd.read_csv to set the sep kwarg. Defaults to None.
- Raises:
ValueError – Must provide either a path or a dataframe
ValueError – parent_column not present in data
ValueError – id_column not present in data
ValueError – id_column does not contain positive integers
ValueError – id_column does not contain unique values
ValueError – pos_columns not present in data
ValueError – time_column not present in data
ValueError – seg_id_column not present in data
- Returns:
TrackingGraph