-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document napari plugin #393
Open
niksirbi
wants to merge
17
commits into
napari-dev
Choose a base branch
from
document-napari-plugin
base: napari-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+224
−23
Open
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
dafaa6f
started user guide about napari plugin
niksirbi 25a36eb
added optional dependencies for napari-video and pyvideoreader
niksirbi dc6fd2d
WIP expanding on the napari plugin user guide
niksirbi 75d418a
add section on loading poses datasets
niksirbi 5800cf9
set maximum card columns to 2 in the user guide page
niksirbi d21cbe8
corrected grammar and spelling mistakes in the plugin guide
niksirbi cb3d14d
removed automatic setting of playback fps to tracking fps
niksirbi 28a5dfa
update to v3 of pyvista/setup-headless-display-action
niksirbi 99aeb22
Apply suggestions from Sofia's code review
niksirbi ec7ee4d
renamed napari guide and added clarifications
niksirbi 5df617b
fps spinbox: make float, default 1, add tooltip
niksirbi 41cde1d
made image annotations more prominent
niksirbi 6256be5
Apply suggestions from CH's code review
niksirbi 59085ac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e2a2dcb
applied more suggestions from CH's review
niksirbi c0f761c
documented known issues
niksirbi ad14632
renamed napari_plugin.md to gui.md
niksirbi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,161 @@ | ||
(target-napari-plugin)= | ||
# The napari plugin | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To enable the interactive visualisation of motion tracks in | ||
`movement`, we have created an experimental plugin for [napari](napari:). | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Currently, the plugin supports loading 2D | ||
[poses datasets](target-poses-and-bboxes-dataset), and visualising them | ||
as points overlaid on video frames. | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
:::{warning} | ||
This plugin is still in early stages of development and offers | ||
limited functionality. We are working on ironing out the kinks and | ||
gradually adding more features. [Get in touch](target-get-in-touch) | ||
if you find any bugs or have suggestions for improvements! | ||
::: | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Installation | ||
|
||
The `napari` plugin is shipped with the `movement` package starting from | ||
version `0.1.0`. If you install `movement` via `conda`, `napari` is already | ||
included as a dependency. If you use the `pip` installer, make sure to | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
install `movement` with the `[napari]` extra: | ||
|
||
```sh | ||
pip install movement[napari] | ||
``` | ||
|
||
## Launch the plugin | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Type the following command in your terminal: | ||
|
||
```sh | ||
napari -w movement | ||
``` | ||
|
||
This will open the `napari` window with the `movement` plugin docked on the | ||
right-hand side. | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Load a background layer | ||
|
||
Next, you need a background for you visualisation. You can either | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[load the video](target-load-video) corresponding to the poses dataset, | ||
or a [single image](target-load-frame), e.g., a still frame | ||
derived from that video. In the following sections, we will show you how to | ||
do both and discuss some limitations. | ||
|
||
(target-load-video)= | ||
### Load a whole video | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To load a video, drag and drop the video file onto the `napari` window. | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
You will see a pop-up dialog asking you to select the reader. | ||
Choose the `video` reader—corresponding to the | ||
[`napari-video`](https://github.com/janclemenslab/napari-video) | ||
plugin—and click `OK`. | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`napari-video` will load the video as a single `napari` | ||
[image layer](napari:howtos/layers/image.html), with a slider | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
at the bottom that you can use to navigate through frames. | ||
You may also use the left and right arrow keys to navigate | ||
frame-by-frame. | ||
|
||
Clicking on the play button will start the video playback at a default | ||
rate of 10 frames per second. You can adjust that by right-clicking on the | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
play button or by opening the `napari > Preferences` menu and changing | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
the `Playback frames per second` setting. | ||
|
||
:::{admonition} Video playback limitations | ||
:class: warning | ||
|
||
- During playback you cannot jump at an arbitrary frame by clicking on the | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
slider. Make sure to pause the video first. | ||
- `napari-video` may struggle to play videos at a high frame rate, depending | ||
on your hardware, the video resolution and codec. If you experience | ||
performance issues, such as the video freezing or skipping frames, | ||
try reducing the playback frames per second or fall back to | ||
using a [single image](target-load-frame) as a background. | ||
::: | ||
|
||
|
||
(target-load-frame)= | ||
### Load an image | ||
|
||
This usually means using a still frame extracted from the video, but in theory | ||
you could use any image that's in the same coordinate system as the | ||
tracking data. For example, you could use a schematic diagram of the arena, | ||
as long as it has the same width and height as the video and is | ||
properly aligned with the tracking data. | ||
|
||
::: {dropdown} Extracting a still frame from a video | ||
:color: info | ||
:icon: info | ||
|
||
You can extract a still frame using your video player/editor of | ||
choice. We find the command line tool [`ffmpeg`](https://www.ffmpeg.org/) | ||
very useful for this task. | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To extract the first frame of a video: | ||
|
||
```sh | ||
ffmpeg -i video.mp4 -frames:v 1 first-frame.png | ||
``` | ||
|
||
To extract a frame at a specific time stamp (e.g. at 2 seconds): | ||
|
||
```sh | ||
ffmpeg -i video.mp4 -ss 00:00:02 -frames:v 1 frame-2sec.png | ||
``` | ||
::: | ||
|
||
To load any image into `napari`, simply drag and drop the image file into | ||
the napari window. Alternatively, you can use the `File > Open File(s)` menu | ||
option and select the file from the file dialog. | ||
In any case, the image will be loaded as a static | ||
[image layer](napari:howtos/layers/image.html). | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Load the poses dataset | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Now you are ready to load some pose tracks over your chosen background layer. | ||
|
||
The `movement` plugin on the right-hand side of the window should contain | ||
an expanded `Load poses` menu. This contains a `source software` dropdown, | ||
an `fps` (frames per second) input field, and a `Browse` button to select | ||
a file containing predicted poses. | ||
You may also directly paste a `file path` into the homonymous field. | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
::: {note} | ||
See [supported formats](target-supported-formats) for more information on | ||
the expected software and file formats. | ||
::: | ||
|
||
Once the file path is set, click the `Load` button to load the poses dataset | ||
into `napari`. The plugin will create a new | ||
[points layer](napari:howtos/layers/points.html) on top of the existing | ||
image layer. | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
You will see a view similar to the one below: | ||
|
||
 | ||
|
||
The predicted keypoints are represented as points, colour-coded by | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
keypoint ID for single-individual datasets, or by individual ID for | ||
multi-individual datasets. Hovering with your mouse over a point will | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bring up a tooltip containing the names of the individual and keypoint, | ||
the point-wise confidence score (as predicted by the source software), | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
and the time in seconds (this is calculated from the frame number and | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
the `fps` value you provided). | ||
|
||
Using the slider at the bottom of the window, you can navigate through | ||
the frames of the poses dataset. The points will update accordingly, allowing | ||
you to inspect the predicted keypoints at different time points. | ||
If you loaded a video as a background layer, the video will also update | ||
in sync with the poses dataset. | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
::: {admonition} Stay tuned | ||
Though the display style of the points layer is currently fixed, we are | ||
working on adding more customisation options in future releases, such as | ||
enabling you to change the point size, colour, or shape. | ||
niksirbi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
We are also working on enabling the visualisation of | ||
[bounding boxes datasets](target-poses-and-bboxes-dataset) in the plugin. | ||
::: |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could put the annotations in red to make them more visible (the "Plugin" one may be easily missed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Red actually didn't contrast very well against the background. But I made all annotations bigger and bolder:
