show_stim_meas_pattern

PURPOSE ^

SHOW_STIM_MEAS_PATTERN: show the stim and meas pattern graphically

SYNOPSIS ^

function show_stim_meas_pattern(fwd_model,disp_meas,offset,elec_pp);

DESCRIPTION ^

 SHOW_STIM_MEAS_PATTERN: show the stim and meas pattern graphically
 usage: show_stim_meas_pattern(fwd_model,disp_meas,offset,elec_pp);

 Function that displays the electrodes utilised for each measurement.
 Each electrode is colour-coded depending on its operation
 
 Current Drive - Red
 Current Sink - Black
 Positive Potential Measurement - Green
 Negative Potential Measurement - Yellow

 Pressing any key changes the display to the next measurement

 Advanced Options
 "disp_meas" - 'y' or 'n' - selects whether the measuring electrodes are
                            displayed or not
 "disp_meas" - 'ya' or 'na' - animate the patterns
 "offset" - integer (1 to number of electrodes per plane), default=0
          - rotates the display by number of electrodes selected
 "elec_pp" - number of electrodes per plane

 (C) 2005 by Stephen Murphy. Licensed under GPL version 2.
 $Id: show_stim_meas_pattern.m 4988 2015-05-12 18:12:44Z aadler $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function show_stim_meas_pattern(fwd_model,disp_meas,offset,elec_pp);
0002 
0003 % SHOW_STIM_MEAS_PATTERN: show the stim and meas pattern graphically
0004 % usage: show_stim_meas_pattern(fwd_model,disp_meas,offset,elec_pp);
0005 %
0006 % Function that displays the electrodes utilised for each measurement.
0007 % Each electrode is colour-coded depending on its operation
0008 %
0009 % Current Drive - Red
0010 % Current Sink - Black
0011 % Positive Potential Measurement - Green
0012 % Negative Potential Measurement - Yellow
0013 %
0014 % Pressing any key changes the display to the next measurement
0015 %
0016 % Advanced Options
0017 % "disp_meas" - 'y' or 'n' - selects whether the measuring electrodes are
0018 %                            displayed or not
0019 % "disp_meas" - 'ya' or 'na' - animate the patterns
0020 % "offset" - integer (1 to number of electrodes per plane), default=0
0021 %          - rotates the display by number of electrodes selected
0022 % "elec_pp" - number of electrodes per plane
0023 %
0024 % (C) 2005 by Stephen Murphy. Licensed under GPL version 2.
0025 % $Id: show_stim_meas_pattern.m 4988 2015-05-12 18:12:44Z aadler $
0026 
0027 % old parameters
0028 %function show_stim_meas_pattern(vtx,srf,elec,Ib,indH,df,disp_meas,offset,elec_pp);
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 %figure
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                 % Driving electrode
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                 %sinking electrode
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                     % Driving electrode
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                         %drive_elec=[drive_elec;X';Y';Z'];
0156                     end
0157                 elseif Ib(loop2,loop1) ~=0
0158                     %sinking electrode
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                         %sink_elec=[sink_elec;X';Y';Z'];
0169                     end
0170                 end
0171             end     
0172             
0173             % Patch measuring electrodes
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 %   close;

Generated on Fri 30-Dec-2022 19:44:54 by m2html © 2005