-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add writer to plugin for exporting a Tracks layer to hdf (#369)
* Update plugin reader to return early for unsupported filetypes * Add a function btrack.utils.napari_to_tracks Converts napari layer data into a list of Tracklets * Add hdf writer function to the plugin * Add plugin writer to napari config * Use empty dict for graph and properties if they are not layer metadata * Determine parent, root, and children from graph if it exists * Make black happy * Add the tracks.h5 example dataset * Set correct parent, root, and generation when converting napari to track * Add test for btrack.utils.napari_to_tracks The z-coordinates are not compared as dummy objects in the sample set have non-zero values even though it's a 2D dataset * Use constants.States enum when setting default label rather int literal Also inherit from enum.IntEnum for constants.States otherwise numpy complains that it can't be used to set as a fill value with np.full_like * Upgrade `cvxopt` (#348) * Update `pre-commit` and make some other fixes * Update version pins * Remove references to `cvxopt` * Add type Co-authored-by: Alan R Lowe <[email protected]> * Use `|=` * Remove extra dependencies --------- Co-authored-by: Alan R Lowe <[email protected]> * Move `fixture`s into `conftest.py` (#331) * Move `fixture`s into `conftest.py` * Just import `btrack` * Move `Container` * Fix tests * Rename writer * Use `qtpy` * Don't set widget values in the widgets (as done from file) (#379) * Remove unnecessary `.setValue` calls * Check status done by config file * Don't store refs when converting tracks to napari * Fix description of return values from napari_to_tracks --------- Co-authored-by: Patrick Roddy <[email protected]> Co-authored-by: Alan R Lowe <[email protected]>
- Loading branch information
1 parent
efaad04
commit 2ec7728
Showing
8 changed files
with
197 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
This module is a writer plugin to export Tracks layers using BTrack | ||
""" | ||
from typing import Optional | ||
|
||
import numpy.typing as npt | ||
|
||
from btrack.io import HDF5FileHandler | ||
from btrack.utils import napari_to_tracks | ||
|
||
|
||
def export_to_hdf( | ||
path: str, | ||
data: npt.ArrayLike, | ||
meta: dict, | ||
) -> Optional[str]: | ||
tracks = napari_to_tracks( | ||
data=data, | ||
properties=meta.get("properties", {}), | ||
graph=meta.get("graph", {}), | ||
) | ||
|
||
with HDF5FileHandler( | ||
filename=path, | ||
read_write="w", | ||
obj_type="obj_type_1", | ||
) as writer: | ||
writer.write_tracks(tracks) | ||
|
||
return path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters