-
Notifications
You must be signed in to change notification settings - Fork 75
Document napari plugin #393
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## napari-dev #393 +/- ##
===========================================
Coverage 99.82% 99.82%
===========================================
Files 18 18
Lines 1122 1175 +53
===========================================
+ Hits 1120 1173 +53
Misses 2 2 ☔ View full report in Codecov by Sentry. |
willGraham01
left a comment
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.
I'm able to follow the instructions and get the plugin working, all the listed features in the guide seem to work 🥳
- I couldn't load any of the SLEAP poses datasets, but I imagine that's just me trying to load the wrong type of data in? I got a
ValueError: Could not find the expected dataset(s) {'df_with_missing'} in file: /home/ccaegra/.movement/data/poses/SLEAP_single-mouse_EPM.analysis.h5when trying to do so, quickly followed by a seg-fault in the C-backend.
One thing I did realise is that we appear to have a memory leak issue when the user deletes the layers they read in. To recreate:
- Fire up napari,
napari -w movement - Load any valid dataset, EG
DLC_single-mouse_EPM.predictions.h5(as in the user-guide). - The slider and the "play" button will allow the user to move through the frames as expected.
- Delete the imported layers using the
naparilayers tab. - Load any valid dataset (even the same one) in again via the plugin.
- The slider can now be manually dragged to move through the loaded image, but pressing "play" results in a seg-fault (see below).
Valgrind's traceback goes deep into the C/C++ backend, but it looks like the fault originates from a napari object. So either we're not cleaning up our references to layers properly - which I don't think is the problem having looked at the widget's class (we aren't storing any references and are just passing the imported layer to the core napari instance to handle itself) - or (more likely) this is a genuine bug with the napari backend.
That error message indicates that you may have tried to load a file output by SLEAP, using the DeepLabCut loader (becasue "df_with_missing" is a dataset within DeepLabCut .h5 output files). Can you try again loading the same file but with |
Yeah that's very annoying, I can reproduce it. It's likely on the napari side (see this issue), but it would be good to make sure that we are not creating this problem). |
sfmig
left a comment
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.
Looks great! My first time using the napari plugin 🤩
All small nitpicky comments, feel free to take or leave them! Mostly about making the guide sound a bit less technical / dev-oriented.
I found some behaviour with the fps a bit odd:
- seems like it cannot be a float. But in a movement dataset we do set the fps as a float.
- it also seems like the default is set to 30fps. Would this be better as 0, or as 1 (to match the frame number in the slider)? Note that the tooltip doesn't specify units. Since it is now decoupled from the playback speed and it only affects the tooltip data, I was imagining what would someone input if they didn't know or care about the fps when just visualising the data.
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.
Can confirm, this was indeed the problem 😅 Data loaded OK when I switched. |
Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com>
Maybe we can make the error message a bit more clear? 👀 (I encountered this and was surprised because generally movement has crystal clear messages) |
I agree that error message should be modified by adding something "Are you sure you've selected the correct Hopefully, using Sofía's updated step-by-step instructions this error will occur less frequently (or not at all if we switch to inferring the file format, and enable drag-and-dropping files (which we should!). |
You can always do a "try...except" catch in the widget code, if we know the specific errors. But then we'd likely get into the rabbit hole of needing our own custom exceptions to reliably identify errors like this, and errors where the file is genuinely faulty, for example |
@sfmig I've now changed the fps spinbox to:
def _create_fps_widget(self):
"""Create a spinbox for selecting the frames per second (fps)."""
self.fps_spinbox = QDoubleSpinBox()
self.fps_spinbox.setObjectName("fps_spinbox")
self.fps_spinbox.setMinimum(0.1)
self.fps_spinbox.setMaximum(1000.0)
self.fps_spinbox.setValue(1.0)
self.fps_spinbox.setDecimals(2)
# How much we increment/decrement when the user clicks the arrows
self.fps_spinbox.setSingleStep(1)
# Add a tooltip
self.fps_spinbox.setToolTip(
"Set the frames per second of the tracking data.\n"
"This just affects the displayed time when hovering over a point\n"
"(it doesn't set the playback speed)."
)
self.layout().addRow("fps:", self.fps_spinbox) |
@willGraham01 I actually have lots of trouble diagnosing this issue. I went through reports of similar issues, like this one but I frankly don't understand the Qt internals well enough to determine what causes this (and how to solve it). What course of action would you propose? |
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.
Thanks @niksirbi! All LGTM 🚀 and sorry for being late to the party! Only left a few minor suggestions, and as usual, feel free to take or leave.
Edit: do we want to mention movement launch?
Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk>
for more information, see https://pre-commit.ci
I can reproduce it, so it's not just your setup! I haven't fully confirmed this but I have a suspicion: As far as I can tell, this only happens with SLEAP multi-animal datasets. Interestingly, it happens with the "mixed-labels" version of the Aeon dataset, but not with the "proofread" one. I wonder whether this is somehow related to mixed identities/tracks in SLEAP files. Intriguingly, whether we are using the analysis.h5 or the .slp file doesn't matter. I will not get to the bottom of this tonight. Any ideas @lochhh? |
To me it happens with all the multi-animal datasets, not only SLEAP ones (the Sherlock bboxes dataset - which is not in GIN but can share- , and the DLC two mice dataset). I think maybe that is a stronger hint. Another hint is that the frame slider end is set to 512 in all cases - seems like a default? It makes me think napari is interpreting the axes wrong... Just to be extra clear I am not loading any videos, just data. |
Yay, you make a strong case. If it's all multi-animal datasets, and the problem is solved by pre-loading a video first, it is indeed highly likely that napari does something funky with the axes there. I guess if the video is added first and the points later, napari aligns the axes of the points layer to the image layer? Do you know if pre-loading the image only (still frame) also solves this or do we always need the video? |
I just tried with the two mice octagon data - the problem still exists if you load a still frame. The number of frames in the slider does not match the number of frames in the data. |
| visualise 2D [poses datasets](target-poses-and-bboxes-dataset) | ||
| as points overlaid on video frames. | ||
|
|
||
| :::{warning} |
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.
Wdyt about adding a link to issues tagged with the GUI and BUG labels here so that we can merge this docs PR and investigate the issues in another? @sfmig @niksirbi
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.
Absolutely. This would also avoid the branching-on-branches mess we are in right now.
I propose the following course of action:
- merge this PR into napari-dev, with the added link to GUI-tagged issues (I will do this)
- rebase and merge Replace
brainglobe-utilswithqt-niu#441 intonapari-dev(@lochhh will do this) - Update
napari-devbranch to make sure it's in-sync with main (I will do this) - Deal with Unexpected "tail" from previous time frame showing in points layer in multi-animal datasets #446 in a separate-PR to
napari-dev - Once bug is fixed, merge
napari-devto main.
What do y'all think?
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.
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.
Sounds good to me, although I'd prefer merging napari-dev to main sooner rather than waiting for all bugs to be fixed - we'll always discover more 🙈
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 also go for merging napari-dev to main before fixing the bug, which would be the bolder choice (meaning that we risk including a buggy plugin in the next release), but would make our dev processes easier.
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.
I wrote my last message before reading your replies, sounds like we all agree, I will start the untangling now.
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.
Bold it is!
Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk>
|
* started user guide about napari plugin * added optional dependencies for napari-video and pyvideoreader * WIP expanding on the napari plugin user guide * add section on loading poses datasets * set maximum card columns to 2 in the user guide page * corrected grammar and spelling mistakes in the plugin guide * removed automatic setting of playback fps to tracking fps * update to v3 of pyvista/setup-headless-display-action * Apply suggestions from Sofia's code review Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> * renamed napari guide and added clarifications * fps spinbox: make float, default 1, add tooltip * made image annotations more prominent * Apply suggestions from CH's code review Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * applied more suggestions from CH's review * documented known issues * renamed napari_plugin.md to gui.md * add link to github issues tagged with GUI + bug * Use movement-github link from myst-url-scheme Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> --------- Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* started user guide about napari plugin * added optional dependencies for napari-video and pyvideoreader * WIP expanding on the napari plugin user guide * add section on loading poses datasets * set maximum card columns to 2 in the user guide page * corrected grammar and spelling mistakes in the plugin guide * removed automatic setting of playback fps to tracking fps * update to v3 of pyvista/setup-headless-display-action * Apply suggestions from Sofia's code review Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> * renamed napari guide and added clarifications * fps spinbox: make float, default 1, add tooltip * made image annotations more prominent * Apply suggestions from CH's code review Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * applied more suggestions from CH's review * documented known issues * renamed napari_plugin.md to gui.md * add link to github issues tagged with GUI + bug * Use movement-github link from myst-url-scheme Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> --------- Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* started user guide about napari plugin * added optional dependencies for napari-video and pyvideoreader * WIP expanding on the napari plugin user guide * add section on loading poses datasets * set maximum card columns to 2 in the user guide page * corrected grammar and spelling mistakes in the plugin guide * removed automatic setting of playback fps to tracking fps * update to v3 of pyvista/setup-headless-display-action * Apply suggestions from Sofia's code review Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> * renamed napari guide and added clarifications * fps spinbox: make float, default 1, add tooltip * made image annotations more prominent * Apply suggestions from CH's code review Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * applied more suggestions from CH's review * documented known issues * renamed napari_plugin.md to gui.md * add link to github issues tagged with GUI + bug * Use movement-github link from myst-url-scheme Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> --------- Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* initialise napari plugin development * Create skeleton for napari plugin with collapsible widgets (#218) * initialise napari plugin development * initialise napari plugin development * create skeleton for napari plugin with collapsible widgets * add basic widget smoke tests and allow headless testing * do not depend on napari from pip * include napari option in install instructions * make meta_widget module private * pin atlasapi version to avoid unnecessary dependencies * pin napari >= 0.4.19 from conda-forge * switched to pip install of napari[all] * seperation of concerns in widget tests * add pytest-mock dev dependency * Qt widget for loading pose datasets as napari Points layers (#253) * initialise napari plugin development * Create skeleton for napari plugin with collapsible widgets (#218) * initialise napari plugin development * initialise napari plugin development * create skeleton for napari plugin with collapsible widgets * add basic widget smoke tests and allow headless testing * do not depend on napari from pip * include napari option in install instructions * make meta_widget module private * pin atlasapi version to avoid unnecessary dependencies * pin napari >= 0.4.19 from conda-forge * switched to pip install of napari[all] * seperation of concerns in widget tests * add pytest-mock dev dependency * initialise napari plugin development * initialise napari plugin development * initialise napari plugin development * Added loader widget for poses * update widget tests * simplify dependency on brainglobe-utils * consistent monospace formatting for movement in public docstrings * get rid of code that's only relevant for displaying Tracks * enable visibility of napari layer tooltips * renamed widget to PosesLoader * make cmap optional in set_color_by method * wrote unit tests for napari convert module * wrote unit-tests for the layer styles module * linkcheck ignore zenodo redirects * move _sample_colormap out of PointsStyle class * small refactoring in the loader widget * Expand tests for loader widget * added comments and docstrings to napari plugin tests * refactored all napari tests into separate unit test folder * added napari-video to dependencies * replaced deprecated edge_width with border_width * got rid of widget pytest fixtures * remove duplicate word from docstring * remove napari-video dependency * include napari extras in docs requirements * add test for _on_browse_clicked method * getOpenFileName returns tuple, not str * simplify poses_to_napari_tracks Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * [pre-commit.ci] pre-commit autoupdate (#338) updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.9 → v0.7.2](astral-sh/ruff-pre-commit@v0.6.9...v0.7.2) - [github.com/pre-commit/mirrors-mypy: v1.11.2 → v1.13.0](pre-commit/mirrors-mypy@v1.11.2...v1.13.0) - [github.com/mgedmin/check-manifest: 0.49 → 0.50](mgedmin/check-manifest@0.49...0.50) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Implement `compute_speed` and `compute_path_length` (#280) * implement compute_speed and compute_path_length functions * added speed to existing kinematics unit test * rewrote compute_path_length with various nan policies * unit test compute_path_length across time ranges * fixed and refactor compute_path_length and its tests * fixed docstring for compute_path_length * Accept suggestion on docstring wording Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * Remove print statement from test Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * Ensure nan report is printed Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * adapt warning message match in test * change 'any' to 'all' * uniform wording across path length docstrings * (mostly) leave time range validation to xarray slice * refactored parameters for test across time ranges * simplified test for path lenght with nans * replace drop policy with ffill * remove B905 ruff rule * make pre-commit happy --------- Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * initialise napari plugin development * initialise napari plugin development * initialise napari plugin development * initialise napari plugin development * initialise napari plugin development * avoid redefining duplicate attributes in child dataclass * modify test case to match poses_to_napari_tracks simplification * expected_log_messages should be a subset of captured messages Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * fix typo Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * use names for Qwidgets * reorganised test_valid_poses_to_napari_tracks * parametrised layer style tests * delet integration test which was reintroduced after conflict resolution * added test about file filters * deleted obsolete loader widget file (had snuck back in due to conflict merging) * combine tests for button callouts Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * Simplify test_layer_style_as_kwargs Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> --------- Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * added `movement launch` CLI entrypoint (#345) * updated dimensions order in poses_to_napari_tracks conversion function * Document napari plugin (#393) * started user guide about napari plugin * added optional dependencies for napari-video and pyvideoreader * WIP expanding on the napari plugin user guide * add section on loading poses datasets * set maximum card columns to 2 in the user guide page * corrected grammar and spelling mistakes in the plugin guide * removed automatic setting of playback fps to tracking fps * update to v3 of pyvista/setup-headless-display-action * Apply suggestions from Sofia's code review Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> * renamed napari guide and added clarifications * fps spinbox: make float, default 1, add tooltip * made image annotations more prominent * Apply suggestions from CH's code review Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * applied more suggestions from CH's review * documented known issues * renamed napari_plugin.md to gui.md * add link to github issues tagged with GUI + bug * Use movement-github link from myst-url-scheme Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> --------- Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * use updated pytest fixtures in napari convert tests * Replace bg-utils with qt-niu (#441) * update command for testing GUI in installation guide. * updated wording in v0.1 roadmap --------- Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com>
* started user guide about napari plugin * added optional dependencies for napari-video and pyvideoreader * WIP expanding on the napari plugin user guide * add section on loading poses datasets * set maximum card columns to 2 in the user guide page * corrected grammar and spelling mistakes in the plugin guide * removed automatic setting of playback fps to tracking fps * update to v3 of pyvista/setup-headless-display-action * Apply suggestions from Sofia's code review Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> * renamed napari guide and added clarifications * fps spinbox: make float, default 1, add tooltip * made image annotations more prominent * Apply suggestions from CH's code review Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * applied more suggestions from CH's review * documented known issues * renamed napari_plugin.md to gui.md * add link to github issues tagged with GUI + bug * Use movement-github link from myst-url-scheme Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> --------- Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* started user guide about napari plugin * added optional dependencies for napari-video and pyvideoreader * WIP expanding on the napari plugin user guide * add section on loading poses datasets * set maximum card columns to 2 in the user guide page * corrected grammar and spelling mistakes in the plugin guide * removed automatic setting of playback fps to tracking fps * update to v3 of pyvista/setup-headless-display-action * Apply suggestions from Sofia's code review Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> * renamed napari guide and added clarifications * fps spinbox: make float, default 1, add tooltip * made image annotations more prominent * Apply suggestions from CH's code review Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * applied more suggestions from CH's review * documented known issues * renamed napari_plugin.md to gui.md * add link to github issues tagged with GUI + bug * Use movement-github link from myst-url-scheme Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> --------- Co-authored-by: sfmig <33267254+sfmig@users.noreply.github.com> Co-authored-by: Chang Huan Lo <changhuan.lo@ucl.ac.uk> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>








Description
What is this PR
Why is this PR needed?
Closes #283
What does this PR do?
This PR puts some final necessary touches before we are able to release the
napariplugin into the world.napari-videoandpyvideoreaderto the[napari]extras dependencies. These are necessary for loading videos into as an image layer innapari.movementplugin for napari. This guide includes some warnings, to manage expectations, and some advice on how to troubleshoot video playback issues.napariat hifgh fps, I modified the default behaviour of the plugin. Previously, the plugin changednapari's playback fps setting to the same value as the loaded data (e.g. if loading data tracked at 60 fps, the plugin would automatically setnapari's palyback speed to that values, so that the video would play "in real time" by default). This PR removes that feature, and instead leaves that choice entirely to the user (documented in the guide). This means that user's will getnapari's default playback rate of 10 fps, and can choose to change that however they like.References
After this PR is successfully merged into
napari-dev, we will have achieved all tasks listed under the meta-issue #31.After that, we can finally merge
napari-devintomain, write a blogpost about the plugin and finally make ourv0.1.0release.How to review this PR
The best way to review the PR would be to build the docs locally, and then follow the instructions in updated docs, i.e.:
movementin dev mode (this also gets you all thenapari-related dependenciesds = sample_data.fetch_dataset(filename, with_video=True), and find the files in~/.movement.The reason I'm tagging many reviewers here is the following:
napariplugin development, so I thought y'all will benefit from seeing the current (limited) status quo.napari.How has this PR been tested?
No new functionality has been added. Some tests were modified to account for the removal of the aforementioned fps functionality.
Is this a breaking change?
No.
Does this PR require an update to the documentation?
It is, for the most part, an update to documentation.
Checklist: