Convert the results

Hi
Now I have the result after source localization, and I want to flip the left and right brain after source, what should I do, that is, flip the result of the right brain after sourcing to the left brain, and the result of the left brain to the right brain, what should I do.
Thank you for reply.

Flipping the activation between left and right hemispheres is not as trivial as it seems. This is because the hemispheres are not symmetrical and there is not an one-to-one equivalence between left- and right-hemisphere vertices. There are few post addressing this topic:

Thank you very much. I asked AI how to write the code to flip results, it gave me this:

% Replace with your paths
surfaceFile = 'path_to_your_cortex_surface.mat';
resultFile = 'path_to_your_source_result.mat';

% Load the surface
Surface = load(surfaceFile);
% Load the results
Results = load(resultFile);
``

% Flip the x coordinate
Surface.Vertices(:, 2) = -Surface.Vertices(:, 2);

% Flip source activity
Results.GridOrient = -Results.GridOrient;
if isfield(Results, 'ImageGridAmp')
    Results.ImageGridAmp = -Results.ImageGridAmp;
end
if isfield(Results, 'ImagingKernel')
    Results.ImagingKernel = -Results.ImagingKernel;
end

newSurfaceFile = 'path_to_your_new_flipped_surface.mat';
newResultFile = 'path_to_your_new_flipped_source_result.mat';

% Save new surface
save(newSurfaceFile, '-struct', 'Surface');
% Save new results
save(newResultFile, '-struct', 'Results');

I am trying to run this code, it works well. And the results fliped successfully. Maybe someone also need this.

Hi @xipeiyao, be careful as the code from your answer only flips the coordinates of the vertices, not the results. This is to say, it does not project the results from one hemisphere to the other, and the new flipped surface is not anatomically correct, it is just the mirror of the original one

Hi. Yes, you are right. I found this problem yesterday. I am trying to export source results to spm12, and writing code to flip results directly.
In this process, I have two questions. One is the source results have 15002 points when i export it to matlab, is there a mask or some other way to tell me which part of the brain this 15002 corresponds to. The other one is that i export results to the file of '.nii', and i wrote code to flip the first dimension of data, but i cannot import flipped data to brainstorm, how can i import flipped data into brainstorm, it awlays report an error:" number of source is different from the number of vertices". How can i import flipped data successfully.
Looking forward to your reply. Thank you very much.

The indices of the Results file correspond to the vertices in the Surface file (for surface source space).

Can you described how are you exporting and importing the NIfTI file?

Yeah, i know the results is correspond to the vertices of surface file. but i dont know which brain region is the vertices correspond to, such as i donot know which region is the first vertice.

I import '.nii' : creat a new folder to subject1----right click----file----import source maps----choose flipped data .nii file.

If you mean a surface scout by "brain region". Just look at the Scout that contains that vertex index in its Vertices field. Let me know if you refer to something else by "brain region"

Exporting sources as NIfTI creates a volume that has the same size as the Subject MRI. Thus it cannot be imported as sources (as Brainstorm defines the volume sources on a different grid):
https://neuroimage.usc.edu/brainstorm/Tutorials/TutVolSource