-
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
base: napari-dev
Are you sure you want to change the base?
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. |
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.h5
when 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
napari
layers 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). |
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 <[email protected]>
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? |
Since this is a one-line fix, I've opened a quick PR #424 rather than raising an issue. |
From when I was working on the group layers for BrainGlobe, this isn't going to be a quick fix. I think we encountered a similar issue there and I remember being deep in TLDR To Get Things MovingFor the time being, we can report this as a known bug in the plugin docs (and open an issue for it on the repo), and ignore it for now (allowing us to merge in & release the widget). Realistically, I don't think we expect users to load in their data, and then delete it and re-open it. And as far as I can tell, opening multiple datasets does not produce this bug. Debugging Ideas? |
@willGraham01 your suggested course sounds good. I'd appreciate if you'd open an issue to track this, and copy-paste your suggested "debugging" workflow. Meanwhile, I will update the guide to mention this as a "known issue". |
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 <[email protected]>
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? |
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
napari
plugin into the world.napari-video
andpyvideoreader
to the[napari]
extras dependencies. These are necessary for loading videos into as an image layer innapari
.movement
plugin for napari. This guide includes some warnings, to manage expectations, and some advice on how to troubleshoot video playback issues.napari
at 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-dev
intomain
, write a blogpost about the plugin and finally make ourv0.1.0
release.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.:
movement
in 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:
napari
plugin 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: