Skip to content

Commit 2abe741

Browse files
committed
Added representative traces for simulation channel distance figure, edited nonStatNoiseAnalysis to output individual sweeps
1 parent bac82de commit 2abe741

7 files changed

Lines changed: 172 additions & 144 deletions

File tree

Analysis/SK/AnnotatedScripts/AntVsPost_VoltageAttenuation_180803.m

Lines changed: 15 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
sortSweeps = {'magnitude','magnitude','magnitude','magnitude'};
6868

69-
anteriorMRCs = IdAnalysis(ephysData,protList,anteriorDistCells,'num','matchType',matchType, ...
69+
[anteriorMRCs, antStim] = IdAnalysis(ephysData,protList,anteriorDistCells,'num','matchType',matchType, ...
7070
'tauType','thalfmax', 'sortSweepsBy', sortSweeps, 'integrateCurrent',1 , ...
7171
'recParameters', ephysMetaData,'sepByStimDistance',1);
7272

@@ -339,7 +339,7 @@
339339
xlswrite(fname,postNorm,'postNorm','A2');
340340

341341

342-
%% Plot representative traces for spatial figure
342+
%% Plot representative traces for spatial dynamics figure
343343

344344
% check distance and nReps for each recording
345345
antDists = cell2mat(cellfun(@(x) mean(x(:,12:13)),anteriorMRCs(:,3),'un',0));
@@ -359,126 +359,17 @@
359359

360360
plotfixer
361361

362+
%% Separate and write representative traces for channel-sim-distance figure
363+
364+
% anterior trace FAT 105 at 1, 5, 10um mean traces separated by on/off
365+
% stimulus, from [stimStart-250, stimEnd+250]ms.
366+
onStim = 751;
367+
offStim = 2251;
368+
sf = 5; %kHz
369+
boxTime = 150*sf; %ms
370+
tVec = (-150*sf:150*sf)'/sf/1000; %s
371+
372+
reps(:,1:3) = anteriorMRCs{4,2}([2 5 9],onStim-boxTime:onStim+boxTime)';
373+
reps(:,4:6) = anteriorMRCs{4,2}([2 5 9],offStim-boxTime:offStim+boxTime)';
374+
362375

363-
%% Old code
364-
365-
% %% Pull out and combine relevant data for plotting single size
366-
%
367-
% % Voltage attenuation data comes from the length constant fitting done in
368-
% % Igor, which gives a voltage attenuation factor at the location of the
369-
% % stimulus site for each recording, based on the calculated length
370-
% % constant.
371-
%
372-
% % Grab the current at the selected step size (e.g., 10um) for each
373-
% % recording, grab the cell-stimulus distance for that recording, and match
374-
% % the recording name against the voltage attenuation table to find the
375-
% % attenuation factor for that recording.
376-
% whichMRCs = anteriorMRCs;
377-
% thisAtt = attenuationData(:,[2 8 10]);
378-
% distCol = 12;
379-
% peakCol = 6; % 6 for peak current, 11 for integrated current/charge
380-
% distVPeak = [];
381-
% stepSize = 10;
382-
%
383-
% for iCell = 1:size(whichMRCs,1)
384-
% thisCell = whichMRCs{iCell,3};
385-
% whichStep = round(thisCell(:,1)) == stepSize;
386-
% if any(whichStep)
387-
% thisName = whichMRCs{iCell,1};
388-
% hasAtt = strcmp(thisName,thisAtt(:,1));
389-
%
390-
% if any(hasAtt) && thisAtt{hasAtt,2}
391-
% distVPeak(iCell,:) = [thisCell(whichStep,[distCol peakCol]) thisAtt{hasAtt,3}];
392-
% else
393-
% distVPeak(iCell,:) = [thisCell(whichStep,[distCol peakCol]) nan];
394-
% end
395-
%
396-
% end
397-
%
398-
% end
399-
%
400-
% distVPeak_Ant = distVPeak;
401-
%
402-
% whichMRCs = posteriorMRCs;
403-
% distVPeak = [];
404-
%
405-
%
406-
% for iCell = 1:size(whichMRCs,1)
407-
% thisCell = whichMRCs{iCell,3};
408-
% whichStep = round(thisCell(:,1)) == stepSize;
409-
% if any(whichStep)
410-
% thisName = whichMRCs{iCell,1};
411-
% hasAtt = strcmp(thisName,thisAtt(:,1));
412-
%
413-
% if any(hasAtt)
414-
% distVPeak(iCell,:) = [thisCell(whichStep,[distCol peakCol]) thisAtt{hasAtt,2}];
415-
% else
416-
% distVPeak(iCell,:) = [thisCell(whichStep,[distCol peakCol]) nan];
417-
% end
418-
%
419-
% end
420-
%
421-
% end
422-
%
423-
% distVPeak_Post = distVPeak;
424-
%
425-
% clear a iCell thisCell whichMRCs whichStep thisName hasAtt distVPeak
426-
%
427-
% %% Make correction to I for space clamp error
428-
% % (Note: this is an approximation, assuming that the majority of the
429-
% % current is happening at the stimulus site, which we know is not entirely
430-
% % true, and channels at different points along the neurite will experience
431-
% % different voltages.
432-
%
433-
% % Now calculate what the actual voltage was at the stimulus site based on
434-
% % the voltage attenuation factor. In this case, command voltage was -60mV
435-
% % for all steps.
436-
%
437-
% % attenuation factor = Vm'/Vc so Vm' = Vc * attenuation factor
438-
%
439-
% % Then calculate what current would've been based on sodium reversal
440-
% % potential.
441-
% % For IC2 solution used here, Ena = +94mV.
442-
%
443-
% % Im' = Im * ((Vc-Ena)/(Vm'-Ena))
444-
%
445-
% Vc = -0.06; %in V
446-
% Ena = 0.094; % in V
447-
% Im = distVPeak_Ant(:,2);
448-
% Vatt = distVPeak_Ant(:,3);
449-
%
450-
% Vm = Vc * Vatt;
451-
% distVPeak_Ant(:,4) = (Im * (Vc-Ena)) ./ (Vm-Ena);
452-
%
453-
% %% Plot anterior and posterior single size on separate plots
454-
%
455-
% figure(); axh(1) = subplot(2,1,1);
456-
% scatter(distVPeak_Ant(:,1),distVPeak_Ant(:,4));
457-
% xlabel('Distance from cell body (um)');
458-
% ylabel(sprintf('Current @%dum (pA)',stepSize))
459-
% text(100,200,'Anterior');
460-
% axh(2) = subplot(2,1,2);
461-
% scatter(distVPeak_Post(:,1),distVPeak_Post(:,2));
462-
% xlabel('Distance from cell body (um)');
463-
% ylabel(sprintf('Current @%dum (pA)',stepSize))
464-
% text(100,200,'Posterior');
465-
%
466-
% for i = 1:length(axh)
467-
% xlim(axh(i),[0 200]);
468-
% ylim(axh(i),[0 200]);
469-
% end
470-
%
471-
% %% Plot on one plot
472-
%
473-
% figure();
474-
% scatter(distVPeak_Ant(:,1),distVPeak_Ant(:,4));
475-
% hold on;
476-
% scatter(-distVPeak_Post(:,1),distVPeak_Post(:,2));
477-
% text(distVPeak_Ant(:,1)+1,distVPeak_Ant(:,4)+1,anteriorMRCs(:,1));
478-
% text(-distVPeak_Post(:,1)+1,distVPeak_Post(:,2)+1,posteriorMRCs(:,1));
479-
% xlabel('Distance from cell body (um)');
480-
% ylabel(sprintf('Current @%dum (pA)',stepSize))
481-
% xlim([-100 200]);ylim([0 200]);
482-
% vline(0,'k:');
483-
%
484-
%

Analysis/SK/AnnotatedScripts/Velocity_VoltageAtt_180913.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,25 @@
180180
linkaxes(axh,'y');
181181
plotfixer;
182182

183+
%% Separate and write representative traces for channel-sim-distance figure
184+
185+
% FAT218 mean traces at 106um/s, 320, 3790 separated by on/off
186+
% stimulus, from [stimStart-250, stimEnd+250]ms.
187+
onStimStart = 1503; onStimEnd = 2250;
188+
offStimStart = [5253; 4752; 4521]; offStimEnd = offStimStart + 747;
189+
sf = 10; %kHz
190+
boxTime = 150*sf; %ms
191+
onBox = [onStimStart-boxTime onStimEnd+boxTime];
192+
offBox = [offStimStart-boxTime offStimEnd+boxTime];
193+
194+
195+
reps(:,1:3) = velocityMRCs{4,2}([3 4 8],onBox(1):onBox(2))';
196+
reps(:,4) = velocityMRCs{4,2}(3,offBox(1,1):offBox(1,2))';
197+
reps(:,5) = velocityMRCs{4,2}(4,offBox(2,1):offBox(2,2))';
198+
reps(:,6) = velocityMRCs{4,2}(8,offBox(3,1):offBox(3,2))';
199+
200+
tVec = ((1:length(reps))-boxTime-1)'./(sf*1000);
201+
183202
%% Pull out and combine data to plot one particular velocity vs. distance
184203

185204
% Voltage attenuation data comes from the length constant fitting done in

Analysis/SK/Scripts-in-progress/NonStatNoiseAnalysis.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
nonStatOutput.(cellName)(whichRow).sweepsPerWindow = averagingWindow;
237237
nonStatOutput.(cellName)(whichRow).totalMean = totalMean;
238238
nonStatOutput.(cellName)(whichRow).totalVar = totalVar;
239+
nonStatOutput.(cellName)(whichRow).traces = leakSubtract(responseTime,:);
239240
nonStatOutput.(cellName)(whichRow).distance = thisDist;
240241

241242

Analysis/SK/Scripts-in-progress/PreIndentNoiseAnalysis.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
strainList = {'TU2769'};
55
internalList = {'IC6'};
6-
stimPosition = {'anterior'};
6+
stimPosition = {'posterior'};
77

88
wormPrep = {'dissected'};
99
cellDist = [40 100];
@@ -20,6 +20,7 @@
2020

2121
%% Exclusion
2222
protList ={'NoisePre','WC_Probe8','WC_Probe4','WC_Probe3','WC_Probe12'};
23+
% protList ={'WC_Probe8','WC_Probe4','WC_Probe3','WC_Probe12'};
2324

2425
matchType = 'first';
2526

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
% calculate
2+
3+
% theseCells = {'FAT186','FAT190','FAT241'};
4+
% protList ={'WC_Probe';'NoPre'};
5+
protList ={'NoPre'};
6+
% protList ={'WC_Probe'};
7+
matchType = 'first';
8+
sortSweeps = {'magnitude','magnitude','magnitude','magnitude'};
9+
10+
% use allSteps(190124).xls
11+
[postSweeps, postStim] = IdAnalysis(ephysData,protList,posteriorDistCells,'num','matchType',matchType, ...
12+
'tauType','thalfmax', 'sortSweepsBy', sortSweeps, 'integrateCurrent',1 , ...
13+
'recParameters', ephysMetaData,'sepByStimDistance',1,'saveSweeps',1);
14+
15+
clear protList sortSweeps matchType
16+
17+
%% plot
18+
figure('Position',[500 100 800 600]);
19+
stepSize = 10;
20+
21+
for i = 1:size(postSweeps,1)
22+
subplot(2,4,i)
23+
try
24+
plot(postSweeps{i,3}{abs(postSweeps{i,4}(:,1)-stepSize)<0.4}')
25+
catch
26+
continue
27+
end
28+
29+
end
30+
31+
suptitle('Posterior 250ms step');

0 commit comments

Comments
 (0)