function varargout=axontp(varargin) % % AXONTP % % VARARGOUT = AXONTP % Testpulse program for Axon amplifier using one shot % acquisition. % Assumes the following: % - Frequency = 10KHz % - Command sensitivity = 100 mV/V % - Output gain = 1 V/nA % % This program delivers a testpulse (currently 2mV in amplitude % and 20msec wide) on both output channels, and monitors the output % current. Also plots the access resistance over time. % global handles datafighandles % If we were called with no arguments means we were called straight % from matlab; so we will set up the figure. if nargin==0 % Set up the main figure mainfig = figure; uicontrol('style','checkbox','units','inches','position',[4.2 6.5 1.2 .3],'string','testpulse (on)','tag','power','backgroundcolor',[.1 .4 .9],'callback','axontp(''conflute'')'); axes('units','inches','position',[1.25 4 3 2],'tag','axes1'); ... xlabel('time, ms'); axes('units','inches','position',[5.25 4 3 2],'tag','axes2'); ... xlabel('time, ms'); axes('units','inches','position',[1.25 1 3 2],'tag','axes3'); ... xlabel('time, s'); axes('units','inches','position',[5.25 1 3 2],'tag','axes4'); ... xlabel('time, s'); set(mainfig,'Units','inches','color',[.8 .3 0],'pointer','custom', ... 'position',[.1 3.5 9.25 7],'handlevisibility','on',... 'name','Axon Testpulse'); handles=guihandles(mainfig); %---------------------------------------- % Set up the accessory figure with the data values datafig = figure; yvalue = 6.4; for ichannel = 1:2 % Amplifier 1 Label uicontrol('style','text','units','inches','position',[.2 yvalue 2.1 .2], ... 'FontName', 'helvetica', 'FontSize',12, 'FontWeight', 'bold',... 'HorizontalAlignment', 'left', 'string',sprintf('Amplifier %d', ichannel), ... 'backgroundcolor',[.9 .9 0]); %% Rtotal yvalue = yvalue - 0.3; uicontrol('style','text','units','inches','position',[.2 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','Rtot.', ... 'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[.75 yvalue 1 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','no value', ... 'tag',sprintf('rtot%d',ichannel),'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[1.8 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',10, ... 'tag',sprintf('rtot%d_units',ichannel), 'HorizontalAlignment', 'left',... 'string','Mohms', 'backgroundcolor',[.9 .9 0]); %% Rseries yvalue = yvalue - .3; uicontrol('style','text','units','inches','position',[.2 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','Rser.', ... 'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[.75 yvalue 1 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','no value', ... 'tag',sprintf('rser%d',ichannel),'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[1.8 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',10, ... 'HorizontalAlignment', 'left', 'string','Mohms', ... 'backgroundcolor',[.9 .9 0]); %% Rpipette yvalue = yvalue - .3; uicontrol('style','text','units','inches','position',[.2 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','Rpip.', ... 'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[.75 yvalue 1 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','not set', ... 'tag',sprintf('rpip%d',ichannel),'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[1.8 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',10, ... 'HorizontalAlignment', 'left', 'string','Mohms', ... 'backgroundcolor',[.9 .9 0]); uicontrol('style','checkbox','units','inches','position',[.75 (yvalue-.35) ... 1.6 .3], 'FontName', 'helvetica', 'FontSize',10, ... 'tag',sprintf('rpip%dc',ichannel),'HorizontalAlignment', 'left', ... 'string','Set Rpipette', 'backgroundcolor',[.9 .9 0], ... 'callback', sprintf('axontp(''setrpipette'')', ichannel)); %% Ra yvalue = yvalue - .75; uicontrol('style','text','units','inches','position',[.2 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','Ra', ... 'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[.75 yvalue 1 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','no value', ... 'tag',sprintf('ra%d',ichannel),'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[1.8 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',10, ... 'HorizontalAlignment', 'left', 'string','Mohms', ... 'backgroundcolor',[.9 .9 0]); %% Rm yvalue = yvalue - .3; uicontrol('style','text','units','inches','position',[.2 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','Rm', ... 'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[.75 yvalue 1 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','no value', ... 'tag',sprintf('rm%d',ichannel),'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[1.8 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',10, ... 'HorizontalAlignment', 'left', 'string','Mohms', ... 'backgroundcolor',[.9 .9 0]); %% Cm yvalue = yvalue -.3; uicontrol('style','text','units','inches','position',[.2 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','Cm', ... 'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[.75 yvalue 1 .2], ... 'FontName', 'helvetica', 'FontSize',12, ... 'HorizontalAlignment', 'left', 'string','no value', ... 'tag',sprintf('cm%d',ichannel), 'backgroundcolor',[.9 .9 0]); uicontrol('style','text','units','inches','position',[1.8 yvalue .5 .2], ... 'FontName', 'helvetica', 'FontSize',10, ... 'HorizontalAlignment', 'left', 'string','pFarads', ... 'backgroundcolor',[.9 .9 0]); yvalue = yvalue - 1.3; end set(datafig,'Units','inches','color',[.8 .3 0],'pointer','custom', ... 'position',[10 3.5 2.5 7],'handlevisibility','on','name','Axon Datascreen'); datafighandles = guihandles(datafig); % -- Both the figures have now been set up ------------------------------ if nargout > 0 varargout{1} = fig; end % The elseif below goes with the "if nargin == 0" above % elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK try if (nargout) [varargout{1:nargout}] = feval(varargin{:}); else feval(varargin{:}); % FEVAL switchyard end catch disp(lasterr); end end %------------------------------------------------------------------- % This is the main function, the one that gets called when the % testpulse button is pressed. %------------------------------------------------------------------- function varargout=conflute(varargin) % We need the Rtotal to be global because it is used to transfer % data to setrpipette. global handles datafighandles Rtotal %init parameters Fs = 10000; % Frequency (in Hz) stimlength = 1000; % in samples pulsewidth = 200; % in samples scaling = 100; % mV/V, the command sensitivity of the amplifier gain = 1; % V/nA, the output gain of the amplifier amplitude = 2; % mV, amplitude of test pulse nrepeat = 1; % number of times we want the testpulse repeated % We will only do things here if the "testpulse" button is on. If % not, we will just lie here and shrivel. power = get(handles.power,'value'); if power == 1 % We will have two x axes: one called time, in msecs, to % plot the output current, and one called rrtime, in secs, % to plot the access resistance over time. chan0 = zeros(1,600); chan1 = zeros(1,600); rr = zeros(999,2); time = [1:600] * 1000 / Fs; %units in msec rrtime=[1:999] * stimlength / Fs; %units in sec % create handles to plots in respective axes axes(handles.axes1); pl1 = plot(time,chan0); xlabel('Time (ms)'); ylabel('current (pA)'); axes(handles.axes2); pl2 = plot(time,chan1); xlabel('Time (ms)'); ylabel('current (pA)'); axes(handles.axes3); pl3 = plot(rrtime,rr(:,1)); xlabel('Time (s)'); set(gca,'ylim',[0 ... 200],'xlim',[0 100]); ylabel('R_{access} (M\Omega)'); axes(handles.axes4); pl4 = plot(rrtime,rr(:,2)); xlabel('Time (s)'); set(gca,'ylim',[0 ... 200],'xlim',[0 100]); ylabel('R_{access} (M\Omega)'); set(gcf, 'doublebuffer', 'on'); % While the "testpulse" button is pressed, this while loop will % execute, sending out a testpulse and plotting the output appropriately while get(handles.power,'value')==1; % Call testpulse now [Rtotal Rseries Rmem Cmem Ileak current] = testpulse(Fs, scaling, gain, amplitude, pulsewidth, nrepeat); % Rseries is returned in ohms, and we want to plot it in megaohms, % so we convert it here. for ichannel = 1:2 rr(:,ichannel) = [rr(2:999,ichannel); Rseries(ichannel)*10^-6]; end % First we update the four graphs set(pl1, 'ydata', current(:,1)); set(pl2, 'ydata', current(:,2)); set(pl3, 'ydata', rr(:,1)); set(pl4, 'ydata', rr(:,2)); drawnow; % Now we update the text fields with the different resistance % and capacitance values % % We check to see that the datascreen window exists, because % we allow the user to turn it off. if (findobj('name', 'Axon Datascreen')) % We will display the total resistance in Mohms or Gohms depending % on the approximate range if (Rtotal(1) > 10^9) set(datafighandles.rtot1,'string',sprintf('%3.1f', (Rtotal(1)*10^-9))); set(datafighandles.rtot1_units,'string','Gohms'); else set(datafighandles.rtot1,'string',sprintf('%3.1f', (Rtotal(1)*10^-6))); set(datafighandles.rtot1_units,'string','Mohms'); end if (Rtotal(2) > 10^9) set(datafighandles.rtot2,'string',sprintf('%3.1f', (Rtotal(2)*10^-9))); set(datafighandles.rtot2_units,'string','Gohms'); else set(datafighandles.rtot2,'string',sprintf('%3.1f', (Rtotal(2)*10^-6))); set(datafighandles.rtot2_units,'string','Mohms'); end set(datafighandles.rser1,'string',sprintf('%2.1f', (Rseries(1)*10^-6))); set(datafighandles.rser2,'string',sprintf('%2.1f', (Rseries(2)*10^-6))); if (strcmp(get(datafighandles.rpip1,'string'), 'not set')) set(datafighandles.ra1,'string',sprintf('%2.1f', (Rseries(1)*10^-6))); else rpipette = str2num(get(datafighandles.rpip1,'string')) * 10^6; set(datafighandles.ra1,'string',sprintf('%2.1f', ((Rseries(1)-rpipette)*10^-6))); end if (strcmp(get(datafighandles.rpip2,'string'), 'not set')) set(datafighandles.ra2,'string',sprintf('%2.1f', (Rseries(2)*10^-6))); else rpipette = str2num(get(datafighandles.rpip2,'string')) * 10^6; set(datafighandles.ra2,'string',sprintf('%2.1f', ((Rseries(2)-rpipette)*10^-6))); end set(datafighandles.rm1,'string',sprintf('%2.1f', (Rmem(1)*10^-6))); set(datafighandles.rm2,'string',sprintf('%2.1f', (Rmem(2)*10^-6))); set(datafighandles.cm1,'string',sprintf('%2.1f', (Cmem(1)*10^12))); set(datafighandles.cm2,'string',sprintf('%2.1f', (Cmem(2)*10^12))); drawnow; end % Now we're done updating everything. Yahoo! pause(0.1) end end %------------------------------------------------------------------- % When user clicks on Set R_pipette, this transfers the resistance % during the voltage step (should be just rt since there are no % capacitors involved), to the R_pipette value. % % This should be done ONLY when the pipette is in the bath not near % a cell. Setting R_pipette ensures accurate calculation of the % access resistance Ra during the patch. function setrpipette % We need the Rtotal to be global because that's how we % get data from the acquisition routine. The return value % is not transferred in a variable; the acquisition function % simply reads the string that we set here. global datafighandles Rtotal if (strcmp (get(gcbo, 'tag'), 'rpip1c')) if get(gcbo, 'value') == 1 set(datafighandles.rpip1,'string',sprintf('%2.1f', (Rtotal(1)*10^-6))); else set(datafighandles.rpip1,'string', 'not set'); end else if get(gcbo, 'value') == 1 set(datafighandles.rpip2,'string',sprintf('%2.1f', (Rtotal(2)*10^-6))); else set(datafighandles.rpip2,'string', 'not set'); end end %-------------------------------------------------------------------