Display dipoles across subjects on default anatomy

Hi,

I did dipole modelling and dipole scanning for the subject’s individual anatomy. Ideally in my next step I would like to display all dipoles found for a time point (for all subjects) on the standard cortex to compare their locations. I projected the source estimation on the default anatomy and was now wondering if there’s a way to do dipole scanning there to? I get the error message “reference to non existent field nAvg”. And is there a way to display the results on the same cortex, other then manipulating the matlab file and putting all relevant dipoles in one file?

Or maybe there is a smarter way to achieve a figure displaying the dipoles across subjects altogether?

Thanks a lot in advance!
Alice

Hello

I projected the source estimation on the default anatomy and was now wondering if there’s a way to do dipole scanning there to? I get the error message “reference to non existent field nAvg”

This is not supposed to work... But you should not get this error either.
Can you please post the full error message you get?

But otherwise, there is currently no solution working for projecting either the full dipoles maps or the selected most significant dipoles (process "dipole scanning") on a template.
The only solution I see for now is to use the template anatomy for all your subjects... which is not a very satisfying option either, because the positions of the dipoles wouldn't corrected for the anatomical differences across the various subjects.
This has been on our todo list for a while, but we won't have time to work on this immediately.

Or maybe there is a smarter way to achieve a figure displaying the dipoles across subjects altogether?

If you have multiple dipoles files available in the same folder, you can select them both, right-click > Merge dipoles. But this is not going to help much.

Sorry...
Francois

Thank you Francois for the reply anyway!

Here is the full error message:error

Concerning projecting the dipole maps on the template: we were wondering how the coordinates of the individual anatomy are projected to the cortex space of the template? Is there any function for converting the location coordinates in the dipole file to the location of the vertices in the template surface? Then we could maybe try to work on a solution ourselves?

Thanks again,
Alice

Thank you, I fixed the error you were getting (missing nAvg field), but it will not help you with your current objectives.
@Sylvain @John_Mosher Suggestions?

Concerning projecting the dipole maps on the template: we were wondering how the coordinates of the individual anatomy are projected to the cortex space of the template?

For cortical maps, we use the FreeSurfer or BrainSuite registrations, based on accurate sulci-based deformations:
https://neuroimage.usc.edu/brainstorm/Tutorials/CoregisterSubjects

For other 3D points (ie. dipole grids of volume source results), we use the affine SPM MNI transformation computed from the MRI Viewer, which is less accurate:
https://neuroimage.usc.edu/brainstorm/Tutorials/CoregisterSubjects#Volume_source_models

Is there any function for converting the location coordinates in the dipole file to the location of the vertices in the template surface?

There are functions to convert between SCS coordinates (in which the coordinates of your dipole files are) to MNI coordinates:
https://neuroimage.usc.edu/brainstorm/CoordinateSystems#Converting_between_coordinate_systems
I can't think of a solution that could use the accurate FreeSurfer/BrainSuite solution...

Then we could maybe try to work on a solution ourselves?

Maybe you could do something like editing the structure of the dipoles files (https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Custom_processing) to replace the SCS coordinates with the MNI coordinates, and them move the files to the "Group analysis" subject.

If you come up with a working solution and would like to share it with the community, I'm sure other users would find this very useful.
Feel free to open pull requests on the Brainstorm github: GitHub - brainstorm-tools/brainstorm3: Brainstorm software: MEG, EEG, fNIRS, ECoG, sEEG and electrophysiology

Let me know if you need additional pointers in the code or in the documentation.
Cheers,
Francois

Dear Francois & Brainstorm team,

Thank you very much for your previous answers to our problem!

Do you think the following approach would make sense?

  1. Project sources (individual results_Dipoles_KERNEL file) to a template surface.
    --> This gives us a results_dipole file in "group analysis" in which "ImageGridAmp" contains the performance of a dipole at each vertex and time point (projected to the template surface).

  2. Perform dipole scanning on "ImageGridAmp" of the template surface (results_dipole file in "group analysis") by finding the vertex with the maximum value for every time point.
    --> This results in an index of the best fitting vertex for every time point (on the template surface).

  3. Obtain the locations (SCS coordinates) of best fitting vertices from .Vertices in the template surface structure (e.g. "@default_subject/tess_cortex_pial_high.mat").

  4. Obtain the dipole orientation from .VertNormals in the template surface structure (because we only searched for dipoles normal to the cortex).

  5. Define the "amplitude" of the dipoles: Use values from ImageGridAmp of vertices found in step 2)
    (not yet implemented in the code below)

  6. Save the information of steps 3), 4), and 5) in a .mat with the same structure as the individual dipole scanning .mat

  7. Plot the projected and scanned dipoles (contained in the .mat from step 6)) on the template surface using a modified version of "view_dipoles.m". (We only added an additional input argument "surf2plot" to specify the surface on which to plot, and changed line 127 to "SurfaceFile = surf2plot").

Maybe the procedure gets clearer when looking at the code we used:
BrainstormForum_project_dipoles2template.m (2.6 KB)

...and the modified view_dipoles.m function:
view_dipoles_templ_surf.m (6.0 KB)

Do you think this approach would be an option? If so, one could extend this procedure to several subjects and plot their best fitting dipoles together in one template surface.

Thank you very much again for your support and best wishes,
Tilman

Hi Tilman,

Unfortunately, no, I'm not sure this works.
The problem comes from step #1: It takes the norm of the three values available at each location in your results_Dipoles_KERNEL file to save a flat map in the Group_analysis subject. I have no idea what the impact of this is, but I doubt it would be good for your files.

I would be less intimidated by the approach I suggest: estimate the dipoles on the individual anatomy, then convert the dipoles locations from SCS to MNI (you need to adjust the orientation as well... but I'm not sure what's the correct procedure for this)

I would really like to have the input from @John_Mosher on this topic: he wrote these functions, and I think used them for group analysis. He for sure has an opinion on the topic.

Francois

(I opened a related issue on our github: https://github.com/brainstorm-tools/brainstorm3/issues/171)

Hi Francois,

Thank you for the fast reply and for opening the issue on github.

I also tried to "manually" project the ImagingKernel (from the individual results_Dipoles_KERNEL file) on the template surface by doing:
ImageGridAmp_template = (Wmat * ImagingKernel_indiv) * EEG_data;
where Wmat is the interpolation matrix from the individual surface to the template surface (derived from the Freesurfer co-registration using tess_interp_tess2tess()).

These dipoles were (almost exactly) identical to the dipoles calculated with process_project_sources().
Before, I also worried about the flat map (process_source_flat()) but if I understood correctly this should actually not affect constrained dipoles (because their orientation is always normal to cortex)... But please correct me if I am wrong.

Thanks for the idea of converting SCS to MNI coordinates - we will try it!

Tilman

Using constrained sources, your option for projecting dipole maps is probably OK.

What is concerning is that I don't think @John_Mosher and @ebock designed these tools to work on constrained sources. For what I understood, this works best best on fully unconstrained source models (no location constraint, no orientation constraint), as illustrated in the EEG&Epilepsy tutorial:
https://neuroimage.usc.edu/brainstorm/Tutorials/Epilepsy#Dipole_scanning

Not discussing the projection to the MNI space, here is what you get if you use the dipole scanning with unconstrained (volume source model - left) vs. constrained (cortex / cortex normals - right):
image image

image image

The differences in localization are not negligible, and this is before adding more imprecision with the projection to the template. If you are interested in the localization accuracy, work with distributed source maps instead of isolated dipoles.
Unless @John_Mosher has other suggestions?...

We compared constrained and unconstrained dipoles. Indeed for subjects for whom the constrained dipole approach did not look so good, unconstrained dipoles seem to lead to better (more expected) results.

In our paradigm we applied median nerve stimulation, so we know where to expect a dipole at ~20 ms (Brodmann area 3b, hand region). Moreover, there should be only one main dipole that is responsible for the somatosensory evoked potential at ~20 ms and which is normal to cortex. This is why we originally decided for dipole scanning (constrained) to test and validate our individual headmodels...

We will try the other options, too, although finding one best fitting dipole at every time point seems to be most meaningful in our case. So it would be very interesting to hear from the authors of the dipole functions what they think about this issue.

Thanks a lot again for all your support so far!

With this type of design, you might want to consider just a single dipole fit instead of distributed sources - at least to confirm location/orientation. You can use the Fieldtrip function for that inside brainstorm or go for CTF SAM or Elekta xfit (depending on the manufacturer of your system)

Beth

I finally implemented the projection of a dipoles file on the MNI template:
https://github.com/brainstorm-tools/brainstorm3/commit/10f443b3e42aa25a0a08a4943f9c96fe8dc8c448

This uses the non-linear MNI registration if available, the linear registration otherwise:
https://neuroimage.usc.edu/brainstorm/CoordinateSystems#Non-linear_normalization

1 Like