-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunPatchAttempt_continuousAcquisition.m
executable file
·114 lines (94 loc) · 3.19 KB
/
runPatchAttempt_continuousAcquisition.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
function pipetteNum = runPatchAttempt_continuousAcquisition(ID, pipetteNum)
% % goals:
% measure and record pipette resistance
% record cell-attached trace?
% measure and record resting potential and seal resistance
%
% need to:
% make sure parameters and conversions are right
% re-figure out the exact workflow
HWsettings = sensor_settings_PP; % to set AO channels consistently
daqreset;
s = daq.createSession('ni');
s.Rate = DAQ_fs;
s.IsContinuous = true;
%%
% start acquisition
parametersValue = questdlg_PPStart;
if parametersValue %record trace for paramersn calculation only
pipetteNum = parametersValue + 1;
fidWrite = fopen(sprintf('parameters_%s_pipette%02d.bin',ID, pipetteNum), 'w+');
ai = s.addAnalogInputChannel(HWsettings.DAQdevName, ...
0:5 , 'Voltage');
for ch = 1:length(ai)
ai(ch).Range = [-10 10];
ai(ch).TerminalConfig = 'SingleEnded';
end
lh_ai = s.addlistener('DataAvailable', @(src, event)logData_2Piezos(src, event, fidWrite));
s.startBackground;
stopValue = questdlg_PPStop; %this should work, but I am not sure. Double-check
s.stop;
fclose(fidWrite);
% now either repeat recursively or record experiment
else %record actual experiment
end
%% record for some time then push a button to stop
% % pause()
% s.stop;
%
%
% fclose(fidWrite);
% for subsequent analysis, take from here
%% test data acquis and pip resist
% %read data in
% fid = fopen(sprintf('sealResistanceData_%s.bin',metadata.key.ID), 'r');
% data = fread(fid, 'double' );
% fclose(fid);
%
% data = reshape(data, length(ai)+1, []);
% timestamps = (data(1,:))';
% data = data(2:end,:);
% data = data'; %for consistency with TO's code
%
% figure; plot(timestamps(1:4001), data( 1:4001, HWsettings.DATAch.VOLTAGE_NON_SCALED_A_DAQ_AI ))
% hold on
%
% figure; hold on
% plot(timestamps(1:4001), scaled(1:4001)); ylabel('scaled, [pA]')
% plot(timestamps(1:4001), current(1:4001));
%
%
%
%
% %% measure pipette resistance
% s.DurationInSeconds = 1;
% [trial_data, trial_time] = s.startForeground();
% [ current, voltage, scaled ] = get_scaled_voltage_and_current_TO( trial_data );
% pipette_resistance = pipetteResistanceCalc( current);
%
% fprintf('pipette resistance is %3.1f MOhm\n',pipette_resistance)
%
%
% %% record access resistance
% % settings.sampRate = 40000; % higher sampling rate for getting the peak
% s.DurationInSeconds = 1.0;
% [trial_data3, trial_time3] = s.startForeground();
% [ current, voltage, scaled ] = get_scaled_voltage_and_current_TO( trial_data3 );
% [R_access, R_membrane] = accessResistanceCalc_TO( current, voltage, trial_time, Ch.sampRate );
% fprintf('access resistance is %3.1f MOhm\n',R_access)
% fprintf('membrane resistance is %3.1f MOhm\n',R_membrane)
%
%
%
% %% record_i_0_resting_voltage %what was this????
% s.DurationInSeconds = 1.0;
% [trial_data2, trial_time2] = s.startForeground();
% [ current, voltage, scaled ] = get_scaled_voltage_and_current_TO( trial_data2 );
% resting_voltage = mean( voltage );
% fprintf('resting voltage is %3.1f MOhm\n', resting_voltage)
%
%
% %%
% daqreset
%
% save(sprintf('parameters_%s.mat',metadata.key.ID), 'pipette_resistance', 'R_access', 'R_membrane', 'resting_voltage')