|
| 1 | +(target-gui)= |
| 2 | +# Graphical User Interface |
| 3 | + |
| 4 | +The `movement` graphical user interface (GUI), powered by our custom plugin for |
| 5 | +[napari](napari:), makes it easy to view and explore `movement` |
| 6 | +motion tracks. Currently, you can use it to |
| 7 | +visualise 2D [poses datasets](target-poses-and-bboxes-dataset) |
| 8 | +as points overlaid on video frames. |
| 9 | + |
| 10 | +:::{warning} |
| 11 | +The GUI is still in early stages of development but we are working on ironing |
| 12 | +out the [kinks](movement-github:issues?q=sort%3Aupdated-desc+is%3Aissue+state%3Aopen+label%3AGUI+label%3Abug). |
| 13 | +Please [get in touch](target-get-in-touch) |
| 14 | +if you find any bugs or have suggestions for improvements! |
| 15 | +::: |
| 16 | + |
| 17 | +The `napari` plugin is shipped with the `movement` package starting from |
| 18 | +version `0.1.0`. To use it, you need to |
| 19 | +[install the package](target-installation) via a method that |
| 20 | +includes the `napari` dependency. |
| 21 | + |
| 22 | + |
| 23 | +## Launch the GUI |
| 24 | + |
| 25 | +To launch the `movement` GUI, type the following command in your terminal: |
| 26 | + |
| 27 | +```sh |
| 28 | +movement launch |
| 29 | +``` |
| 30 | + |
| 31 | +This is equivalent to running `napari -w movement` and will open the `napari` |
| 32 | +window with the `movement` widget docked on the |
| 33 | +right-hand side, as in the [screenshot](target-widget-screenshot) below. |
| 34 | + |
| 35 | +In `napari`, data is typically loaded into [layers](napari:guides/layers.html), |
| 36 | +which can be reordered and toggled for visibility in the layers list panel. |
| 37 | +For example, keypoint data can be added as a |
| 38 | +[points layer](napari:howtos/layers/points.html), |
| 39 | +while image stacks (including videos) can be added as |
| 40 | +[image layers](napari:howtos/layers/image.html). |
| 41 | +Below, we'll explain how to do this. |
| 42 | + |
| 43 | +## Load a background layer |
| 44 | + |
| 45 | +Though this is not strictly necessary, it is usually informative to |
| 46 | +view the keypoints overlaid on a background that provides |
| 47 | +some spatial context. You can either [load the video](target-load-video) |
| 48 | +corresponding to the poses dataset, or a [single image](target-load-frame), |
| 49 | +e.g., a still frame derived from that video. |
| 50 | +You can do this by dragging and dropping the corresponding file onto the |
| 51 | +`napari` window or by using the `File > Open File(s)` menu option. |
| 52 | +Please read the following sections for detailed information |
| 53 | +and some important considerations. |
| 54 | + |
| 55 | +(target-load-video)= |
| 56 | +### Load a video |
| 57 | + |
| 58 | +When trying to load a video file into `napari`, you will be prompted |
| 59 | +via a pop-up dialog to select the reader. |
| 60 | +Choose the `video` reader—corresponding to the |
| 61 | +[`napari-video`](https://github.com/janclemenslab/napari-video) |
| 62 | +plugin—and click `OK`. You can optionally select to remember this reader |
| 63 | +for all files with the same extension. |
| 64 | + |
| 65 | +`napari-video` will load the video as an image stack with a slider |
| 66 | +at the bottom that you can use to navigate through frames. |
| 67 | +You may also use the left and right arrow keys to navigate |
| 68 | +frame-by-frame. |
| 69 | + |
| 70 | +Clicking on the play button will start the video playback at a default |
| 71 | +rate of 10 frames per second. You can adjust that by right-clicking on the |
| 72 | +play button or by opening the `napari > Preferences` menu |
| 73 | +(`File > Preferences` on Windows) and changing |
| 74 | +the `Playback frames per second` setting. |
| 75 | + |
| 76 | +(target-video-playback-limitations)= |
| 77 | +:::{admonition} Video playback limitations |
| 78 | +:class: warning |
| 79 | + |
| 80 | +- The video playback may freeze or stutter if you click on the slider to jump |
| 81 | + to a specific frame. We recommended pausing the playback before such jumps. |
| 82 | +- `napari-video` may struggle to play videos at a high frame rate, depending |
| 83 | + on your hardware, the video resolution and codec. If you experience |
| 84 | + performance issues, such as the video freezing or skipping frames, |
| 85 | + try reducing the playback frames per second or fall back to |
| 86 | + using a [single image](target-load-frame) as a background. |
| 87 | +::: |
| 88 | + |
| 89 | + |
| 90 | +(target-load-frame)= |
| 91 | +### Load an image |
| 92 | + |
| 93 | +This usually means using a still frame extracted from the video, but in theory |
| 94 | +you could use any image that's in the same coordinate system as the |
| 95 | +tracking data. For example, you could use a schematic diagram of the arena, |
| 96 | +as long as it has the same width and height as the video and is |
| 97 | +properly aligned with the tracking data. |
| 98 | + |
| 99 | +::: {dropdown} Extracting a still frame from a video |
| 100 | +:color: info |
| 101 | +:icon: info |
| 102 | + |
| 103 | +You can use the command line tool [`ffmpeg`](https://www.ffmpeg.org/) |
| 104 | +to extract a still frame from a video. |
| 105 | + |
| 106 | +To extract the first frame of a video: |
| 107 | + |
| 108 | +```sh |
| 109 | +ffmpeg -i video.mp4 -frames:v 1 first-frame.png |
| 110 | +``` |
| 111 | + |
| 112 | +To extract a frame at a specific time stamp (e.g. at 2 seconds): |
| 113 | + |
| 114 | +```sh |
| 115 | +ffmpeg -i video.mp4 -ss 00:00:02 -frames:v 1 frame-2sec.png |
| 116 | +``` |
| 117 | +::: |
| 118 | + |
| 119 | +Dragging and dropping the image file onto the `napari` window |
| 120 | +(or opening it via the `File` menu) will load the image |
| 121 | +as a single 2D frame without a slider. |
| 122 | + |
| 123 | +## Load the poses dataset |
| 124 | + |
| 125 | +Now you are ready to load some pose tracks over your chosen background layer. |
| 126 | + |
| 127 | +On the right-hand side of the window you should see |
| 128 | +an expanded `Load poses` menu. To load pose data in napari: |
| 129 | +1. Select the `source software` from the dropdown menu. |
| 130 | +2. Set the `fps` (frames per second) of the video the pose data refers to. Note this will only affect the units of the time variable shown when hovering over a keypoint. If the `fps` is not known, you can set it to 1, which will effectively make the time variable equal to the frame number. |
| 131 | +3. Select the file containing the predicted poses. The path can be directly pasted or you can use the file browser button. |
| 132 | +4. Click `Load`. |
| 133 | + |
| 134 | +The data should be loaded into the viewer as a |
| 135 | +[points layer](napari:howtos/layers/points.html). |
| 136 | +By default, it is added at the top of the layer list. |
| 137 | + |
| 138 | +::: {note} |
| 139 | +See [supported formats](target-supported-formats) for more information on |
| 140 | +the expected software and file formats. |
| 141 | +::: |
| 142 | + |
| 143 | + |
| 144 | +You will see a view similar to the one below: |
| 145 | + |
| 146 | +(target-widget-screenshot)= |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | +The keypoints are represented as points, colour-coded by |
| 151 | +keypoint ID for single-individual datasets, or by individual ID for |
| 152 | +multi-individual datasets. These IDs can be also displayed as text |
| 153 | +next to the points by enabling the `display text` option from the |
| 154 | +layer controls panel. |
| 155 | + |
| 156 | +Hovering with your mouse over a point |
| 157 | +(with the points layer selected) will |
| 158 | +bring up a tooltip containing the names of the individual and keypoint, |
| 159 | +the point-wise confidence score (provided by the source software), |
| 160 | +and the time in seconds (calculated based on the frame number and |
| 161 | +the `fps` value you provided). |
| 162 | + |
| 163 | +Using the slider at the bottom of the window, you can move through |
| 164 | +the frames of the dataset, and the points and video will update |
| 165 | +in sync. |
| 166 | + |
| 167 | +::: {admonition} Stay tuned |
| 168 | +Though the display style of the points layer is currently fixed, we are |
| 169 | +working on adding more customisation options in future releases, such as |
| 170 | +enabling you to change the point size, colour, or shape. |
| 171 | + |
| 172 | +We are also working on enabling the visualisation of |
| 173 | +[bounding boxes datasets](target-poses-and-bboxes-dataset) in the plugin. |
| 174 | +::: |
0 commit comments