Home > eeg > egis > spline > topo3D.m

topo3D

PURPOSE ^

topo3D(data,badchan,minmax,sigvals);

SYNOPSIS ^

function [interpdata, Hpatch] = topo3D(data,badchan,minmax,sigvals,thetitle);

DESCRIPTION ^

topo3D(data,badchan,minmax,sigvals);
makes a 3D topographic map.  Plots 2 standard views in separate figure
windows.  Each of these views can be rotated by the controls in the figure
window.  
data = 1by129 data at the EEG electrode positions
badchan = list of bad channels
minmax = [minimum maximum] data range for plots.  If an empty matrix 
is provided the program automatically sets the range
sigvals = (optional) 1by129 array of p values. if p < 0.05 the color of the electrode
positions is set to green otherwise its gray.  This parameter can be skipped.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [interpdata, Hpatch] = topo3D(data,badchan,minmax,sigvals,thetitle);
0002 %topo3D(data,badchan,minmax,sigvals);
0003 %makes a 3D topographic map.  Plots 2 standard views in separate figure
0004 %windows.  Each of these views can be rotated by the controls in the figure
0005 %window.
0006 %data = 1by129 data at the EEG electrode positions
0007 %badchan = list of bad channels
0008 %minmax = [minimum maximum] data range for plots.  If an empty matrix
0009 %is provided the program automatically sets the range
0010 %sigvals = (optional) 1by129 array of p values. if p < 0.05 the color of the electrode
0011 %positions is set to green otherwise its gray.  This parameter can be skipped.
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 %

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003