0001 function [interpdata, Hpatch] = topo3D(data,badchan,minmax,sigvals,thetitle);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 global hotncold hotter
0013 global stimchan EYE
0014 figure(100)
0015 hotncold2 = hotncold;
0016 hotter2 = jet;
0017 hotncold2(1,:) = 0.5;
0018 hotter2(1,:) = 0.5;
0019 close(100)
0020 if nargin ~=3 & nargin ~=4 & nargin ~= 5
0021 error('incorrect number of inputs');
0022 end;
0023 global ENVIRONMENT
0024 load headmodel.mat
0025 chans = [1:129];
0026 chans = removebadchan(chans,badchan);
0027 if nargin == 3
0028 sigvals = 0.01*ones(1,129);
0029 thetitle = [];
0030 if ~strcmp(ENVIRONMENT,'Lausanne')
0031 sigvals([stimchan EYE]) = 1;
0032 else
0033 sigvals(EYE) = 1;
0034 end;
0035 end;
0036 if nargin == 4
0037 thetitle = [];
0038 end;
0039 if isempty(minmax);
0040 if min(data(chans)) >= 0
0041 maxdata = max(data(chans));
0042 mindata = 0;
0043 else
0044 maxdata = max(abs(data(chans)));
0045 mindata = - maxdata;
0046 end
0047 else
0048 mindata = minmax(1);
0049 maxdata = minmax(2);
0050 end;
0051
0052 x = elp.x(chans)';
0053 y = elp.y(chans)';
0054 z = elp.z(chans)';
0055 v = data(chans);
0056 if mindata == 0
0057 v = round((v/maxdata+1/63)*63);
0058 else
0059 v = round((v/maxdata+32/63)*63);
0060 end;
0061 list1 = find(vertex_matrix(:,3) > 0.02 & vertex_matrix(:,1) > -0.04);
0062 list2 = find(vertex_matrix(:,3) > 0.00 & vertex_matrix(:,1) <= -0.04);
0063 xs = vertex_matrix([list1; list2],1);
0064 ys = vertex_matrix([list1; list2],2);
0065 zs = vertex_matrix([list1; list2],3);
0066 w= 10^-15;
0067 [k,kinv,a,ainv,e]= k_and_e(w,x,y,z);
0068 [p,q,error_check]= mateqs(w,x,y,z,v,k,kinv,a,ainv,e);
0069 interp3D = interp_3d(w,x,y,z,xs,ys,zs,p,q);
0070 interpdata = ones(length(vertex_matrix(:,1)),1);
0071 interp3D(find(interp3D <= 2)) = 2;
0072 interp3D(find(interp3D >= 64)) = 64;
0073 interpdata(list1) = interp3D(1:length(list1));
0074 interpdata(list2) = interp3D(length(list1)+1:end);
0075 figure
0076 Hpatch = patch('Vertices',vertex_matrix,'Faces',face_matrix,...
0077 'FaceVertexCData',interpdata,'facecolor','interp','edgecolor','k','CDataMapping','direct');
0078 if mindata < 0
0079 colormap(hotncold2)
0080 else
0081 colormap(hotter2)
0082 end
0083 hold on
0084 global stimchan EYE
0085 chanselec = [1:129];
0086 chanselec = removebadchan(chanselec,[stimchan EYE]);
0087 h = plot3(elp.x(chanselec),elp.y(chanselec),elp.z(chanselec),'ko');
0088 set(h,'MarkerFaceColor',[0.5 0.5 0.5]);
0089 set(h,'MarkerSize',4);
0090 sigchans = find(sigvals < 0.05);
0091 sigchans = removebadchan(sigchans, badchan);
0092 h = plot3(elp.x(sigchans),elp.y(sigchans),elp.z(sigchans),'ko');
0093 set(h,'MarkerFaceColor','k');
0094 set(h,'MarkerSize',9);
0095 axis image
0096 axis off
0097 h = colorbar;
0098 set(h,'YTick',[1 33 65]);
0099 set(h,'YTickLabel',[minmax(1) sum(minmax)/2 minmax(2)]');
0100 axis off
0101 view(-90,50)
0102 title(thetitle);
0103