0001 function show_stim_meas_pattern(fwd_model,disp_meas,offset,elec_pp);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 pp= np_fwd_parameters( fwd_model);
0031 vtx = pp.vtx;
0032 srf = pp.srf;
0033 elec = pp.elec;
0034 Ib = pp.Ib;
0035 df = pp.df;
0036 indH = pp.indH;
0037
0038
0039 set(gcf,'Name','Wire Mesh Current Injections')
0040
0041 if nargin<2
0042 disp_meas='n';
0043 end
0044 if nargin<4
0045 elec_pp= [];
0046 end
0047
0048 animate=0;
0049 if length(disp_meas)==2
0050 if disp_meas(2)=='a'
0051 animate= .2;
0052 else
0053 error('don''t understand disp_meas parameter');
0054 end
0055 disp_meas= disp_meas(1);
0056 end
0057
0058 if disp_meas=='n'
0059
0060 for loop1=1:size(Ib,2)
0061
0062 trimesh(srf,vtx(:,1),vtx(:,2),vtx(:,3));
0063 axis image;
0064 xlabel('x')
0065 ylabel('y')
0066 zlabel('z')
0067 set(gcf,'Colormap',[0 0 0]);
0068
0069 if ~isempty( elec_pp)
0070 set(gca,'CameraViewAngleMode','Manual');
0071 camera_angle=360/elec_pp;
0072 camorbit(camera_angle*offset,0);
0073 end
0074
0075 hidden off;
0076 title(['Current Injection ' num2str(loop1)])
0077
0078 drive_elec=[];
0079 sink_elec=[];
0080
0081 for loop2=1:size(Ib,1)
0082 if Ib(loop2,loop1) ~=0 & isreal(sqrt(Ib(loop2,loop1)))
0083
0084 for loop3=0:(size(elec,2)/3)-1
0085
0086 if ( elec(loop2,1+(loop3*3)) ~= 0 & elec(loop2,2+(loop3*3)) ~=0 & elec(loop2,3+(loop3*3)) ~=0 )
0087 X = [vtx(elec(loop2,1+(loop3*3)),1);vtx(elec(loop2,2+(loop3*3)),1);vtx(elec(loop2,3+(loop3*3)),1)];
0088 Y = [vtx(elec(loop2,1+(loop3*3)),2);vtx(elec(loop2,2+(loop3*3)),2);vtx(elec(loop2,3+(loop3*3)),2)];
0089 Z = [vtx(elec(loop2,1+(loop3*3)),3);vtx(elec(loop2,2+(loop3*3)),3);vtx(elec(loop2,3+(loop3*3)),3)];
0090 end
0091
0092 patch(X,Y,Z,'r');
0093 drive_elec=[drive_elec;X';Y';Z'];
0094 end
0095 elseif Ib(loop2,loop1) ~=0
0096
0097 for loop3=0:(size(elec,2)/3)-1
0098
0099 if ( elec(loop2,1+(loop3*3)) ~= 0 & elec(loop2,2+(loop3*3)) ~=0 & elec(loop2,3+(loop3*3)) ~=0 )
0100 X = [vtx(elec(loop2,1+(loop3*3)),1);vtx(elec(loop2,2+(loop3*3)),1);vtx(elec(loop2,3+(loop3*3)),1)];
0101 Y = [vtx(elec(loop2,1+(loop3*3)),2);vtx(elec(loop2,2+(loop3*3)),2);vtx(elec(loop2,3+(loop3*3)),2)];
0102 Z = [vtx(elec(loop2,1+(loop3*3)),3);vtx(elec(loop2,2+(loop3*3)),3);vtx(elec(loop2,3+(loop3*3)),3)];
0103 end
0104
0105 patch(X,Y,Z,'k');
0106 sink_elec=[sink_elec;X';Y';Z'];
0107 end
0108 end
0109 end
0110
0111 if animate>0
0112 pause(animate);
0113 else
0114 pause;
0115 end
0116
0117 end
0118
0119 elseif disp_meas=='y'
0120 meas_no=1;
0121 for loop1=1:size(Ib,2)
0122
0123 while meas_no<=sum(df(1:loop1))
0124 trimesh(srf,vtx(:,1),vtx(:,2),vtx(:,3));
0125 axis image;
0126 xlabel('x')
0127 ylabel('y')
0128 zlabel('z')
0129 set(gcf,'Colormap',[0 0 0]);
0130
0131 if ~isempty(elec_pp)
0132 set(gca,'CameraViewAngleMode','Manual');
0133 camera_angle=360/elec_pp;
0134 camorbit(camera_angle*offset,0);
0135 end
0136
0137 hidden off;
0138 title(sprintf('Stim #=%d, Meas #=%d', loop1, meas_no))
0139
0140 drive_elec=[];
0141 sink_elec=[];
0142
0143 for loop2=1:size(Ib,1)
0144 if Ib(loop2,loop1) ~=0 & isreal(sqrt(Ib(loop2,loop1)))
0145
0146 for loop3=0:(size(elec,2)/3)-1
0147
0148 if ( elec(loop2,1+(loop3*3)) ~= 0 & elec(loop2,2+(loop3*3)) ~=0 & elec(loop2,3+(loop3*3)) ~=0 )
0149 X = [vtx(elec(loop2,1+(loop3*3)),1);vtx(elec(loop2,2+(loop3*3)),1);vtx(elec(loop2,3+(loop3*3)),1)];
0150 Y = [vtx(elec(loop2,1+(loop3*3)),2);vtx(elec(loop2,2+(loop3*3)),2);vtx(elec(loop2,3+(loop3*3)),2)];
0151 Z = [vtx(elec(loop2,1+(loop3*3)),3);vtx(elec(loop2,2+(loop3*3)),3);vtx(elec(loop2,3+(loop3*3)),3)];
0152 end
0153
0154 patch(X,Y,Z,'r');
0155
0156 end
0157 elseif Ib(loop2,loop1) ~=0
0158
0159 for loop3=0:(size(elec,2)/3)-1
0160
0161 if ( elec(loop2,1+(loop3*3)) ~= 0 & elec(loop2,2+(loop3*3)) ~=0 & elec(loop2,3+(loop3*3)) ~=0 )
0162 X = [vtx(elec(loop2,1+(loop3*3)),1);vtx(elec(loop2,2+(loop3*3)),1);vtx(elec(loop2,3+(loop3*3)),1)];
0163 Y = [vtx(elec(loop2,1+(loop3*3)),2);vtx(elec(loop2,2+(loop3*3)),2);vtx(elec(loop2,3+(loop3*3)),2)];
0164 Z = [vtx(elec(loop2,1+(loop3*3)),3);vtx(elec(loop2,2+(loop3*3)),3);vtx(elec(loop2,3+(loop3*3)),3)];
0165 end
0166
0167 patch(X,Y,Z,'k');
0168
0169 end
0170 end
0171 end
0172
0173
0174 for loop3=0:(size(elec,2)/3)-1
0175 if ( elec(indH(meas_no,1),1+(loop3*3)) ~= 0 & elec(indH(meas_no,1),2+(loop3*3)) ~=0 & elec(indH(meas_no,1),3+(loop3*3)) ~=0 )
0176 X = [vtx(elec(indH(meas_no,1),1+(loop3*3)),1);vtx(elec(indH(meas_no,1),2+(loop3*3)),1);vtx(elec(indH(meas_no,1),3+(loop3*3)),1)];
0177 Y = [vtx(elec(indH(meas_no,1),1+(loop3*3)),2);vtx(elec(indH(meas_no,1),2+(loop3*3)),2);vtx(elec(indH(meas_no,1),3+(loop3*3)),2)];
0178 Z = [vtx(elec(indH(meas_no,1),1+(loop3*3)),3);vtx(elec(indH(meas_no,1),2+(loop3*3)),3);vtx(elec(indH(meas_no,1),3+(loop3*3)),3)];
0179 end
0180
0181 patch(X,Y,Z,'g');
0182 end
0183
0184 for loop3=0:(size(elec,2)/3)-1
0185 if ( elec(indH(meas_no,2),1+(loop3*3)) ~= 0 & elec(indH(meas_no,2),2+(loop3*3)) ~=0 & elec(indH(meas_no,2),3+(loop3*3)) ~=0 )
0186 X = [vtx(elec(indH(meas_no,2),1+(loop3*3)),1);vtx(elec(indH(meas_no,2),2+(loop3*3)),1);vtx(elec(indH(meas_no,2),3+(loop3*3)),1)];
0187 Y = [vtx(elec(indH(meas_no,2),1+(loop3*3)),2);vtx(elec(indH(meas_no,2),2+(loop3*3)),2);vtx(elec(indH(meas_no,2),3+(loop3*3)),2)];
0188 Z = [vtx(elec(indH(meas_no,2),1+(loop3*3)),3);vtx(elec(indH(meas_no,2),2+(loop3*3)),3);vtx(elec(indH(meas_no,2),3+(loop3*3)),3)];
0189 end
0190
0191 patch(X,Y,Z,'y');
0192 end
0193 meas_no=meas_no+1;
0194
0195 if animate>0
0196 pause(animate);
0197 else
0198 pause;
0199 end
0200
0201 end
0202 end
0203 else
0204 error('parameter disp_meas not understood');
0205 end
0206
0207