Permalink
Browse files

FAQ: add entry about merging hemispheres

  • Loading branch information...
nno committed Oct 12, 2018
1 parent 6050285 commit 7d4e924ef2ecabff486ccef639d7d185e68bcbd4
Showing with 62 additions and 0 deletions.
  1. +62 −0 doc/source/faq.rst
@@ -1582,6 +1582,68 @@ For time-frequency data:
Note that there is no example script (yet) showing how to transform this data back into BrainStorm.
Make a merged hemisphere from a left and right hemisphere
---------------------------------------------------------
'Using Freesurfer I generated left and right hemisphere surface files. How can I combine them into a merged hemisphere?'
You could use the function below.
.. code-block:: matlab
function [v_merged, f_merged] = merge_surfaces(filenames)
% merge surface filesep
%
% Input:
% filenames: cell filenames of surfaces to merge, for example
% these can be '.asc' files as generated by FreeSurfer's
% recon_all
%
% Output:
% v_merged Nx3 matrix with vertex coordinates for N vertices
% f_merged Mx3 matrix with face indices for M faces
%
% Example:
% % merge left and right hemispheres of pial surface
% fns = {'lh.pial.asc', 'rh.pial.asc'}
% [v,f]=merge_surfaces(fns)
% surfing_write('mh.pial.asc',v,f);
%
% Note:
% - this function uses surfing_read from the Surfing toolbox.
% See https://github.com/surfing/surfing
% - the output can be saved with surfing_write
%
% Nick Oosterhof 2018-10-12
if ~iscellstr(filenames)
error('input must be cell with filenames')
end
n_surfaces = numel(filenames);
v_s = cell(n_surfaces,1);
f_s = cell(n_surfaces,1);
n_total = 0;
for k=1:n_surfaces
filename = filenames{k};
[v, f] = surfing_read(filename);
cosmo_disp(v)
cosmo_disp(f)
% keep the vertex coordinates
v_s{k} = v;
% update face indices to take into account previous input surfaces
f_s{k} = f + n_total;
# update index of first face for next surface
n_vertices = size(v,1);
n_total = n_total + n_vertices;
end
v_merged = cat(1,v_s{:});
f_merged = cat(1,f_s{:});

0 comments on commit 7d4e924

Please sign in to comment.