Problem with projected source map

Hi. I am trying to project a subject coherence map to the default anatomy. I think I may have done something wrong, but I cannot figure it out. I compute the coherence between each vertex and a stimulus channel signal. Then I extract (using extract values) one frequency and I have a cortical map, show here on the top. Then I right click and project to default anatomy. The result is the map on the bottom. Any clues when that is?

It could be either:

  1. an issue with the interpolation matrix (computed using the freesurfer spheres)
    => Do you get the same issue for all the subjects?
  2. an issue with the way time-frequency or connectivity files are projected
    => Do you get the same absurd results when projecting source maps (instead of coherence maps)?

Yes for both questions. So I guess its the interpolation matrix. Any idea how to fix it?

Hi there, any resolution on this issue? After updating to the new version, I get the same problem when projecting sources on default anatomy, the results look fine on the individual anatomy but then look like your second map at the bottom.
Thank you in advance for your help.

we found possible bug, please, advise asap

In tess_interp_tess2tess function

line 167 (and following lines have similar problem)

vertSphLsrc = srcSurfMat.Reg.Sphere.Vertices(1:length(iVertLsrc), :);

should be

vertSphLsrc = srcSurfMat.Reg.Sphere.Vertices(iVertLsrc, :);

iVertLsrc is not in numerical order

Hello,

This issue was reported multiple times, but I never got the chance to get the data to investigate it.
Your suggested fix would not work in some cases: The cortex surface can include more structures and typically has more vertices than the Sphere array, which includes only the two hemispheres. Therefore the indices iVertLsrc do not always match the corresponding vertices in srcSurfMat.Reg.Sphere.Vertices. The goal of this “1:length(iVertLsrc)” is to take the correct number of vertices regardless of the actual indices.

But indeed, if the indices iVertLsrc are not sorted, it might cause an issue in the computation of the interpolation matrix, line 277/279. I need to understand two things:

  1. How is it possible that the indices in iVertLsrc are not sorted
  2. How to match correctly the indices in the sphere and cortex lists of vertices

Could you please send me an example dataset, with which I could reproduce your erroneous interpolation?

  • Right-click on the subject > File > Duplicate subject
  • Delete all the files that are not needed to reproduce the error
  • Right-click on the subject > File > Export subject
  • Upload the zip file somewhere (eg dropbox, google drive…) and post here the link to download it.

Thanks
Francois

Hi Francois,

The indices are not sorted for the cortex surface in FS Average after reducing the number of vertices to 10,001.

Thank you very much,
Anda

I created a new subject, set FSAverage as its anatomy, downsampled it to 10000V and and projected some source files to it.
The indices stay sorted, and the projected maps looks good.
At line 167, isequal(1:length(iVertLsrc), iVertLsrc) returns 1.

What version of Matlab are you using?
If you made multiple experiments, make sure you delete the interpolation matrices in the subject cortex surface (right-click on the subject cortex surface > Remove interpolations)

Please send me an example dataset so I can investigate all the possible issues.
Thanks

Francois, we are using Matlab 2013.
So, in the old version of Brainstorm (Oct 2015) it works fine, the old code actually uses the indices vector not only its length, but the new code has an issue.
Since the problem appears to be related to the FSAverage, we can send you our FSAverage folder (obtained after reducing to 10000 vertices), then you can test it with any MRI/dataset.

https://www.dropbox.com/s/aq6srbcqkh89c7q/%40default_subject.zipx?dl=0

FSAverage folder and reduced cortex surface was originally created in Brainstorm ver Oct 2015 and then the database was used with the new ver Jun 2018

In October 2015, there wasn’t any support for projecting mixed source models on a template. This explains the changes in the indexing. It added some complexity that is clearly not well handled in this function, I’ll have a look at it.

If your database is from before 2016, you should start by updating your template.
Right-click on the Default anatomy > Use template > FSAverage 2016

Another option to guarantee consistency is to use your old database with the old software, and then start using a new version of the software when you start importing/processing new data.

Thank you, Francois, for your kind prompt help. Much appreciated.

I can see a file named “old-tess_cortex_pial_low_10000V.mat”, this means you renamed manually some of the files. In the future, I recommend you avoid moving or renaming files in the brainstorm database manually, always use the database explorer in Brainstorm for manipulating the files. This is an important source of inconsistencies in the data structures.

Got it. I think we copied one atlas from one protocol to another. Thanks!

The problem resides in the downsampling. Previously Brainstorm was not preserving the order of the vertices when downsampling the surfaces. Use your old anatomy, downsample the surface again to 10000V, and the projection works.

I rehabilitated the old code that was handling these old surfaces (which was still in the function but commented out). Now Brainstorm should be able to detect if the surfaces are old (and use the old code) or if they are new (and use the new code). This is a dirty fix, I hope it is not going to break anything else...

Update Brainstorm and it should now work with your existing protocol. It can be useful if you have lots of recordings using these old surfaces and don't want to recompute everything. Otherwise, update Brainstorm, update the template, and downsample again the surface to 10000V, to make sure all the structures are up-to-date.

Will do. Thank you, Francois!