Skip to content

Commit 623597b

Browse files
committed
Store only .slp as labels_path
1 parent bf1ea3a commit 623597b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

docs/source/getting_started.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ save_poses.to_sleap_analysis_file(ds, "/path/to/file.h5")
228228

229229
:::{note}
230230
When saving to SLEAP-style files, only `track_names`, `node_names`, `tracks`, `track_occupancy`,
231-
`point_scores`, and `labels_path` are saved. Other attributes and data variables
231+
and `point_scores` are saved. `labels_path` will only be saved if the source
232+
file of the dataset is a SLEAP .slp file. Otherwise, it will be an empty string.
233+
Other attributes and data variables
232234
(i.e., `instance_scores`, `tracking_scores`, `edge_names`, `edge_inds`, `video_path`,
233235
`video_ind`, and `provenance`) are not currently supported. To learn more about what
234236
each attribute and data variable represents, see the

movement/io/save_poses.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,11 @@ def to_sleap_analysis_file(
246246
"track_names", "node_names", "tracks", "track_occupancy", "point_scores",
247247
"instance_scores", "tracking_scores", "labels_path", "edge_names",
248248
"edge_inds", "video_path", "video_ind", "provenance" [1]_.
249-
However, only "track_names", "node_names", "tracks", "track_occupancy",
250-
"point_scores" and "labels_path" will contain data extracted from the
251-
input dataset.
249+
However, only "track_names", "node_names", "tracks", "track_occupancy"
250+
and "point_scores" will contain data extracted from the input dataset.
251+
"labels_path" will contain the path to the input file only if the source
252+
file of the dataset is a SLEAP .slp file. Otherwise, it will be an empty
253+
string.
252254
The other attributes and data variables that are not present in the input
253255
dataset will contain default (empty) values.
254256
@@ -293,7 +295,9 @@ def to_sleap_analysis_file(
293295
point_scores = np.transpose(ds.confidence.data, (1, 2, 0))
294296
instance_scores = np.full((n_individuals, n_frames), np.nan, dtype=float)
295297
tracking_scores = np.full((n_individuals, n_frames), np.nan, dtype=float)
296-
298+
labels_path = (
299+
ds.source_file if Path(ds.source_file).suffix == ".slp" else ""
300+
)
297301
data_dict = dict(
298302
track_names=individual_names,
299303
node_names=keypoint_names,
@@ -302,7 +306,7 @@ def to_sleap_analysis_file(
302306
point_scores=point_scores,
303307
instance_scores=instance_scores,
304308
tracking_scores=tracking_scores,
305-
labels_path=ds.source_file,
309+
labels_path=labels_path,
306310
edge_names=[],
307311
edge_inds=[],
308312
video_path="",

0 commit comments

Comments
 (0)