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

Improved Defacing module (version 2?) #62

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Improved Defacing module (version 2?) #62

wants to merge 13 commits into from

Conversation

raamana
Copy link
Owner

@raamana raamana commented Apr 7, 2022

incorporating valuable suggestions from @Arshitha @ericearl et al.

fixes #59 #60

and maybe even #61 let's see :)

@raamana
Copy link
Owner Author

raamana commented Apr 7, 2022

Eric, you can use this branch (after pull and pip install -e . dev install) to play with it and see how you like it

@raamana
Copy link
Owner Author

raamana commented Apr 7, 2022

a small issue, we need to pay attention to, is to ensure slice percent location 50 is actually "middle" of the brain in each view. I will double check the implementation of SlicePicker, keep an eye on this as you review different subjects

@raamana
Copy link
Owner Author

raamana commented Apr 8, 2022

Hi @Arshitha, to integrate fsleyes, work off the v2_defacing branch that this PR is based on.

it's a also a good practice not to use master for major new features like adding fsleyes rendering. Don't hesitate to ping me if you have questions, or got lost in the codebase for more than few hours :)

@Arshitha
Copy link

okay, thanks @raamana ! I created a new branch but it makes more sense to use v2_defacing branch. :) I'll keep you posted on my progress

@raamana
Copy link
Owner Author

raamana commented Apr 15, 2022

sounds good! keep me posted.

@Arshitha
Copy link

Arshitha commented Apr 12, 2023

@raamana As I'm working on defacing scans again, I'm trying to figure out an easier way to generate 3D renders. fsleyes render has been useful but one issue with fsleyes render is that it opens an XQuartz session each time the command runs and thereby momentarily taking over screen control. This issue is exacerbated when the command is run within a loop and I lose complete control over my screen until the loop finishes, which is not a great solution. Are you aware of any other tools that generate 3D renders through command line?

@raamana
Copy link
Owner Author

raamana commented Apr 12, 2023

not really!

can you try rerun fsleyes script, after setting MPL with below, before running the for loop?

    matplotlib.use('Agg')
    matplotlib.interactive(False)

maybe @pauldmccarthy has some ideas on how to keep FSLeyes in the background / batch processing mode?

@Arshitha
Copy link

Arshitha commented Apr 12, 2023

Thanks @raamana ! I was able to figure with the help our HPC staff. I missed the key instruction of fsleyes render docs page about exporting an environment variable called PYOPENGL_PLATFORM="osmesa" and unsetting the DISPLAY variable.

@raamana
Copy link
Owner Author

raamana commented Apr 12, 2023

awesome! I can't wait to incorporate fsleyes render into the defacing module, if I can find a way to easily install it on most common OSes.

@pauldmccarthy
Copy link

awesome! I can't wait to incorporate fsleyes render into the defacing module, if I can find a way to easily install it on most common OSes.

@raamana Conda is definitely the easiest method for installing FSLeyes, e.g.:

conda create -n fsleyes -c conda-forge fsleyes

Using pip is problematic, as wxPython wheels for Linux are not available on pypi (they are hosted separately at https://extras.wxpython.org/wxPython4/extras/linux/gtk3/), and a range of wxPython dependencies need to be installed by the OS package manager.

In contrast, installing with conda/mamba will install all of the required dependencies in a single step, and works on macOS and all Linux flavours (and Windows too, assuming that a reasonable OpenGL version is supported).

@raamana
Copy link
Owner Author

raamana commented Apr 13, 2023

thanks Paul - few questions:

  1. what's the smallest package of fsleyes we can create with minimal set of dependencies just for the rendering part? I am guessing we will still need the OPENGL related parts?

  2. can we create a shell script to help make installation from pypi easy (even for just Linux and macOS)? I am trying to move away from Conda altogether as it was bulky and slow etc, and I've recently erased it all and started from scractch for my own development.

@raamana
Copy link
Owner Author

raamana commented Apr 13, 2023

also, given we don't need any FSLeyes GUI at all, I am wondering if there is a way to do away with wxPython altogether? that's assuming no install issues with OpenGL related stuff.

even if we a bit of GUI/canvas is needed, we can try replace wxPython with more native or pip-friendly Tkinter or another library in a minimal way and proceed with batch generation of renders?

@pauldmccarthy
Copy link

also, given we don't need any FSLeyes GUI at all, I am wondering if there is a way to do away with wxPython altogether? that's assuming no install issues with OpenGL related stuff.

even if we a bit of GUI/canvas is needed, we can try replace wxPython with more native or pip-friendly Tkinter or another library in a minimal way and proceed with batch generation of renders?

Replacing wxPython with a different toolkit is not really an option, as there is far too much wxPython-specific code in FSLeyes. I did consider TKinter very early on, but it has poor support for OpenGL (at least it did in 2014), so was basically a non-starter.

Allowing off-screen rendering without having wxPython installed should be possible, but would require quite a bit of refactoring, so is unlikely to happen any time soon. It's a nice idea though, so I may be able to look into it at some point (unless somebody else wants to have a go - contributions are welcome!).

With that said...

what's the smallest package of fsleyes we can create with minimal set of dependencies just for the rendering part? I am guessing we will still need the OPENGL related parts?

For volumetric rendering you need everything in requirements.txt. For mesh rendering you will also need rtree and trimesh. If not using conda, you will also need to use your OS package manager to install additional dependencies for wxPython and rtree.

can we create a shell script to help make installation from pypi easy (even for just Linux and macOS)? I am trying to move away from Conda altogether as it was bulky and slow etc, and I've recently erased it all and started from scractch for my own development.

Conda is the best option from my perspective, as it works on every platform, and takes care of non-python dependencies. Have you tried mamba? It is much faster than conda. You can test it out by installing one of the Mamabaforge variants of miniforge.

However, of course it is possible to script a pypi-based installation. There are some notes in the FSLeyes user docs which you may find useful.

On macOS you need to:

  1. install libspatialindex (required by rtree).
  2. Run pip install fsleyes - macOS wheels for wxPython are available on pypi, so this should be all you need to do.

On Linux you need to:

  1. Install libSDL, and possibly some other wxPython dependencies. You might find this script useful (it is used in the docker images I use for testing).
  2. Instal libspatialindex
  3. Install wxPython with e.g. pip install -f https://extras.wxpython.org/wxPython4/extras/linux/gtk2/centos-7 wxpython
  4. Run pip install fsleyes

@raamana
Copy link
Owner Author

raamana commented Apr 14, 2023

thanks very much Paul for the detailed notes - can you dumb down the macOS installation instructions further (exactly where to get wheels and how to apply them locally etc)? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New set of checkboxes for visible features
3 participants