clamp.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. function varargout = clamp(varargin)
  2. % CLAMP MATLAB code for clamp.fig
  3. % CLAMP, by itself, creates a new CLAMP or raises the existing
  4. % singleton*.
  5. %
  6. % H = CLAMP returns the handle to a new CLAMP or the handle to
  7. % the existing singleton*.
  8. %
  9. % CLAMP('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in CLAMP.M with the given input arguments.
  11. %
  12. % CLAMP('Property','Value',...) creates a new CLAMP or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before clamp_OpeningFcn gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to clamp_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22. % Edit the above text to modify the response to help clamp
  23. % Last Modified by GUIDE v2.5 01-Aug-2018 17:00:38
  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name', mfilename, ...
  27. 'gui_Singleton', gui_Singleton, ...
  28. 'gui_OpeningFcn', @clamp_OpeningFcn, ...
  29. 'gui_OutputFcn', @clamp_OutputFcn, ...
  30. 'gui_LayoutFcn', [] , ...
  31. 'gui_Callback', []);
  32. if nargin && ischar(varargin{1})
  33. gui_State.gui_Callback = str2func(varargin{1});
  34. end
  35. if nargout
  36. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38. gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT
  41. % --- Executes just before clamp is made visible.
  42. function clamp_OpeningFcn(hObject, eventdata, handles, varargin)
  43. % This function has no output args, see OutputFcn.
  44. % hObject handle to figure
  45. % eventdata reserved - to be defined in a future version of MATLAB
  46. % handles structure with handles and user data (see GUIDATA)
  47. % varargin command line arguments to clamp (see VARARGIN)
  48. % Update the current L&F
  49. %originalLnF = javax.swing.UIManager.getLookAndFeel; %class
  50. %newLnF = 'javax.swing.plaf.metal.MetalLookAndFeel'; %string
  51. %javax.swing.UIManager.setLookAndFeel(newLnF);
  52. % Restore the original L&F
  53. %javax.swing.UIManager.setLookAndFeel(originalLnF);
  54. %Create a data acquisition session
  55. handles.devices = daq.getDevices;
  56. handles.daqSession = daq.createSession('ni');
  57. % Add channels specified by subsystem type and device
  58. chAI0=addAnalogInputChannel(handles.daqSession,'Dev1', 0, 'Voltage');
  59. chAI0.TerminalConfig = 'SingleEndedNonReferenced';
  60. chAI1=addAnalogInputChannel(handles.daqSession,'Dev1', 1, 'Voltage');
  61. chAI1.TerminalConfig = 'SingleEndedNonReferenced';
  62. chAO0=addAnalogOutputChannel(handles.daqSession,'Dev1', 0, 'Voltage');
  63. % Configure Data Acquisition Properties
  64. handles.daqSession.Rate = 100000;
  65. handles.secToAccuire=1;%Sample period in seconds
  66. handles.vHold=-100;
  67. handles.scaleFactorI=0.1; %0.1 V per uA
  68. handles.scaleFactorV=10; %V output scaled 10x on OC-725C
  69. handles.mVconversion=1000; %To mV
  70. handles.mSconversion=1000; %To mS
  71. handles.msToSamples=handles.daqSession.Rate/handles.mSconversion;
  72. handles.saveData=0;
  73. handles.leakSubtraction=0;
  74. handles.PathName='C:\Users\Hugo\Documents\MATLAB';
  75. handles.FileName='clamp.mat';
  76. handles.btnStop=0;
  77. % Axis lim
  78. handles.xMin = 300;
  79. handles.xMax = 350;
  80. handles.yMinI = -5;
  81. handles.yMaxI = 0;
  82. handles.yMinV = -120;
  83. handles.yMaxV = 80;
  84. % Info
  85. handles.newCell=0;
  86. handles.human=0;
  87. handles.neandertal=0;
  88. handles.iData=[];
  89. handles.vData=[];
  90. handles.time=[];
  91. plot(handles.axes1,[],[]);
  92. xlabel(handles.axes1,'Time (ms)');
  93. ylabel(handles.axes1,'Current (uA)');
  94. axis(handles.axes1,[handles.xMin handles.xMax handles.yMinI handles.yMaxI]);
  95. plot(handles.axes2,[],[]);
  96. xlabel(handles.axes2,'Time (ms)');
  97. ylabel(handles.axes2,'Voltage (mV)');
  98. axis(handles.axes2,[handles.xMin handles.xMax handles.yMinV handles.yMaxV]);
  99. % Choose default command line output for clamp
  100. handles.output = hObject;
  101. % Update handles structure
  102. guidata(hObject, handles);
  103. % UIWAIT makes clamp wait for user response (see UIRESUME)
  104. % uiwait(handles.figure1);
  105. % --- Outputs from this function are returned to the command line.
  106. function varargout = clamp_OutputFcn(hObject, eventdata, handles)
  107. % varargout cell array for returning output args (see VARARGOUT);
  108. % hObject handle to figure
  109. % eventdata reserved - to be defined in a future version of MATLAB
  110. % handles structure with handles and user data (see GUIDATA)
  111. % Get default command line output from handles structure
  112. varargout{1} = handles.output;
  113. % --- Executes on button press in actFastInact.
  114. function actFastInact_Callback(hObject, eventdata, handles)
  115. % hObject handle to actFastInact (see GCBO)
  116. % eventdata reserved - to be defined in a future version of MATLAB
  117. % handles structure with handles and user data (see GUIDATA)
  118. handles.btnStop=0;
  119. guidata(hObject, handles);
  120. hold(handles.axes1,'off');
  121. hold(handles.axes2,'off');
  122. holdingVoltage=handles.vHold;
  123. testPulsStart=holdingVoltage;
  124. testPulsEnd=20;
  125. testPulsInactivation=0;
  126. sleepTime=10;
  127. %Stockholmsprotokollet. 9-11 grader. Oklart vilken paus mellan?
  128. preStimulusTime=60; %ms
  129. stimulus1Time=300; %ms
  130. stimulus2Time=40; %mS
  131. postStimulusTime=120; %mS
  132. samplesToAcquire=(preStimulusTime+stimulus1Time+stimulus2Time+postStimulusTime)*handles.msToSamples;
  133. nrOfSweeps=(testPulsStart-(testPulsEnd))/-10+1;
  134. iData=zeros(samplesToAcquire,nrOfSweeps);
  135. vData=zeros(samplesToAcquire,nrOfSweeps);
  136. time=zeros(samplesToAcquire,nrOfSweeps);
  137. testPuls=testPulsStart;
  138. i=1;
  139. while testPuls<=testPulsEnd% used to be 10 steps
  140. if i>1
  141. pause(sleepTime);
  142. end
  143. drawnow() %Give the abort callback a chance to interrupt
  144. handles = guidata(hObject); %Update the GUI data
  145. if handles.btnStop==1 % stop condition
  146. disp('Aborted.')
  147. break;
  148. end
  149. preStimulusVoltage=holdingVoltage; %mV
  150. preStimulus=preStimulusVoltage*ones(preStimulusTime*handles.msToSamples,1);
  151. stimulus1Voltage=holdingVoltage+(i-1)*10; %mV
  152. stimulus1=stimulus1Voltage*ones(stimulus1Time*handles.msToSamples,1);
  153. stimulus2Voltage=testPulsInactivation; %mV
  154. stimulus2=stimulus2Voltage*ones(stimulus2Time*handles.msToSamples,1);
  155. postStimulusVoltage=holdingVoltage; %mV
  156. postStimulus=postStimulusVoltage*ones(postStimulusTime*handles.msToSamples,1);
  157. line0=vertcat(preStimulus,stimulus1,stimulus2,postStimulus);
  158. queueOutputData(handles.daqSession,line0*(handles.scaleFactorV/handles.mVconversion));
  159. [inputData,time(:,i),triggerTime] = handles.daqSession.startForeground();
  160. iData(:,i)=(1/handles.scaleFactorI)*inputData(:,1); %data in uA
  161. vData(:,i)=(handles.mVconversion/handles.scaleFactorV)*inputData(:,2); %data in mV
  162. %Leak subtraction
  163. if 1>0 %(handles.leakSubtraction==0)
  164. iDataPlot=iData(:,i);
  165. else
  166. iDataPlot=iData(:,i)-mean(iData(38000:40000,i));
  167. end
  168. iDataPlot=movmean(iDataPlot,20);
  169. plot(handles.axes1,handles.mSconversion*time(:,1),iDataPlot);
  170. xlabel(handles.axes1,'Time (ms)');
  171. ylabel(handles.axes1,'Current (uA)');
  172. axis(handles.axes1,[handles.xMin handles.xMax handles.yMinI handles.yMaxI]);
  173. hold(handles.axes1,'on');
  174. plot(handles.axes2,handles.mSconversion*time(:,1),vData(:,i));
  175. xlabel(handles.axes2,'Time (ms)');
  176. ylabel(handles.axes2,'Voltage (mV)');
  177. axis(handles.axes2,[handles.xMin handles.xMax handles.yMinV handles.yMaxV]);
  178. hold(handles.axes2,'on');
  179. disp(['Clamped ', num2str(stimulus1Voltage),' mV']);
  180. testPuls=testPuls+10;
  181. i=i+1;
  182. end
  183. handles.type='fast';
  184. handles.iData=iData;
  185. handles.vData=vData;
  186. handles.time=time;
  187. guidata(hObject, handles);
  188. % --- Executes on button press in slowkinetics.
  189. function slowkinetics_Callback(hObject, eventdata, handles)
  190. % hObject handle to slowkinetics (see GCBO)
  191. % eventdata reserved - to be defined in a future version of MATLAB
  192. % handles structure with handles and user data (see GUIDATA)
  193. % hObject handle to actFastInact (see GCBO)
  194. % eventdata reserved - to be defined in a future version of MATLAB
  195. % handles structure with handles and user data (see GUIDATA)
  196. hold(handles.axes1,'off');
  197. hold(handles.axes2,'off');
  198. preStimulusTime=100; %ms
  199. stimulus1Time=10000; %mS
  200. stimulus2Time=100; %mS
  201. stimulus3Time=200; %mS
  202. postStimulusTime=100; %mS
  203. holdingVoltage=-120;
  204. testPulsStart=-120;
  205. testPulsEnd=-20;
  206. sleepTime=10; %Seconds
  207. samplesToAcquire=(preStimulusTime+stimulus1Time+stimulus2Time+stimulus3Time+postStimulusTime)*handles.msToSamples;
  208. nrOfSweeps=(testPulsStart-(testPulsEnd))/-10+1;
  209. iData=zeros(samplesToAcquire,nrOfSweeps);
  210. vData=zeros(samplesToAcquire,nrOfSweeps);
  211. time=zeros(samplesToAcquire,nrOfSweeps);
  212. testPuls=testPulsStart;
  213. i=1;
  214. while testPuls<=testPulsEnd% used to be 10 steps
  215. if i>1
  216. pause(sleepTime);
  217. end
  218. preStimulusVoltage=holdingVoltage; %mV %Used to be minus 120
  219. preStimulus=preStimulusVoltage*ones(preStimulusTime*handles.msToSamples,1);
  220. stimulus1Voltage=testPuls; %mV %Used to be minus 140 * 10
  221. stimulus1=stimulus1Voltage*ones(stimulus1Time*handles.msToSamples,1);
  222. stimulus2Voltage=holdingVoltage; %mV %Used to be minus 120
  223. stimulus2=stimulus2Voltage*ones(stimulus2Time*handles.msToSamples,1);
  224. stimulus3Voltage=0; %mV
  225. stimulus3=stimulus3Voltage*ones(stimulus3Time*handles.msToSamples,1);
  226. postStimulusVoltage=holdingVoltage; %mV
  227. postStimulus=postStimulusVoltage*ones(postStimulusTime*handles.msToSamples,1);
  228. line0=vertcat(preStimulus,stimulus1,stimulus2,stimulus3,postStimulus);
  229. queueOutputData(handles.daqSession,line0*(handles.scaleFactorV/handles.mVconversion));
  230. [inputData,time(:,i),triggerTime] = handles.daqSession.startForeground();
  231. iData(:,i)=(1/handles.scaleFactorI)*inputData(:,1); %data in uA
  232. vData(:,i)=(handles.mVconversion/handles.scaleFactorV)*inputData(:,2); %data in mV
  233. %Leak subtraction
  234. if 1<0%(handles.leakSubtraction==0)
  235. iDataPlot=iData(:,i);
  236. else
  237. iDataPlot=iData(:,i)-max(iData((preStimulusTime+stimulus1Time+stimulus2Time+0.5*stimulus3Time:preStimulusTime+stimulus1Time+stimulus2Time+stimulus3Time)*handles.msToSamples,i));
  238. end
  239. iDataPlot=movmean(iDataPlot,20);
  240. plot(handles.axes1,handles.mSconversion*time(:,1),iDataPlot);
  241. xlabel(handles.axes1,'Time (ms)');
  242. ylabel(handles.axes1,'Current (uA)');
  243. axis(handles.axes1,[handles.xMin handles.xMax handles.yMinI handles.yMaxI]);
  244. hold(handles.axes1,'on');
  245. plot(handles.axes2,handles.mSconversion*time(:,1),vData(:,i));
  246. xlabel(handles.axes2,'Time (ms)');
  247. ylabel(handles.axes2,'Voltage (mV)');
  248. axis(handles.axes2,[handles.xMin handles.xMax handles.yMinV handles.yMaxV]);
  249. hold(handles.axes2,'on');
  250. disp(['Clamped ', num2str(stimulus1Voltage),' mV']);
  251. testPuls=testPuls+10;
  252. i=i+1;
  253. end
  254. handles.type='slow';
  255. handles.iData=iData;
  256. handles.vData=vData;
  257. handles.time=time;
  258. guidata(hObject, handles);
  259. % --- Executes on button press in resurgent.
  260. function resurgent_Callback(hObject, eventdata, handles)
  261. % hObject handle to resurgent (see GCBO)
  262. % eventdata reserved - to be defined in a future version of MATLAB
  263. % handles structure with handles and user data (see GUIDATA)
  264. hold(handles.axes1,'off');
  265. hold(handles.axes2,'off');
  266. preStimulusTime=100; %ms
  267. stimulus1Time=20; %ms
  268. stimulus2Time=500; %mS
  269. postStimulusTime=100; %mS
  270. samplesToAcquire=(preStimulusTime+stimulus1Time+stimulus2Time+postStimulusTime)*handles.msToSamples;
  271. iData=zeros(samplesToAcquire,11);
  272. vData=zeros(samplesToAcquire,11);
  273. time=zeros(samplesToAcquire,11);
  274. for i=1:1%11
  275. preStimulusVoltage=-100; %mV
  276. preStimulus=preStimulusVoltage*ones(preStimulusTime*handles.msToSamples,1);
  277. stimulus1Voltage=30; %mV
  278. stimulus1=stimulus1Voltage*ones(stimulus1Time*handles.msToSamples,1);
  279. stimulus2Voltage=-80+(i-1)*10; %mV
  280. stimulus2=stimulus2Voltage*ones(stimulus2Time*handles.msToSamples,1);
  281. postStimulusVoltage=-100; %mV
  282. postStimulus=postStimulusVoltage*ones(postStimulusTime*handles.msToSamples,1);
  283. line0=vertcat(preStimulus,stimulus1,stimulus2,postStimulus);
  284. queueOutputData(handles.daqSession,line0*(handles.scaleFactorV/handles.mVconversion));
  285. [inputData,time(:,i),triggerTime] = handles.daqSession.startForeground();
  286. iData(:,i)=(1/handles.scaleFactorI)*inputData(:,1); %data in uA
  287. vData(:,i)=(handles.mVconversion/handles.scaleFactorV)*inputData(:,2); %data in mV
  288. %Leak subtraction
  289. if(handles.leakSubtraction==0)
  290. iDataPlot=iData(:,i);
  291. else
  292. iDataPlot=iData(:,i)-mean(iData(500*handles.msToSamples:600*handles.msToSamples,i));
  293. end
  294. iDataPlot=movmean(iDataPlot,200);
  295. plot(handles.axes1,handles.mSconversion*time(:,1),iDataPlot);
  296. xlabel(handles.axes1,'Time (ms)');
  297. ylabel(handles.axes1,'Current (uA)');
  298. axis(handles.axes1,[handles.xMin handles.xMax handles.yMinI handles.yMaxI]);
  299. hold(handles.axes1,'on');
  300. plot(handles.axes2,handles.mSconversion*time(:,1),vData(:,i));
  301. xlabel(handles.axes2,'Time (ms)');
  302. ylabel(handles.axes2,'Voltage (mV)');
  303. axis(handles.axes2,[handles.xMin handles.xMax handles.yMinV handles.yMaxV]);
  304. hold(handles.axes2,'on');
  305. disp(['Clamped ', num2str(stimulus2Voltage),' mV']);
  306. pause(2.5);
  307. end
  308. handles.type='resurgent';
  309. handles.iData=iData;
  310. handles.vData=vData;
  311. handles.time=time;
  312. guidata(hObject, handles);
  313. % --- Executes on button press in pushbutton2.
  314. function pushbutton2_Callback(hObject, eventdata, handles)
  315. % hObject handle to pushbutton2 (see GCBO)
  316. % eventdata reserved - to be defined in a future version of MATLAB
  317. % handles structure with handles and user data (see GUIDATA)
  318. % Run Session & Acquire Data
  319. %line0=vertcat(ones(handles.daqSession.Rate*1,1), ones(handles.daqSession.Rate*0,1));
  320. handles.vHold = str2double(get(handles.edit1,'String'));
  321. line0=handles.vHold*ones(handles.daqSession.Rate,1);
  322. %vHold = str2double(get(handles.edit1,'String'));
  323. %line0=vHold*ones(handles.daqSession.Rate,1);
  324. queueOutputData(handles.daqSession,line0*(handles.scaleFactorV/handles.mVconversion));
  325. [data,time,triggerTime] = handles.daqSession.startForeground();
  326. guidata(hObject, handles);
  327. % --- Executes on button press in save.
  328. function save_Callback(hObject, eventdata, handles)
  329. % hObject handle to save (see GCBO)
  330. % eventdata reserved - to be defined in a future version of MATLAB
  331. % handles structure with handles and user data (see GUIDATA)
  332. %'iData','vData','time',
  333. iData=handles.iData;
  334. vData=handles.vData;
  335. time=handles.time;
  336. newCell=handles.newCell;
  337. human=handles.human;
  338. neandertal=handles.neandertal;
  339. %type=handles.type;
  340. temp=str2double(get(handles.temp,'String'));
  341. conc=str2double(get(handles.conc,'String'));
  342. days=str2double(get(handles.days,'String'));
  343. fileNr=length(dir('*.mat'))+1;
  344. if newCell==1
  345. str='_newcell';
  346. else
  347. str='';
  348. end
  349. if human==1
  350. save(strcat(date,'_',num2str(fileNr),'_human',str),'human','neandertal','iData','vData','time','days','conc','temp');
  351. disp('Data saved.')
  352. elseif neandertal==1
  353. save(strcat(date,'_',num2str(fileNr),'_neandertal_M932L',str),'human','neandertal','iData','vData','time','days','conc','temp');
  354. disp('Data saved.')
  355. else
  356. disp('No species set. Data could not be saved.')
  357. end
  358. % --- Executes on button press in newcell.
  359. function newcell_Callback(hObject, eventdata, handles)
  360. % hObject handle to newcell (see GCBO)
  361. % eventdata reserved - to be defined in a future version of MATLAB
  362. % handles structure with handles and user data (see GUIDATA)
  363. if (get(hObject,'Value') == get(hObject,'Max'))
  364. handles.newCell=1;
  365. else
  366. handles.newCell=0;
  367. end
  368. % Update handles structure
  369. guidata(hObject, handles);
  370. % --- Executes on button press in pushbutton3.
  371. function pushbutton3_Callback(hObject, eventdata, handles)
  372. % hObject handle to pushbutton3 (see GCBO)
  373. % eventdata reserved - to be defined in a future version of MATLAB
  374. % handles structure with handles and user data (see GUIDATA)
  375. [handles.FileName,handles.PathName] = uiputfile('*.mat','Save data to');
  376. % Update handles structure
  377. guidata(hObject, handles);
  378. function edit1_Callback(hObject, eventdata, handles)
  379. % hObject handle to edit1 (see GCBO)
  380. % eventdata reserved - to be defined in a future version of MATLAB
  381. % handles structure with handles and user data (see GUIDATA)
  382. % Hints: get(hObject,'String') returns contents of edit1 as text
  383. % str2double(get(hObject,'String')) returns contents of edit1 as a double
  384. % --- Executes during object creation, after setting all properties.
  385. function edit1_CreateFcn(hObject, eventdata, handles)
  386. % hObject handle to edit1 (see GCBO)
  387. % eventdata reserved - to be defined in a future version of MATLAB
  388. % handles empty - handles not created until after all CreateFcns called
  389. % Hint: edit controls usually have a white background on Windows.
  390. % See ISPC and COMPUTER.
  391. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  392. set(hObject,'BackgroundColor','white');
  393. end
  394. function xminset_Callback(hObject, eventdata, handles)
  395. % hObject handle to xminset (see GCBO)
  396. % eventdata reserved - to be defined in a future version of MATLAB
  397. % handles structure with handles and user data (see GUIDATA)
  398. % Hints: get(hObject,'String') returns contents of xminset as text
  399. % str2double(get(hObject,'String')) returns contents of xminset as a double
  400. % --- Executes during object creation, after setting all properties.
  401. function xminset_CreateFcn(hObject, eventdata, handles)
  402. % hObject handle to xminset (see GCBO)
  403. % eventdata reserved - to be defined in a future version of MATLAB
  404. % handles empty - handles not created until after all CreateFcns called
  405. % Hint: edit controls usually have a white background on Windows.
  406. % See ISPC and COMPUTER.
  407. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  408. set(hObject,'BackgroundColor','white');
  409. end
  410. % --- Executes on button press in setaxes.
  411. function setaxes_Callback(hObject, eventdata, handles)
  412. % hObject handle to setaxes (see GCBO)
  413. % eventdata reserved - to be defined in a future version of MATLAB
  414. % handles structure with handles and user data (see GUIDATA)
  415. axis(handles.axes1,[str2double(get(handles.xminset,'String')) str2double(get(handles.xmaxset,'String')) str2double(get(handles.yminset,'String')) str2double(get(handles.ymaxset,'String'))]);
  416. handles.xMin = str2double(get(handles.xminset,'String'));
  417. handles.xMax = str2double(get(handles.xmaxset,'String'));
  418. handles.yMinI = str2double(get(handles.yminset,'String'));
  419. handles.yMaxI = str2double(get(handles.ymaxset,'String'));
  420. handles.yMinV = -120;
  421. handles.yMaxV = 80;
  422. guidata(hObject, handles);
  423. function xmaxset_Callback(hObject, eventdata, handles)
  424. % hObject handle to xmaxset (see GCBO)
  425. % eventdata reserved - to be defined in a future version of MATLAB
  426. % handles structure with handles and user data (see GUIDATA)
  427. % Hints: get(hObject,'String') returns contents of xmaxset as text
  428. % str2double(get(hObject,'String')) returns contents of xmaxset as a double
  429. % --- Executes during object creation, after setting all properties.
  430. function xmaxset_CreateFcn(hObject, eventdata, handles)
  431. % hObject handle to xmaxset (see GCBO)
  432. % eventdata reserved - to be defined in a future version of MATLAB
  433. % handles empty - handles not created until after all CreateFcns called
  434. % Hint: edit controls usually have a white background on Windows.
  435. % See ISPC and COMPUTER.
  436. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  437. set(hObject,'BackgroundColor','white');
  438. end
  439. function yminset_Callback(hObject, eventdata, handles)
  440. % hObject handle to yminset (see GCBO)
  441. % eventdata reserved - to be defined in a future version of MATLAB
  442. % handles structure with handles and user data (see GUIDATA)
  443. % Hints: get(hObject,'String') returns contents of yminset as text
  444. % str2double(get(hObject,'String')) returns contents of yminset as a double
  445. % --- Executes during object creation, after setting all properties.
  446. function yminset_CreateFcn(hObject, eventdata, handles)
  447. % hObject handle to yminset (see GCBO)
  448. % eventdata reserved - to be defined in a future version of MATLAB
  449. % handles empty - handles not created until after all CreateFcns called
  450. % Hint: edit controls usually have a white background on Windows.
  451. % See ISPC and COMPUTER.
  452. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  453. set(hObject,'BackgroundColor','white');
  454. end
  455. function ymaxset_Callback(hObject, eventdata, handles)
  456. % hObject handle to ymaxset (see GCBO)
  457. % eventdata reserved - to be defined in a future version of MATLAB
  458. % handles structure with handles and user data (see GUIDATA)
  459. % Hints: get(hObject,'String') returns contents of ymaxset as text
  460. % str2double(get(hObject,'String')) returns contents of ymaxset as a double
  461. % --- Executes during object creation, after setting all properties.
  462. function ymaxset_CreateFcn(hObject, eventdata, handles)
  463. % hObject handle to ymaxset (see GCBO)
  464. % eventdata reserved - to be defined in a future version of MATLAB
  465. % handles empty - handles not created until after all CreateFcns called
  466. % Hint: edit controls usually have a white background on Windows.
  467. % See ISPC and COMPUTER.
  468. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  469. set(hObject,'BackgroundColor','white');
  470. end
  471. function checkbox5_Callback(hObject, eventdata, handles)
  472. % hObject handle to save (see GCBO)
  473. % eventdata reserved - to be defined in a future version of MATLAB
  474. % handles structure with handles and user data (see GUIDATA)
  475. % Hint: get(hObject,'Value') returns toggle state of save
  476. if (get(hObject,'Value') == get(hObject,'Max'))
  477. handles.leakSubtraction=1;
  478. else
  479. handles.leakSubtraction=0;
  480. end
  481. % Update handles structure
  482. guidata(hObject, handles);
  483. % --- Executes on button press in pushbutton9.
  484. function pushbutton9_Callback(hObject, eventdata, handles)
  485. % hObject handle to pushbutton9 (see GCBO)
  486. % eventdata reserved - to be defined in a future version of MATLAB
  487. % handles structure with handles and user data (see GUIDATA)
  488. handles.sweep=9999;
  489. %Update handles structure
  490. guidata(hObject, handles);
  491. % --- Executes on button press in human.
  492. function human_Callback(hObject, eventdata, handles)
  493. % hObject handle to human (see GCBO)
  494. % eventdata reserved - to be defined in a future version of MATLAB
  495. % handles structure with handles and user data (see GUIDATA)
  496. if (get(hObject,'Value') == get(hObject,'Max'))
  497. handles.human=1;
  498. else
  499. handles.human=0;
  500. end
  501. % Update handles structure
  502. guidata(hObject, handles);
  503. % --- Executes on button press in neandertal.
  504. function neandertal_Callback(hObject, eventdata, handles)
  505. % hObject handle to neandertal (see GCBO)
  506. % eventdata reserved - to be defined in a future version of MATLAB
  507. % handles structure with handles and user data (see GUIDATA)
  508. if (get(hObject,'Value') == get(hObject,'Max'))
  509. handles.neandertal=1;
  510. else
  511. handles.neandertal=0;
  512. end
  513. % Update handles structure
  514. guidata(hObject, handles);
  515. function days_Callback(hObject, eventdata, handles)
  516. % hObject handle to days (see GCBO)
  517. % eventdata reserved - to be defined in a future version of MATLAB
  518. % handles structure with handles and user data (see GUIDATA)
  519. % Hints: get(hObject,'String') returns contents of days as text
  520. % str2double(get(hObject,'String')) returns contents of days as a double
  521. % --- Executes during object creation, after setting all properties.
  522. function days_CreateFcn(hObject, eventdata, handles)
  523. % hObject handle to days (see GCBO)
  524. % eventdata reserved - to be defined in a future version of MATLAB
  525. % handles empty - handles not created until after all CreateFcns called
  526. % Hint: edit controls usually have a white background on Windows.
  527. % See ISPC and COMPUTER.
  528. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  529. set(hObject,'BackgroundColor','white');
  530. end
  531. function conc_Callback(hObject, eventdata, handles)
  532. % hObject handle to conc (see GCBO)
  533. % eventdata reserved - to be defined in a future version of MATLAB
  534. % handles structure with handles and user data (see GUIDATA)
  535. % Hints: get(hObject,'String') returns contents of conc as text
  536. % str2double(get(hObject,'String')) returns contents of conc as a double
  537. % --- Executes during object creation, after setting all properties.
  538. function conc_CreateFcn(hObject, eventdata, handles)
  539. % hObject handle to conc (see GCBO)
  540. % eventdata reserved - to be defined in a future version of MATLAB
  541. % handles empty - handles not created until after all CreateFcns called
  542. % Hint: edit controls usually have a white background on Windows.
  543. % See ISPC and COMPUTER.
  544. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  545. set(hObject,'BackgroundColor','white');
  546. end
  547. function temp_Callback(hObject, eventdata, handles)
  548. % hObject handle to temp (see GCBO)
  549. % eventdata reserved - to be defined in a future version of MATLAB
  550. % handles structure with handles and user data (see GUIDATA)
  551. % Hints: get(hObject,'String') returns contents of temp as text
  552. % str2double(get(hObject,'String')) returns contents of temp as a double
  553. % --- Executes during object creation, after setting all properties.
  554. function temp_CreateFcn(hObject, eventdata, handles)
  555. % hObject handle to temp (see GCBO)
  556. % eventdata reserved - to be defined in a future version of MATLAB
  557. % handles empty - handles not created until after all CreateFcns called
  558. % Hint: edit controls usually have a white background on Windows.
  559. % See ISPC and COMPUTER.
  560. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  561. set(hObject,'BackgroundColor','white');
  562. end
  563. % --- Executes on button press in checkbox9.
  564. function checkbox9_Callback(hObject, eventdata, handles)
  565. % hObject handle to checkbox9 (see GCBO)
  566. % eventdata reserved - to be defined in a future version of MATLAB
  567. % handles structure with handles and user data (see GUIDATA)
  568. % Hint: get(hObject,'Value') returns toggle state of checkbox9
  569. % --- Executes on button press in pushbutton14.
  570. function pushbutton14_Callback(hObject, eventdata, handles)
  571. % hObject handle to pushbutton14 (see GCBO)
  572. % eventdata reserved - to be defined in a future version of MATLAB
  573. % handles structure with handles and user data (see GUIDATA)
  574. preStimulusTime=100; %ms
  575. stimulus1Time=100; %ms
  576. postStimulusTime=100; %mS
  577. samplesToAcquire=(preStimulusTime+stimulus1Time+postStimulusTime)*handles.msToSamples;
  578. nrOfSweeps=1;
  579. iData=zeros(samplesToAcquire,nrOfSweeps);
  580. vData=zeros(samplesToAcquire,nrOfSweeps);
  581. time=zeros(samplesToAcquire,nrOfSweeps);
  582. for i=1:nrOfSweeps
  583. preStimulusVoltage=handles.vHold; %mV
  584. preStimulus=preStimulusVoltage*ones(preStimulusTime*handles.msToSamples,1);
  585. stimulus1Voltage=handles.vHold+10; %mV
  586. stimulus1=stimulus1Voltage*ones(stimulus1Time*handles.msToSamples,1);
  587. postStimulusVoltage=handles.vHold; %mV
  588. postStimulus=postStimulusVoltage*ones(postStimulusTime*handles.msToSamples,1);
  589. line0=vertcat(preStimulus,stimulus1,postStimulus);
  590. queueOutputData(handles.daqSession,line0*(handles.scaleFactorV/handles.mVconversion));
  591. [inputData,time(:,i),triggerTime] = handles.daqSession.startForeground();
  592. iData(:,i)=(1/handles.scaleFactorI)*inputData(:,1); %data in uA
  593. vData(:,i)=(handles.mVconversion/handles.scaleFactorV)*inputData(:,2); %data in mV
  594. end
  595. disp(['Membrane resistance is ', num2str(0.01/(mean(iData(150*handles.msToSamples:200*handles.msToSamples,1))-mean(iData(1*handles.msToSamples:50*handles.msToSamples,1)))),' MOhm at ', num2str(handles.vHold), 'mV' ]);
  596. % --- Executes on button press in pushbutton15.
  597. function pushbutton15_Callback(hObject, eventdata, handles)
  598. % hObject handle to pushbutton15 (see GCBO)
  599. % eventdata reserved - to be defined in a future version of MATLAB
  600. % handles structure with handles and user data (see GUIDATA)
  601. handles.btnStop=1;
  602. guidata(hObject, handles);