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

use matplotlib color maps #127

Open
burdinskid13 opened this issue Nov 20, 2023 · 7 comments
Open

use matplotlib color maps #127

burdinskid13 opened this issue Nov 20, 2023 · 7 comments

Comments

@burdinskid13
Copy link

Hi there! I have been trying to use fsleyes render together with two matplotlib color maps that I'd like to use. I cannot figure out how to properly add them to this command to make it work unfortunately. Any help would be much appreciated! Specifically, I'd like to use the Greens and Purples colormaps in the places of $cmap_pos and $cmap_neg. See my code below, which works fine with the built-in color maps in the places of $cmap_pos and $cmap_neg. Thank you!

! fsleyes render --neuroOrientation --outfile $Out -sz  500 500 \
       --selectedOverlay 1 --scene ortho --worldLoc 0 0 0 \
       --zcentre  0  0 --showLocation no \
       --layout horizontal --hidex --hidey --hideCursor \
       --showColourBar --colourBarLocation right --colourBarLabelSide top-left --colourBarSize 85.0 --labelSize 14 \
       $Anat --overlayType volume  \
       $Effect --name "" --overlayType volume --modulateImage $Stat --cmap $cmap_pos --negativeCmap $cmap_neg --useNegativeCmap --displayRange 0.0 13 --modulateRange 0.0 7.0 --modulateAlpha \
       $Stat --overlayType mask --alpha 100.0 --threshold -$Threshold $Threshold --outline --maskColour 0 0 0

@pauldmccarthy
Copy link
Owner

Hi @burdinskid13, this works fine for me - what version o FSLeyes are you using?

fsleyes  render -of out.png  \
  ~/fsl_course_data/rest/ICA/groupICA15/melodic_IC \
  -cm Greens -nc Purples -dr 0 5

out

@burdinskid13
Copy link
Author

I installed fsleyes using the recommended option conda install -c conda-forge fsleyes. When I try to update, I get the message # All requested packages already installed. When I run fsleyes --version I get: fsleyes/FSLeyes version 1.10.1

@pauldmccarthy
Copy link
Owner

And what version of matplotlib do you have installed?

What happens when you try to use a built-in colour map? Do you get any error messages? Is an output file produced?

@burdinskid13
Copy link
Author

I currently have matplotlib: 3.7.1. I don't get any error messages when I use the built-in color maps from fsleyes and the output is produced correctly

@pauldmccarthy
Copy link
Owner

By "built-in", I meant a matplotlib colour map, e.g. Greens - specifically what happens?

@burdinskid13
Copy link
Author

burdinskid13 commented Dec 4, 2023

Sorry, I thought you meant built-in to fsleyes. Here is the error message when I use --cmap Greens:

Traceback (most recent call last):
  File "/om2/user/dclb/.miniconda/envs/fsleyes/lib/python3.9/site-packages/fsleyes/colourmaps.py", line 1262, in _caseInsensitiveLookup
    idx = lKeys.index(k.lower())
ValueError: 'greens' is not in list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/om2/user/dclb/.miniconda/envs/fsleyes/bin/fsleyes", line 10, in <module>
    sys.exit(main())
  File "/om2/user/dclb/.miniconda/envs/fsleyes/lib/python3.9/site-packages/fsleyes/filtermain.py", line 216, in main
    result = fm.main(args)
  File "/om2/user/dclb/.miniconda/envs/fsleyes/lib/python3.9/site-packages/fsleyes/main.py", line 234, in main
    render.main(args[1:])
  File "/om2/user/dclb/.miniconda/envs/fsleyes/lib/python3.9/site-packages/fsleyes/render.py", line 93, in main
    bitmap, bg = render(
  File "/om2/user/dclb/.miniconda/envs/fsleyes/lib/python3.9/site-packages/fsleyes/render.py", line 423, in render
    cbarBmp = buildColourBarBitmap(overlayList,
  File "/om2/user/dclb/.miniconda/envs/fsleyes/lib/python3.9/site-packages/fsleyes/render.py", line 676, in buildColourBarBitmap
    cbarBmp = cb.colourBar(width, height)
  File "/om2/user/dclb/.miniconda/envs/fsleyes/lib/python3.9/site-packages/fsleyes/controls/colourbar.py", line 304, in colourBar
    cmap = fslcm.getColourMapMplKey(cmap.name)
  File "/om2/user/dclb/.miniconda/envs/fsleyes/lib/python3.9/site-packages/fsleyes/colourmaps.py", line 740, in getColourMapMplKey
    return _caseInsensitiveLookup(_cmaps, key).mplkey
  File "/om2/user/dclb/.miniconda/envs/fsleyes/lib/python3.9/site-packages/fsleyes/colourmaps.py", line 1265, in _caseInsensitiveLookup
    else:                   raise  KeyError(k)
KeyError: 'Greens'

@pauldmccarthy
Copy link
Owner

Hmm, I suspect that you may have multiple versions of FSLeyes installed - going by the line numbers in the stack trace, it looks like you are using version 1.8.x. Earlier when you reported that you were using 1.10.1, I'm guessing that you were using a diferent FSLeyes installation.

Can you update FSLeyes and matplotlib in the conda environment that you are using? You should be able to do this with a command such as:

conda update -n fsleyes -c conda-forge --update-deps fsleyes matplotlib

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

No branches or pull requests

2 participants