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

Volume 2 Surface ROIs #170

Closed
mb3152 opened this issue Nov 22, 2016 · 22 comments
Closed

Volume 2 Surface ROIs #170

mb3152 opened this issue Nov 22, 2016 · 22 comments

Comments

@mb3152
Copy link

mb3152 commented Nov 22, 2016

if I have some MNI volume space ROIs, is there an easy way to get the outlines on the surface?

@alexhuth
Copy link
Contributor

No trivial way, I'm afraid. Easiest one-off thing to do would be to add your volume-space ROIs to the ROIs file one by one (assuming you have an MNI flatmap) using cortex.add_roi and then outline them by hand in any SVG editor (we mostly use inkscape).

A more generic approach would be to convert your volume-space ROIs into vertex-space ROIs (using cortex.mapper functions), and then creating outlines for them programmatically. We have code for doing that but it's currently highly experimental (read: won't work without a shitload of tweaking and digging). I can point you in that direction if you like.

@mb3152
Copy link
Author

mb3152 commented Nov 22, 2016

Outlining it totally fine. I am just doing Thomas Yeo's 17 networks, so not too bad. I can't figure out exactly what the cortex.add_roi function requires, though.

I am pulling up the networks with:

vol = cortex.Volume('Yeo_MNI152/17_networks.nii.gz', subject='MNI', xfmname='identity')
brain = cortex.webgl.show(vol)

How would I call cortex.add_roi?

Thanks!

@alexhuth
Copy link
Contributor

You would just call:
cortex.add_roi(vol, name='17_networks')
this will attempt to open inkscape automatically (unless you also add open_inkscape=False), and it will create a new ROI layer called "17_networks". If you want a separate "ROI" for each of the 17, you will need to create new layers for each one.

@mb3152
Copy link
Author

mb3152 commented Nov 22, 2016

hmm, I have inkscape, but I get this error:

//anaconda/lib/python2.7/site-packages/cortex/utils.pyc in add_roi(data, name, open_inkscape, add_path, **kwargs)
196
197 if open_inkscape:
--> 198 return sp.call(["inkscape", '-f', rois.svgfile])

OSError: [Errno 2] No such file or directory

The only files I have for MNI space are the ones you gave me a while ago, which just has the surfaces and the anatomical file. Am I missing a file I need?

@alexhuth
Copy link
Contributor

pycortex is trying to call inkscape from the command line and that's failing. If you're in osx, I doubt you have inkscape set up that way (I know I don't). Just call it with open_inkscape=False, and then open the file yourself in inkscape.

@mb3152
Copy link
Author

mb3152 commented Nov 22, 2016

AH okay, that is working. How do you I add it as an overlay on the original image after I edit the SVG file?

@alexhuth
Copy link
Contributor

Okay so if you've added new layers to the "rois" group in the SVG file, and drawn outlines in those layers, then they will show up as lines when you call webshow (you may have to throw a recache=True into your webshow call though). For an example of what the SVG file should look like, you can check out the rois.svg file included for subject S1: https://github.com/gallantlab/pycortex/blob/master/filestore/db/S1/rois.svg

@mb3152
Copy link
Author

mb3152 commented Nov 22, 2016

Great! Got it. Looks awesome now. Thanks so much Alex.

@mb3152
Copy link
Author

mb3152 commented Nov 22, 2016

Is there a way to only show a single ROI, or a certain set of ROIs?

@alexhuth
Copy link
Contributor

Slightly tricky. You could put them in separate layer groups (i.e. outside the 'rois' group), then tell webshow explicitly to include them. This should create an interface in the viewer that will let you turn them on or off individually, though that currently fails with more than 2-3 groups (we use it for rois, sulci, and gyri).

The more manual approach is simply to set some rois to not be visible, that should propagate correctly iirc.

@mb3152
Copy link
Author

mb3152 commented Nov 22, 2016

Second approach seems a bit easier! How do I set some to not be visible? I can only set all visible in the browser.

@mb3152
Copy link
Author

mb3152 commented Nov 22, 2016

And, in general, is there an easy way to control the ROI features from the command line? For example, control the fill color, outline color et cetera?

@alexhuth
Copy link
Contributor

err what i meant by "set some to be not visible" was to do that in the SVG. Not a scalable solution by any stretch.

You can control the ROI attributes in your cfg file.. there may also be a hacky way to set them online, but that's the easiest way.

@mb3152
Copy link
Author

mb3152 commented Nov 22, 2016

ahh okay got it. what are the variable names for the individual alpha levels for ROIs?

@alexhuth
Copy link
Contributor

I think it's 'stroke-opacity' in SVG-lingo, if you set that property in your options.cfg does it work?

@mb3152
Copy link
Author

mb3152 commented Nov 22, 2016

hmm, does not work. But I like the lines alone anyways. Thanks!

@marklescroart
Copy link
Contributor

I'm going to close this issue, since this all seems to be resolved, but as a side note, it's now possible to do somewhat fancier things with the different display layers in quickflat by adding each overlay separately through compositing. See https://gallantlab.github.io/auto_examples/quickflat/plot_advanced_compositing.html#sphx-glr-auto-examples-quickflat-plot-advanced-compositing-py for an example. (Note that this only works on the glrework-merged branch for now, which will (soon??) be merged into the master branch.

@kwayeke
Copy link

kwayeke commented Nov 2, 2017

@alexhuth "A more generic approach would be to convert your volume-space ROIs into vertex-space ROIs (using cortex.mapper functions), and then creating outlines for them programmatically. We have code for doing that but it's currently highly experimental (read: won't work without a shitload of tweaking and digging). I can point you in that direction if you like." I already have my ROIs in vertex-space. Could you please direct me on how to create the paths/outlines programmatically?

@marklescroart
Copy link
Contributor

AFAIK there isn't any functional code to create paths / lines around ROIs in the .svg file programmatically (note: older file for master branch is rois.svg, newer file created by new glrework-merged branch is overlays.svg). There may be stubs of things lying about somewhere in some little-used function, but unless @alexhuth can point you there, I suggest you add ROIs using the add_roi function as described above.

@alexhuth
Copy link
Contributor

alexhuth commented Nov 2, 2017

I wrote some code to do this a while ago, but the results were a bit ugly and I don't think I ever added it to pycortex. I can try to dig it up, though it may be a while.. sorry @kwayeke!

@kwayeke
Copy link

kwayeke commented Nov 2, 2017

Thanks a million for your prompt response @alexhuth

@kwayeke
Copy link

kwayeke commented Nov 13, 2017

@alexhuth did you find something?

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

4 participants