|
60 | 60 | ExcludeSweeps(ephysData, protList, velocityCells, 'matchType', matchType); |
61 | 61 |
|
62 | 62 | %% Find MRCs |
63 | | -% antAllSteps.xlsx and postAllSteps.xlsx from 180810 |
| 63 | +% antTraps_allFreq(180913).xls |
64 | 64 | protList ={'TrapRate'}; |
65 | 65 | matchType = 'first'; |
66 | 66 |
|
67 | 67 | sortSweeps = {'velocity','velocity','magnitude','magnitude'}; |
68 | 68 |
|
69 | | -velocityMRCs = IdAnalysis(ephysData,protList,velocityCells,'num','matchType',matchType, ... |
| 69 | +[velocityMRCs velocityStim] = IdAnalysis(ephysData,protList,velocityCells,'num','matchType',matchType, ... |
70 | 70 | 'tauType','thalfmax', 'sortSweepsBy', sortSweeps, 'integrateCurrent',1 , ... |
71 | 71 | 'recParameters', ephysMetaData,'sepByStimDistance',1); |
72 | 72 |
|
73 | 73 | clear protList sortSweeps matchType |
74 | 74 |
|
| 75 | +%% Quick plot for looking at asymmetry in slow velocities |
| 76 | +figure(); |
| 77 | +for i = 1:8 |
| 78 | +axh(i) = subtightplot(2,4,i); |
| 79 | +plot(velocityMRCs{i,2}([5 4 3 2 1],:)'); |
| 80 | +cmapline('ax',gca,'colormap','parula'); |
| 81 | +end |
| 82 | +linkaxes(axh,'xy'); |
| 83 | +plotfixer; |
| 84 | + |
| 85 | +%% Get normalized mean traces (normalized to highest velocity) |
| 86 | +% Can then use normVelocityMRCs as input for the final |
| 87 | +normVelocitySweeps = cellfun(@(x,y) x./y(end,6),velocityMRCs(:,2),velocityMRCs(:,3),'un',0); |
| 88 | +normVelocityMRCs = velocityMRCs; |
| 89 | +normVelocityMRCs(:,2) = normVelocitySweeps; |
| 90 | +%% Quick plot for selecting representative traces |
| 91 | +figure(); |
| 92 | +for i = 1:8 |
| 93 | +axh(i) = subtightplot(2,4,i); |
| 94 | +plot(velocityMRCs{i,2}'); |
| 95 | +cmapline('ax',gca,'colormap','parula'); |
| 96 | +end |
| 97 | +linkaxes(axh,'xy'); |
| 98 | + |
| 99 | +%% Plot selected representative traces and stimuli |
| 100 | +% FAT214 with on ramps for 106, 785, 1560, 7230, 39740 um/s |
| 101 | + |
| 102 | +% Grab stimuli based on velocityStim (second output from IdAnalysis) |
| 103 | +% Just example stim from one trace |
| 104 | +% Should this be photodiode trace? (if so don't forget to zero it) |
| 105 | +stimTrace{1} = ephysData.FAT214.data{3,18}(:,2); |
| 106 | +stimTrace{2} = ephysData.FAT214.data{3,11}(:,2); |
| 107 | +stimTrace{3} = ephysData.FAT214.data{3,12}(:,3); |
| 108 | +stimTrace{4} = ephysData.FAT214.data{3,12}(:,4); |
| 109 | +stimTrace{5} = ephysData.FAT214.data{3,11}(:,3); |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | +figure(); |
| 114 | +axh(1)=subplot(2,1,1); |
| 115 | +for i = 1:5 |
| 116 | + plot(stimTrace{i}) |
| 117 | + hold on |
| 118 | +end |
| 119 | +tVec = (1:length(velocityMRCs{1,2}))/10; % time in ms |
| 120 | +plot(tVec,velocityMRCs{1,2}([2 5 6 10 12],:)'); |
| 121 | +cmapline('ax',gca,'colormap','copper'); |
| 122 | +chH = get(gca,'children'); |
| 123 | +set(gca,'children',flipud(chH)); |
| 124 | +plotfixer(); |
| 125 | + |
75 | 126 | %% Pull out and combine relevant data for plot |
76 | 127 |
|
77 | 128 | % Voltage attenuation data comes from the length constant fitting done in |
|
107 | 158 |
|
108 | 159 | end |
109 | 160 |
|
110 | | -distVPeak_Ant = distVPeak; |
| 161 | +distVPeak_On = distVPeak; |
| 162 | + |
| 163 | + |
| 164 | +% Off ramps |
| 165 | + |
| 166 | +distVPeak = []; |
| 167 | + |
| 168 | +for iCell = 1:size(whichMRCs,1) |
| 169 | + thisCell = whichMRCs{iCell,4}; |
| 170 | + whichVel = round(thisCell(:,1)) == -stepVel; |
| 171 | + if any(whichVel) |
| 172 | + thisName = whichMRCs{iCell,1}; |
| 173 | + hasAtt = strcmp(thisName,thisAtt(:,1)); |
| 174 | + |
| 175 | + if any(hasAtt) && thisAtt{hasAtt,2} |
| 176 | + try distVPeak(iCell,:) = [thisCell(whichVel,[distCol peakCol]) thisAtt{hasAtt,3}]; |
| 177 | + catch |
| 178 | + distVPeak(iCell,:) = [mean(thisCell(whichVel,[distCol peakCol]),1) thisAtt{hasAtt,3}]; |
| 179 | + end |
| 180 | + else |
| 181 | + try distVPeak(iCell,:) = [thisCell(whichVel,[distCol peakCol]) nan]; |
| 182 | + catch |
| 183 | + distVPeak(iCell,:) = [mean(thisCell(whichVel,[distCol peakCol]),1) nan]; |
| 184 | + end |
| 185 | + end |
| 186 | + |
| 187 | + end |
| 188 | + |
| 189 | +end |
| 190 | + |
| 191 | +distVPeak_Off = distVPeak; |
111 | 192 |
|
112 | 193 | clear a iCell thisCell whichMRCs whichStep thisName hasAtt distVPeak |
113 | 194 |
|
|
131 | 212 |
|
132 | 213 | Vc = -0.06; %in V |
133 | 214 | Ena = 0.094; % in V |
134 | | -Im = distVPeak_Ant(:,2); |
135 | | -Vatt = distVPeak_Ant(:,3); |
| 215 | +Im = distVPeak_On(:,2); |
| 216 | +Vatt = distVPeak_On(:,3); |
136 | 217 |
|
137 | 218 | Vm = Vc * Vatt; |
138 | | -distVPeak_Ant(:,4) = (Im * (Vc-Ena)) ./ (Vm-Ena); |
| 219 | +distVPeak_On(:,4) = (Im * (Vc-Ena)) ./ (Vm-Ena); |
| 220 | + |
139 | 221 |
|
140 | | -%% Plot anterior and posterior on separate plots |
| 222 | +Im = distVPeak_Off(:,2); |
| 223 | +Vatt = distVPeak_Off(:,3); |
| 224 | + |
| 225 | +Vm = Vc * Vatt; |
| 226 | +distVPeak_Off(:,4) = (Im * (Vc-Ena)) ./ (Vm-Ena); |
141 | 227 |
|
142 | | -figure(); axh(1) = subplot(2,1,1); |
143 | | -scatter(distVPeak_Ant(:,1),distVPeak_Ant(:,4)); |
| 228 | + |
| 229 | +%% Plot on and off currents vs distance |
| 230 | + |
| 231 | +figure(); |
| 232 | +scatter(distVPeak_On(:,1),distVPeak_On(:,4),'b'); |
| 233 | +hold on; |
| 234 | +scatter(distVPeak_Off(:,1),distVPeak_Off(:,4),'r'); |
144 | 235 | xlabel('Distance from cell body (um)'); |
145 | 236 | ylabel(sprintf('Current @%dum (pA)',stepVel)) |
146 | | -text(100,200,'Anterior'); |
| 237 | +xlim(gca,[0 200]); |
| 238 | +ylim(gca,[0 200]); |
| 239 | +legend({'On current','Off current'}); |
147 | 240 |
|
148 | | -for i = 1:length(axh) |
149 | | - xlim(axh(i),[0 200]); |
150 | | - ylim(axh(i),[0 200]); |
151 | | -end |
152 | 241 |
|
153 | 242 | %% Correct all sizes and export for Igor fitting of Boltzmann to each recording |
154 | 243 |
|
155 | 244 | % Set the filename |
156 | | -fname = 'PatchData/attCorrectedVelCurves(180913).xls'; |
| 245 | +fname = 'PatchData/attCorrectedVel_times(181002).xls'; |
| 246 | +noCorr = 0; |
| 247 | + |
| 248 | +for i = 1:2 |
| 249 | +whichRamp = i; % 1 for on currents, 2 for off currents |
| 250 | +normFlag = 0; %normalize to 40mm/s ramp (highest velocity "step") |
| 251 | +peakCol = 9; % 6 for peak current, 11 for integrated current/charge |
| 252 | + % 8 for tauAct, 9 for tauDecay |
| 253 | +switch peakCol |
| 254 | + case 6 |
| 255 | + dType = 'peak'; |
| 256 | + case 11 |
| 257 | + dType = 'charge'; |
| 258 | + case 8 |
| 259 | + dType = 'act'; |
| 260 | + case 9 |
| 261 | + dType = 'decay'; |
| 262 | +end |
| 263 | +distCol = 12; |
157 | 264 |
|
158 | | -allVel = vertcat(velocityMRCs{:,3}); |
| 265 | +allVel = vertcat(velocityMRCs{:,whichRamp+2}); |
159 | 266 | eachVel = uniquetol(allVel(:,1),12,'DataScale',1); |
160 | 267 | % the value of 12 is empirically chosen as being larger than the largest |
161 | 268 | % difference between velocities that could be binned (usually 10 after roundVel) and smaller than the |
|
173 | 280 | vel_Out = cell(length(eachVel)+1,size(whichMRCs,1)); |
174 | 281 |
|
175 | 282 | for iCell = 1:size(whichMRCs,1) |
176 | | - thisCell = whichMRCs{iCell,3}; |
| 283 | + thisCell = whichMRCs{iCell,whichRamp+2}; |
177 | 284 | thisDist = mean(thisCell(:,distCol)); % check if cell distance is in range |
178 | 285 | if thisDist <= distLimits(2) && thisDist >= distLimits(1) |
179 | 286 | thisName{iCell,1} = whichMRCs{iCell,1}; %name |
180 | 287 | thisName{iCell,2} = thisDist; |
181 | | - vel_Out{1,iCell} = thisName{iCell,1}; |
| 288 | + vel_Out{1,iCell} = sprintf('%s_%s_stim%d',thisName{iCell,1},dType,whichRamp); |
182 | 289 | hasAtt = strcmp(thisName{iCell,1},thisAtt(:,1)); |
183 | 290 | Iact = []; |
184 | 291 |
|
185 | 292 | for iVel = 1:length(eachVel) |
186 | 293 | stepVel = eachVel(iVel); |
187 | 294 | whichVel = abs(thisCell(:,1) - stepVel) < 12; %find closest velocity |
188 | 295 | if any(whichVel) |
189 | | - |
190 | 296 | if any(hasAtt) && thisAtt{hasAtt,2} %if attenuation calc exists and not omitCell |
191 | | - Vm = Vc * thisAtt{hasAtt,3}; |
192 | | - Im = thisCell(whichVel,peakCol); |
193 | | - Iact(iVel,1) = (Im * (Vc-Ena)) ./ (Vm-Ena); |
| 297 | + if noCorr == 1 || strcmp(dType,'peak') || strcmp(dType,'charge') %attenuation correction for current/charge but not taus |
| 298 | + Vm = Vc * thisAtt{hasAtt,3}; |
| 299 | + Im = thisCell(whichVel,peakCol); |
| 300 | + if length(Im) > 1 |
| 301 | + %multiple profiles containing this velocity, take mean weighted by nReps |
| 302 | + Im = sum((thisCell(whichVel,peakCol).*thisCell(whichVel,end)))/sum(thisCell(whichVel,end)); |
| 303 | + end |
| 304 | + |
| 305 | + Iact(iVel,1) = (Im * (Vc-Ena)) ./ (Vm-Ena); |
| 306 | + else |
| 307 | + Im = thisCell(whichVel,peakCol); |
| 308 | + if length(Im) > 1 |
| 309 | + %multiple profiles containing this velocity, take mean weighted by nReps |
| 310 | + Im = sum((thisCell(whichVel,peakCol).*thisCell(whichVel,end)))/sum(thisCell(whichVel,end)); |
| 311 | + end |
| 312 | + Iact(iVel,1) = Im; |
| 313 | + end |
194 | 314 | else |
195 | 315 | Iact(iVel,1) = nan; |
196 | 316 | end |
| 317 | + |
197 | 318 |
|
198 | 319 | else |
199 | 320 | Iact(iVel,1) = nan; |
200 | 321 | end |
201 | 322 | end |
| 323 | + |
| 324 | + if whichRamp == 2 |
| 325 | + Iact = flipud(Iact); |
| 326 | + end |
| 327 | + if normFlag |
| 328 | + Iact = Iact./Iact(end); |
| 329 | + end |
202 | 330 | vel_Out(2:length(eachVel)+1,iCell) = num2cell(Iact); |
| 331 | + |
203 | 332 | end |
204 | 333 | end |
205 | | -vel_Name = [{'Anterior', 'Ant_Dist'}; thisName]; |
| 334 | + |
| 335 | +if whichRamp == 2 |
| 336 | + eachVel = flipud(eachVel); |
| 337 | +end |
| 338 | + |
| 339 | +thisName(:,1) = cellfun(@(x) sprintf('%s',x),thisName(:,1),'un',0); |
| 340 | +vel_Name = [{sprintf('Anterior_stim%d',whichRamp), sprintf('Ant_Dist_stim%d',whichRamp)}; thisName]; |
206 | 341 | vel_Out = vel_Out(:,~cellfun(@isempty, vel_Out(1,:))); % clear out empty waves (where dist didn't match) |
207 | 342 | vel_Name = vel_Name(~cellfun(@isempty, vel_Name(:,1)),:); |
208 | 343 |
|
209 | | -vel_Out = [[{'velocity'};num2cell(eachVel)] vel_Out]; % append stepSize wave |
210 | | - |
211 | | -% thisName = cell(0); |
212 | | -% whichMRCs = posteriorMRCs; |
213 | | -% post_Out = cell(length(eachSize)+1,size(whichMRCs,1)); |
214 | | -% |
215 | | -% for iCell = 1:size(whichMRCs,1) |
216 | | -% thisCell = whichMRCs{iCell,3}; |
217 | | -% thisDist = mean(thisCell(:,distCol)); % check if cell distance is in range |
218 | | -% if thisDist <= distLimits(2) && thisDist >= distLimits(1) |
219 | | -% thisName{iCell,1} = whichMRCs{iCell,1}; %name |
220 | | -% thisName{iCell,2} = thisDist; %distance |
221 | | -% post_Out{1,iCell} = thisName{iCell,1}; |
222 | | -% Iact = []; |
223 | | -% |
224 | | -% for iSize = 1:length(eachSize) |
225 | | -% stepVel = eachSize(iSize); |
226 | | -% whichStep = round(thisCell(:,1)*2)/2 == stepVel; %round to nearest 0.5 |
227 | | -% if any(whichStep) |
228 | | -% Iact(iSize,1) = thisCell(whichStep,peakCol); |
229 | | -% else |
230 | | -% Iact(iSize,1) = nan; |
231 | | -% end |
232 | | -% end |
233 | | -% post_Out(2:length(eachSize)+1,iCell) = num2cell(Iact); |
234 | | -% end |
235 | | -% end |
236 | | -% |
237 | | -% post_Name = [{'Posterior', 'Post_Dist'}; thisName]; |
238 | | -% post_Out = post_Out(:,~cellfun(@isempty, post_Out(1,:))); |
239 | | -% post_Name = post_Name(~cellfun(@isempty, post_Name(:,1)),:); |
240 | | - |
241 | | - |
242 | | -xlswrite(fname,vel_Out,'vel'); |
243 | | -xlswrite(fname,vel_Name,'velStats'); |
| 344 | +vel_Out = [[{sprintf('vel_stim%d',whichRamp)};num2cell(eachVel)] vel_Out]; % append stepSize wave |
| 345 | + |
| 346 | + |
| 347 | +xlswrite(fname,vel_Out,sprintf('%s_stim%d',dType,whichRamp)); |
| 348 | +xlswrite(fname,vel_Name,sprintf('%sStats_stim%d',dType,whichRamp)); |
244 | 349 |
|
245 | 350 | clear iCell thisCell Iact whichMRCs whichStep hasAtt thisAtt Vc Ena thisName |
| 351 | +end |
| 352 | + |
| 353 | +%% Calculate ratios |
| 354 | +% re-save vel_Out as on/offVelChrg and on/offVelPeak for the corresponding |
| 355 | +% cases |
| 356 | +on = onVelPeak; |
| 357 | +off = offVelPeak; |
| 358 | +out = on(1,:); |
| 359 | + |
| 360 | +onVel = [on{2:end,1}]; |
| 361 | +offVel = -[off{2:end,1}]; |
| 362 | + |
| 363 | + |
| 364 | +for i = 1:length(onVel) |
| 365 | + whichVel = abs(onVel(i)-offVel)<12; |
| 366 | + if any(whichVel) |
| 367 | + thisVel = find(whichVel); |
| 368 | + out{i+1,1} = offVel(thisVel); |
| 369 | + out(i+1,2:end) = cellfun(@(x,y) x./y, off(thisVel+1,2:end), on(i+1,2:end),'un',0); |
| 370 | + end |
| 371 | +end |
| 372 | + |
| 373 | +out = out(~cellfun(@isempty,out(:,1)),:); |
| 374 | +xlswrite(fname,out,sprintf('velPeak_ratio')); |
246 | 375 |
|
247 | 376 |
|
248 | 377 | %% Renormalize |
|
0 commit comments