Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
fahsuanlin authored Feb 10, 2024
1 parent 78335af commit 8b517d4
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions scripts/prep_bem_fhlin.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
close all; clear all;

subjects_dir='/Users/fhlin/workspace/eegmri_wm/subjects';
subject='s001';

file_surf={
{'outer_skin.surf'},
{'outer_skull.surf'},
{'inner_skull.surf'},
{'../surf/lh.orig'};
{'../surf/rh.orig'},
};

output_file_surf={
's001_skin.mat'
's001_skull.mat'
's001_csf.mat'
's001_gm_lh.mat'
's001_gm_rh.mat'
};

for f_idx=1:length(file_surf)
vv=[];ff=[];
for i_idx=1:length(file_surf{f_idx})
if(length(file_surf{f_idx})==1)
[vv,ff]=read_surf(sprintf('%s/%s/bem/%s',subjects_dir,subject, file_surf{f_idx}{i_idx}));
else
[vv_tmp,ff_tmp]=read_surf(sprintf('%s/%s/%s',subjects_dir,subject, file_surf{f_idx}{i_idx}));
vv=cat(1,vv,vv_tmp);
ff=cat(1,ff,ff_tmp);
end;
end;
surf_vertex{f_idx}=vv;
surf_face{f_idx}=ff;

surf_face{f_idx}=surf_face{f_idx}+1;

TR = triangulation(surf_face{f_idx},surf_vertex{f_idx});
surf_center{f_idx}= incenter(TR);
surf_norm{f_idx} = faceNormal(TR);

%save files for e-field modeling
P=surf_vertex{f_idx};
t=surf_face{f_idx};
normals=surf_norm{f_idx};
save(sprintf('%s',output_file_surf{f_idx}),'P','t','normals');

hold on;
colors=get(gca,'colororder');
h=patch('vertices',surf_vertex{f_idx},'faces',surf_face{f_idx},'edgecolor','none','facecolor',colors(f_idx,:),'facealpha',0.2);
%quiver3(surf_center{f_idx}(:,1),surf_center{f_idx}(:,2),surf_center{f_idx}(:,3),surf_norm{f_idx}(:,1),surf_norm{f_idx}(:,2),surf_norm{f_idx}(:,3),0.5,'color','r');

end;
view(-160,20);
lighting phong
camlight
axis off vis3d equal

0 comments on commit 8b517d4

Please sign in to comment.