hacking mne_setup_source_space

Hi all,
My colleague and I created a script to add subcortical structures like the amygdala and hippocampus surfaces to the the white and pial freesurffer surfaces we call these modified surfaces cortex. Our goal it to try to extend sources to these subcortical ROI's.

We then try to execute: mne_setup_source_space --subject $SUBJECT
--overwrite --surface cortex --ico 5 --cps

We get an error at step 3 define cortical patches:

error : Node 18 does not belong to any of the patches.

Is there any way to resolve this error, and do source analysis on this extended brain surface?

thanks //dave

David I. Leitman PhD

Research Assistant Professor
Department of Psychiatry-
Neuropsychiatry program
Perelman School of Medicine
University of Pennsylvania
Gates Pavilion 10th floor room 1042
3400 Spruce St
Philadelphia, PA 19104-4283
P: (215) 662-7389
F: (215) 662-7903
E: leitman at mail.med.upenn.edu
Faculty page: http://www.med.upenn.edu/apps/faculty/index.php/g275/p8174343
Lab website:
http://davidileitman.com

The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the the Neuropsychiatry Section immediately by e-mail, and delete the original message.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140412/ab2f89b0/attachment.html

It sounds like your definition of tris might omit some of the included
vertices, in other words it's an invalid triangulation of the surface. IIRC
the patch statistics are derived using the connectivity of the surface,
which in turn is derived from the triangulation.

An alternative approach (and probably more future compatible) would be to
make it so you're source space had three or more parts: the standard two
hemispheres, plus an arbitrary volumetric grid or even surface, if you
wish. There is some primitive and lightly tested support for this in
mne-python, and some work on this might be done this summer. If you're
interested, feel free to open an issue there and we can work on it.

Another option that might work would be to not compute patch stats (no
-cps), but I would guess faking the surfaces this way will cause (more)
problems as you go, as various pieces of software may reasonably (but
incorrectly) assume hemispheres refer to the original freesufer surfaces.

Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140412/ef4ae691/attachment.html

Hi Eric,
please see below:

It sounds like your definition of tris might omit some of the included vertices, in other words it's an invalid triangulation of the surface. IIRC the patch statistics are derived using the connectivity of the surface, which in turn is derived from the triangulation.

An alternative approach (and probably more future compatible) would be to make it so you're source space had three or more parts: the standard two hemispheres, plus an arbitrary volumetric grid or even surface, if you wish. There is some primitive and lightly tested support for this in mne-python, and some work on this might be done this summer. If you're interested, feel free to open an issue there and we can work on it.

Hi were could i find these primitive versions and support ?

Another option that might work would be to not compute patch stats (no -cps), but I would guess faking the surfaces this way will cause (more) problems as you go, as various pieces of software may reasonably (but incorrectly) assume hemispheres refer to the original freesufer surfaces.

This is exactly what we did we have been able create and add surfaces using some scripts from A.M winkler at http://brainder.org with these and opiting --cps from setup source space we have been able to apply the inverse model and get MNE estimates from amygdala and hippocampus. At this point I am writing a script to automate the surface merge and create label files for the new merged surface and its sub cortical constituents. By merging in a specific order we are able to keep track of the vertices, such that each surface whit AMY and HIP have vertex numbers that are in a distinct range based on their merge order.
once the script is complete I will send it on to you and the listserve.

You mention problems down the road, what kind of problems do you think we might encounter?

Eric
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

David I. Leitman PhD

Research Assistant Professor
Department of Psychiatry-
Neuropsychiatry program
Perelman School of Medicine
University of Pennsylvania
Gates Pavilion 10th floor room 1042
3400 Spruce St
Philadelphia, PA 19104-4283
P: (215) 662-7389
F: (215) 662-7903
E: leitman at mail.med.upenn.edu
Faculty page: http://www.med.upenn.edu/apps/faculty/index.php/g275/p8174343
Lab website:
http://davidileitman.com

The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the the Neuropsychiatry Section immediately by e-mail, and delete the original message.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140414/d135a1ab/attachment.html

Hey David,

Responses inline below.

... surface, if you wish. There is some primitive and lightly tested
support for this in mne-python, and some work on this might be done this
summer. If you're interested, feel free to open an issue there and we can
work on it.

Hi were could i find these primitive versions and support ?

Some of the stable volume/discrete source space functionality is documented
here:

http://martinos.org/mne/stable/generated/mne.setup_volume_source_space.html#mne.setup_volume_source_space

The equivalent in the C code would be "mne_volume_source_space". In Python,
a "source space" is just a type of list, the most common of which is a
two-element list containing one space for the left hemisphere, and the
other for the right. So in principle one could append to this standard
two-element list any arbitrary number of additional volume or discrete
source spaces, such as the amygdala or hippocampus. We haven't extensively
tested how such code integrates with the rest of the pipeline (e.g., with
forward solutions and inverses, let alone plotting), but this is the type
of approach we will likely use in the near future. It would be great if we
could get your input or (even better!) contributions to the code base to
help this along.

If you prefer working with the C+MATLAB tools instead of Python, you could
consider using "mne_volume_source_space" to set up a discrete source space
containing any additional structures of interest, and then using the MATLAB
toolbox to combine them and write them out to disk.

Another option that might work would be to not compute patch stats (no
-cps), but I would guess faking the surfaces this way will cause (more)
problems as you go, as various pieces of software may reasonably (but
incorrectly) assume hemispheres refer to the original freesufer surfaces.

...
You mention problems down the road, what kind of problems do you think we
might encounter?

The source space FIFF files created by MNE (both MNE-C
mne_setup_source_space and mne-python equivalent) are marked as being of
"surface" type, as opposed to "discrete" or "volume" type:

https://github.com/mne-tools/mne-python/blob/master/mne/fiff/constants.py#L531

And I'd have to check, but they might even explicitly be marked as left and
right hemisphere somewhere:

https://github.com/mne-tools/mne-python/blob/master/mne/fiff/constants.py#L274

I think some of the downstream code assumes (at least) a couple of things
about such source spaces, namely 1) that each surface-type source space
will contain a valid triangulation (e.g., all nodes exist in the
triangulation somewhere), and 2) that these source spaces will correspond
to the left and right hemispheres as obtained from Freesurfer. Both of
these assumptions appear to be violated by your modifications, so any code
that relies on the assumptions above may be prone to failures.

For example, "--cps" appears to be one instance. I'd have to think about
how well forward solution code would handle it; having source locations and
normals might be sufficient there, since that's all you'd get with a
discrete source space (which forward solutions can be calculated for), but
having the FIFF tags indicating that the two spaces are of surface type
might break something somewhere. I wouldn't expect plotting utilities like
mne_analyze or PySurfer to succeed on any STCs or inverses downstream,
since valid triangulations are the bread and butter of the OpenGL calls at
the heart of those code sets -- and these programs also assume things about
surfaces coming from Freesurfer. I also wouldn't expect any morphing
procedures to work, since these use the Freesurfer-defined morph maps.
There may be other examples, but these are a few I can think of for now.

Cheers,
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140414/48e3abf8/attachment.html