0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 clear all
0022
0023
0024 cd d:\matlab\cvs\eeg_toolbox\lapint
0025
0026
0027
0028
0029
0030 if isequal(exist('eeg_interp_scalp_mesh_data.mat'),2),
0031 fprintf('\nLoading saved data.\n');
0032 load 'eeg_interp_scalp_mesh_data';
0033 return
0034 end
0035
0036
0037 p = eeg_toolbox_defaults('create');
0038
0039 p = elec_open(p);
0040
0041 p = eeg_open(p);
0042
0043 p = mesh_open(p);
0044
0045
0046
0047 p = mesh_plot(p);
0048 close all
0049
0050
0051 scalpvert = p.mesh.data.vertices{3};
0052 scalpface = p.mesh.data.faces{3};
0053 elecvert = p.mesh.data.vertices{4};
0054 elecface = p.mesh.data.faces{4};
0055
0056
0057 Velec = p.volt.data;
0058
0059 clear p;
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 Scalpindex = dsearchn(scalpvert,elecvert)';
0072
0073
0074 lap = mesh_laplacian(scalpvert,scalpface);
0075
0076
0077 [Lint, keepindex, repindex] = mesh_laplacian_interp(lap,Scalpindex);
0078
0079
0080
0081 time = 100;
0082 if isempty(repindex),
0083 Vscalp = Lint * Velec(time,:)';
0084 else
0085 Vscalp = Lint * Velec(time,keepindex)';
0086 end
0087
0088
0089
0090
0091 return
0092
0093
0094
0095 fig = figure;
0096 Hp = patch('vertices',scalpvert,'faces',scalpface,'FaceVertexCdata',Vscalp,'facecolor','interp','edgecolor','none');
0097 axis off tight vis3d
0098 lighting gouraud
0099
0100 map = eeg_colormap('Red/Blue/White');
0101 colormap(map)
0102
0103 [az,el] = view;
0104 lit = lightangle(az,el);
0105
0106 set(Hp,'AmbientStrength',.7);
0107 set(Hp,'DiffuseStrength',.3);
0108 set(Hp,'SpecularStrength',0);
0109 set(Hp,'SpecularColorReflectance',0);
0110
0111
0112
0113
0114 set(gcf,'BackingStore','off');
0115 set(Hp,'EraseMode','normal');
0116 figure(fig);
0117
0118 rect = get(fig,'Position');
0119 rect(1:2) = [0 0];
0120
0121 clear M
0122
0123 start = 120;
0124 finish = 160;
0125 for t=start:finish,
0126 Vscalp = Lint * Velec(t,:)';
0127 set(Hp,'FaceVertexCdata',Vscalp);
0128 drawnow;
0129 M(t-(start-1)) = getframe(gcf,rect);
0130 end
0131
0132 playtimes = 1;
0133 fps = 15;
0134 figure; axis off; movie(gcf,M,playtimes,fps,rect);
0135 movie2avi(M,'scalp_interpolation.avi','quality',100);
0136
0137
0138
0139 return