Skip to content

Commit

Permalink
Store only .slp as labels_path
Browse files Browse the repository at this point in the history
  • Loading branch information
lochhh committed Nov 24, 2023
1 parent bf1ea3a commit 623597b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ save_poses.to_sleap_analysis_file(ds, "/path/to/file.h5")

:::{note}
When saving to SLEAP-style files, only `track_names`, `node_names`, `tracks`, `track_occupancy`,
`point_scores`, and `labels_path` are saved. Other attributes and data variables
and `point_scores` are saved. `labels_path` will only be saved if the source
file of the dataset is a SLEAP .slp file. Otherwise, it will be an empty string.
Other attributes and data variables
(i.e., `instance_scores`, `tracking_scores`, `edge_names`, `edge_inds`, `video_path`,
`video_ind`, and `provenance`) are not currently supported. To learn more about what
each attribute and data variable represents, see the
Expand Down
14 changes: 9 additions & 5 deletions movement/io/save_poses.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,11 @@ def to_sleap_analysis_file(
"track_names", "node_names", "tracks", "track_occupancy", "point_scores",
"instance_scores", "tracking_scores", "labels_path", "edge_names",
"edge_inds", "video_path", "video_ind", "provenance" [1]_.
However, only "track_names", "node_names", "tracks", "track_occupancy",
"point_scores" and "labels_path" will contain data extracted from the
input dataset.
However, only "track_names", "node_names", "tracks", "track_occupancy"
and "point_scores" will contain data extracted from the input dataset.
"labels_path" will contain the path to the input file only if the source
file of the dataset is a SLEAP .slp file. Otherwise, it will be an empty
string.
The other attributes and data variables that are not present in the input
dataset will contain default (empty) values.
Expand Down Expand Up @@ -293,7 +295,9 @@ def to_sleap_analysis_file(
point_scores = np.transpose(ds.confidence.data, (1, 2, 0))
instance_scores = np.full((n_individuals, n_frames), np.nan, dtype=float)
tracking_scores = np.full((n_individuals, n_frames), np.nan, dtype=float)

labels_path = (
ds.source_file if Path(ds.source_file).suffix == ".slp" else ""
)
data_dict = dict(
track_names=individual_names,
node_names=keypoint_names,
Expand All @@ -302,7 +306,7 @@ def to_sleap_analysis_file(
point_scores=point_scores,
instance_scores=instance_scores,
tracking_scores=tracking_scores,
labels_path=ds.source_file,
labels_path=labels_path,
edge_names=[],
edge_inds=[],
video_path="",
Expand Down

0 comments on commit 623597b

Please sign in to comment.