[FieldTrip] Creating a mesh

Fereshte fereshte.ramezani at gmail.com
Sat Sep 15 15:39:57 CEST 2018


Dear experts,
I've tried making a FEM head model using 5 head labels (GM, WM, CSF, skull
and scalp ; I have not used  "ft_volumesegment" to obtain these lables ). I
read these 5 labels in MATLAB using 'ft_read_mri' and then I try making a
mesh using 'v2m' function. The output doesn't seem to be correct due to the
number of nodes for outer GM (cortex) which is  '129626' and number of
nodes in total ( 169166 ). The code is written below.
I'd highly appreciate your help.
Thanks in advance,
Fereshte

clc
clear all
ft_defaults
%read image(mri) and 5 lable segmentation
mri = ft_read_mri('MRI.nii');
skull_c=ft_read_mri('Skull.nii');
scalp_c=ft_read_mri('Scalp.nii');
gray_c=ft_read_mri('gray.nii');
white_c=ft_read_mri('WM.nii');
csf_c=ft_read_mri('CSF.nii');
% making a volume
head=zeros(mri.dim(1),mri.dim(2),mri.dim(3));
head(find(scalp.anatomy))=1;
head(find(skull.anatomy))=2;
head(find(csf.anatomy))=3;
head(find(gray.anatomy))=4;
head(find(white.anatomy))=5;

imshow(head(:,:,100),[])
% mesh

[node, elem, face] = v2m(uint8(head),[],5,100,'cgalmesh'); % show the mesh
for corrected head model as _c

hs=plotmesh(node,face);
save mesh.mat node elem face;
%%% load mesh
load mesh.mat node elem face ;
ran=[1 2 4 3];
Nodem=mean(node(:,1:3));
mesh.pos=node(:,1:3)-ones(size(node,1),1)*Nodem;
mesh.tet=elem(:,ran);
mesh.labels=elem(:,5);
mesh.tissue=elem(:,5);
mesh.tissuelabel={'scalp', 'skull', 'CSF', 'gray', 'white',};
disp(mesh)
save mesh.mat -append mesh;
load mesh;
% outer GM surface nodes
GM=elem(find(elem(:,5)==4),1:4);
GM_surf=volface(GM);
test=GM_surf(:);%convert the test matrix to a vector
test_2=sort(test); % arrange the elements
GM_surface_nodes=unique(test_2); % remove the duplicate elements
[a b]=size(GM_surface_nodes);% find the position of the GM surface nodes
for i=1:a
    t=GM_surface_nodes(i,1);
    GM_surface_nodes_position(i,1:3)=node(t,1:3);
end
X=GM_surface_nodes_position;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20180915/ab9903cf/attachment-0001.html>


More information about the fieldtrip mailing list