Skip to content

Commit

Permalink
updated test and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
keyaloding committed Aug 1, 2024
1 parent 846856b commit f88ca17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ labels = sio.load_file("predictions.slp")
sio.save_file(labels, "predictions.nwb")
# Or:
# labels.save("predictions.nwb")

# Save to an NWB file and convert SLEAP training data to NWB training data:
frame_inds = [i for i in range(20)]
sio.save_file(labels, "predictions.nwb", as_training=True, frame_inds=frame_inds)
# This will save the first 20 frames of the video as individual images
```

### Convert labels to raw arrays
Expand Down
10 changes: 6 additions & 4 deletions tests/io/test_nwb.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ def nwbfile():
return nwbfile


def test_img_to_path():
def test_video_to_path():
video = Video(filename="tests/data/videos/centered_pair_low_quality.mp4")
pathname = write_video_to_path(video, frame_inds=[i for i in range(30, 50)])
assert len(pathname) == 20
assert pathname[0] == "tests/data/videos/centered_pair_low_quality/frame_30.png"
video_info = write_video_to_path(video, frame_inds=[i for i in range(30, 50)])
index_data, _, _ = video_info
assert list(index_data.keys()) == [i for i in range(30, 50)]
image_0_name = list(index_data.values())[0]
assert image_0_name == "tests/data/videos/centered_pair_low_quality/frame_0.png"


def test_nwb_slp_conversion():
Expand Down

0 comments on commit f88ca17

Please sign in to comment.