Skip to content
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

Add FSLeyes plugin #182

Merged
merged 71 commits into from
Oct 14, 2019
Merged

Add FSLeyes plugin #182

merged 71 commits into from
Oct 14, 2019

Conversation

Stoyan-I-A
Copy link
Member

@Stoyan-I-A Stoyan-I-A commented Mar 10, 2019

This PR implements the following changes:

  • Changed numpy and scikit-image versions
  • Implemented a GUI design for the plugin
  • Implemented an image loader for the plugin
  • Implemented buttons on the control panel of the plugin to apply a prediction model
  • Implemented a button to load existing masks
  • "Active" images/masks are determined by their visibility status (eye icon on the overlay list)
  • added the following tools : watershed segmentation, axon auto-fill

Fixes #159, Fixes #162, Fixes #191, Fixes #192, Fixes #193, Fixes #201, Fixes #209

TODO

How to test / install

The installation procedure can by found here : https://github.com/neuropoly/axondeepseg/blob/FSLeyes_integration/docs/source/documentation.rst

Tools description

Tooltips were added to the GUI. If you hover your cursor over a button on the plugin, a description should popup

@coveralls
Copy link

coveralls commented Mar 10, 2019

Coverage Status

Coverage increased (+0.1%) to 82.812% when pulling 2fe999d on FSLeyes_integration into f216bb8 on master.

ads_plugin.py Outdated Show resolved Hide resolved
ads_plugin.py Outdated Show resolved Hide resolved
@mathieuboudreau
Copy link
Member

mathieuboudreau commented Mar 22, 2019

@Stoyan-I-A please add a short description in your commit message in addition to noting the Issue #. The reason being that it makes parsing through the commit log a lot easier (i.e. I don't have to click on the issues to know what was meant to be done in a commit).

@mathieuboudreau
Copy link
Member

mathieuboudreau commented Mar 22, 2019

I tried loading this plugin, but encountered an error:

Capture d’écran 2019-03-22 à 08 57 24

System: MacOS 10.14.3

Steps followed:

  • Created & activated a new conda virtual environment (conda create -n ads_venv python=3.6 & conda activate ads_venv)
  • Installed ADS inside the venv (pip install -e .)
  • Installed FSLeyes inside the venv (pip install FSLeyes conda install -c conda-forge fsleyes)
  • Opened FSLeyes from the command line (fsleyes)
  • Clicked Files --> Load plugin and selected ads_plugin.py

Three more notes:

  1. which fsleyes confirmed that I'm using the fsleyes inside my venv: /Users/mathieuboudreau/anaconda3/envs/ads_venv/bin/fsleyes

  2. fsleyes --version says that I'm using version 0.27.3+build0

  3. I did have an old FSL installation on my system beforehand (and thus FSLeyes)

Any thoughts @Stoyan-I-A ?

- Added the watershed algorithm using a chunk of the code that was used to compute the morphometrics. That should be changed in the future since it is basically copying code that is used elsewhere.
- Added the axon filling tool. This tool performs flood-fill at the locations of the centroids of the axon-myelin mask.
The centroids are now calculated with the myelin array rather than the axon array when trying to fill the axons.
@Stoyan-I-A
Copy link
Member Author

@mathieuboudreau
I think the error message comes from a package that I was importing. But I am no longer using it, so I'll remove it from the imports.

@mathieuboudreau
Copy link
Member

mathieuboudreau commented Mar 27, 2019

Thanks for the clarification @Stoyan-I-A . I can't test it at the moment unfortunately, as I can't even get FSLeyes to open in my venv anymore. Maybe the steps I reported above aren't exactly what I did, because I don't know what else could have changed. I'm getting this now:


(ads_182) mathieuboudreau@brassens:~$ fsleyes 
This program needs access to the screen. Please run with a
Framework build of python, and only when you are logged in
on the main display of your Mac.

I'll let you know once I debug this and I'm able to test your updated setup.

(Edit: woops, sorry about closing for a brief second, it was a misclick.)

@mathieuboudreau
Copy link
Member

I think installing fsleyes with conda install -c conda-forge fsleyes instead of pip resolved it for me, so I'll change my above steps and test it out again later.

Now, I'm able to open fsleyes within the venv, and install the plugin without the above error occuring.

After that, I was a bit of a loss of where to go to test out your plugin as not instructions appeared, and nothing in the GUI changed. After digging around, I found that there was an option called "ADScontrol" unter Settings --> Ortho View 1, is that what I'm suppose to click?

I did so, and got this error.

Capture d’écran 2019-03-27 à 11 06 59

Afterwards, nothing else appeared on the GUI, still the basic FSLeyes GUI options.

I'm on a MacOS 10.14.3, in the git branch FSLeyes_integration, and at the git commit 85692ca4dd1.

@mathieuboudreau
Copy link
Member

Scratch that last point, I had an older version of the plugin in the plugin folder for some reason. The current one has the directory changes you made recently. Now I get this error:

Capture d’écran 2019-03-27 à 11 11 51

I opened fsleyes from my axondeepseg/ folder on the commandline, so it appears the path handling still needs some tweaking.

@mathieuboudreau
Copy link
Member

I resolved the bug in commit fd63f2f (wrong filename, only printing the module path instead of concatenating it) and made the code a bit more robust for OS-independence. Now the plugin loads for me 🎉!

@jcohenadad
Copy link
Member

Awesome!! Thank you @mathieuboudreau and @Stoyan-I-A for your contribution

@jcohenadad
Copy link
Member

It would be nice to reorganize plugin window like that:

Screen Shot 2019-03-27 at 11 57 36

@jcohenadad
Copy link
Member

jcohenadad commented Sep 3, 2019

@Stoyan-I-A I did a git pull, then (after activating the environment):

conda uninstall fsleyes
yes | conda install -c conda-forge fsleyes>=0.30.1
fsleyes &

When loading the plugin, a window pops up with the following error message: Error installing plugin file, Details: no module named: 'wx.lib.agw.hyperlink'

And the terminal output says:

Failed to load plugin file /Users/julien/.fsleyes/plugins/ads_plugin.py: cannot import name 'ImageOps'
objc[12735]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fff9e4be3d8) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x12f69ef50). One of the two will be used. Which one is undefined.
   ERROR           status.pyc  164: reportIfError   - Error installing plugin file: An error occurred installing the plugin file.

UPDATE: 2019-09-03 12:02:54:

After uninstall/reinstall again:

conda uninstall fsleyes
yes | conda install -c conda-forge fsleyes>=0.30.1

Opening FSLeyes, no need to relead the plugin (still there), and it works fine (i can open the plugin and it works).

Additional, info about PIL (maybe overwritten by fsleyes install):

>>> import PIL
>>> PIL.__version__
'6.1.0'

@mathieuboudreau
Copy link
Member

@Stoyan-I-A I tried to follow the steps for debugging the GUI in the wiki (https://github.com/neuropoly/axondeepseg/wiki/How-to-test-the-plugin-script-in-debug-mode), however the instructions weren't clear/detailed enough for me to be able to do so on my computer.

Could you possibly take a video screen capture of you following the steps required to do so as an example, and I'll try to follow that along, and I'll fill in the missing information that I thought I would have needed in the wiki? One large issue I think may be that your steps may not be identical for all IDEs (I use Visual Studio Code).

@Stoyan-I-A
Copy link
Member Author

@mathieuboudreau I'll see what I can do. Do you think it would help if I added pictures?

@mathieuboudreau
Copy link
Member

We'll see after I see the video, it depznds on how exact some instructuions might need to be.

- The plugin now checks suffixes instead of the entire name
- The fill option now creates a new corrected axon overlay
- The plugin now verifies if another version is present in the ADS directory
@Stoyan-I-A
Copy link
Member Author

@mathieuboudreau I added the video to AxonDeepSeg's google drive.
https://drive.google.com/open?id=1O5TFJZT2dD6XiUQxeJvI1lpEclS1CLB7

@Stoyan-I-A
Copy link
Member Author

why duplicating the hard-coded version information? (see Line 2)

I found it easier to check the version this way. But I should change this.

@jcohenadad
Copy link
Member

why duplicating the hard-coded version information? (see Line 2)

I found it easier to check the version this way. But I should change this.

sorry i missed that on line 2, the version is a comment (part of the header). I would definitely remove this from the header (if we change the version in the future, we need to update both the code and the header, which is prone to errors).

moreover, instead of having the version lost in the code, i would create a global variable and put it at the top of the file, so it is visible by anyone reading your code. Something like:

VERSION = '2.0.1'

that you can put right after all the imports.

ads_plugin.py Outdated
@@ -36,6 +34,8 @@

from AxonDeepSeg.morphometrics.compute_morphometrics import *

VERSION = "0.2.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would specify in the name that it's the plugin version, to avoid confusion with the ADS version. so maybe rename it to PLUGIN_VERSION

@mathieuboudreau
Copy link
Member

@Stoyan-I-A I updated instructions for debugging with a bit more details, it works for me now! https://github.com/neuropoly/axondeepseg/wiki/fsleyes-plugin

@mathieuboudreau
Copy link
Member

Do we know if this plugin/fsleyes will/should work on Windows OS?

@Stoyan-I-A
Copy link
Member Author

Do we know if this plugin/fsleyes will/should work on Windows OS?

FSLeyes isn't supported on Windows. I tried to install it with the PyPi package and it wasn't working correctly.

That being said, I did find some instructions to run FSLeyes on Windows with a Linux Subsystem
https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FslInstallation/Windows

@jcohenadad
Copy link
Member

jcohenadad commented Oct 1, 2019

When trying to re-install the plugin, an error pops up on FSLeyes:

Screen Shot 2019-10-01 at 12 14 05 PM

UPDATE 2019-10-01 12:16:05: Doing a pip install -e . solved it (requirements changed recently)

Copy link
Member

@mathieuboudreau mathieuboudreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per Julien's recommendation on Slack, and since we've likely reviewed this branch/feature more-or-less 10 times & users are already beginning to use it, I'm going to approve this PR and merge so that I can record a tutorial video for it. Any remaining fixes/changes should now be done by opening small (i.e. single-issue or single-feature) pull requests, and not in another big one like this.

Great job @Stoyan-I-A ! This feature is going to be incredibly useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment