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 May 28, 2024
1 parent ac5fc5c commit cc4a179
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions scripts/make_decimated_bem_052524.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
clear all; close all

setenv('SUBJECTS_DIR','/Users/fhlin/workspace/eegmri/subjects/'); %for MAC/Linux

file_surface={
'/Users/fhlin/workspace/eegmri/subjects/180411_PYY/bem/outer_skin.surf';
'/Users/fhlin/workspace/eegmri/subjects/180411_PYY/bem/outer_skull.surf';
'/Users/fhlin/workspace/eegmri/subjects/180411_PYY/bem/inner_skull.surf';
};

R=0.1; %10% of triangulation faces
colors=colororder;

for f_idx=1:length(file_surface)
fprintf('reading [%s]...\n',file_surface{f_idx});
[vertex_coords{f_idx}, faces{f_idx}] = read_surf(file_surface{f_idx});
faces{f_idx}=faces{f_idx}+1; %1-based faces

fprintf('decimating [%s] for %2.2f triangulation...\n',file_surface{f_idx}, R);
[faces_reduced{f_idx}, vertex_coords_reduced{f_idx}] = reducepatch(faces{f_idx}, vertex_coords{f_idx}, R);


[pp,ff,ee]=fileparts(file_surface{f_idx});
fn=sprintf('%s/%s_d10%s',pp,ff,ee);
fprintf('saving decimated surface [%s] ...\n',fn);
write_surf(fn, vertex_coords_reduced{f_idx}, faces_reduced{f_idx}); %0-based faces conversion automatically!!

color_idx=mod(f_idx-1,size(colors,1))+1;
figure(1); hold on;
h=patch('faces',faces{f_idx},'vertices',vertex_coords{f_idx},'edgecolor','none','facealpha',0.2); axis off image vis3d; view(-130, 45);
set(h,'facecolor',colors(color_idx,:));

figure(2); hold on;
h=patch('faces',faces_reduced{f_idx},'vertices',vertex_coords_reduced{f_idx},'edgecolor','none','facealpha',0.2); axis off image vis3d; view(-130, 45);
set(h,'facecolor',colors(color_idx,:));

end;

0 comments on commit cc4a179

Please sign in to comment.