|
1 | 1 | % PreIndentIgorExport.m |
2 | 2 |
|
3 | 3 | %% Load data |
4 | | -% load prepulseFatData(180108).mat |
| 4 | +% Load prepulseWT_Recreated(181108).mat |
| 5 | +%(recreated with filtering/selection code at the current date). |
| 6 | + |
| 7 | +% or run this section to re-load the data if ephysData and |
| 8 | +% ephysMetaData are loaded (through FAT158). |
5 | 9 |
|
6 | | -% or run this section to re-load the data given ephysData and |
7 | | -% ephysMetaData. |
8 | 10 | strainList = {'TU2769'}; |
9 | 11 | internalList = {'IC2'}; |
10 | 12 | resistCutoff = '<210'; % Rs < 210 MOhm |
|
14 | 16 |
|
15 | 17 | clear strainList internalList resistCutoff ans; |
16 | 18 |
|
17 | | - |
18 | | - |
19 | | -protList ={'NoPrePulse'}; |
| 19 | +% Find MRCs for prepulse sweeps. |
| 20 | +% Use TracePicks_Preto158_WT_IC2.xls |
| 21 | +protList ={'PrePulse'}; |
20 | 22 | sortSweeps = {'position','position','position','position'}; |
21 | 23 | matchType = 'full'; |
22 | | -wtNoPreMRCs = IdAnalysis(ephysData,protList,wtCells,'num','matchType',matchType, ... |
| 24 | +wtPreMRCs = IdAnalysis(ephysData,protList,wtCells,'num','matchType',matchType, ... |
23 | 25 | 'tauType','thalfmax', 'sortSweepsBy', sortSweeps, 'integrateCurrent',1,... |
24 | 26 | 'sortStimBy','time','recParameters',ephysMetaData); |
25 | 27 |
|
26 | 28 | clear protList sortSweeps matchType |
27 | 29 |
|
28 | | -protList ={'PrePulse'}; |
| 30 | +% Find MRCs for no-prepulse sweeps. |
| 31 | +% Use TracePicks_NoPreto158_WT_IC2.xls |
| 32 | +protList ={'NoPrePulse'}; |
29 | 33 | sortSweeps = {'position','position','position','position'}; |
30 | 34 | matchType = 'full'; |
31 | | -wtPreMRCs = IdAnalysis(ephysData,protList,wtCells,'num','matchType',matchType, ... |
| 35 | +wtNoPreMRCs = IdAnalysis(ephysData,protList,wtCells,'num','matchType',matchType, ... |
32 | 36 | 'tauType','thalfmax', 'sortSweepsBy', sortSweeps, 'integrateCurrent',1,... |
33 | 37 | 'sortStimBy','time','recParameters',ephysMetaData); |
34 | 38 |
|
35 | 39 | clear protList sortSweeps matchType |
36 | 40 |
|
37 | | -%% Export to Igor |
| 41 | +% Exclude FAT116 because the pre-indentation step was 3um, rather than 5um |
| 42 | +% like the rest of the data. |
| 43 | +wtPreMRCs = wtPreMRCs(2:12,:); |
| 44 | + |
| 45 | +%% Collate data for export |
38 | 46 |
|
39 | 47 | % Get traces and associated recording names |
40 | 48 | noPreTraces = vertcat(wtNoPreMRCs{:,2})'; |
|
48 | 56 |
|
49 | 57 |
|
50 | 58 | % Get sizes of on2 step (or just step for noPre), sort by size |
51 | | -preSteps = vertcat(wtPreMRCs{:,4}); |
52 | | -[preStepsSort, preI] = sortrows(preSteps,1); |
53 | | - |
54 | | -preRelSizes = round(preStepsSort(:,1)) - 5; |
55 | | -preAbsSizes = round(preStepsSort(:,1)); |
56 | | -preN = preStepsSort(:,7); |
57 | | -preCellsSort = preCells(preI); |
58 | | -preTracesSort = preTraces(:,preI); |
59 | | - |
60 | | - |
61 | | - |
62 | | -noPreSteps = vertcat(wtNoPreMRCs{:,3}); |
63 | | -[noPreStepsSort, noPreI] = sortrows(noPreSteps,1); |
64 | | - |
65 | | -noPreSizes = round(noPreStepsSort(:,1)); |
66 | | -noPreN = noPreStepsSort(:,7); |
67 | | -noPreCellsSort = noPreCells(noPreI); |
68 | | -noPreTracesSort = noPreTraces(:,noPreI); |
69 | | - |
70 | | - |
| 59 | +for i = 0:1 |
| 60 | + preSteps = vertcat(wtPreMRCs{:,4+i}); |
| 61 | + [preStepsSort, preI] = sortrows(preSteps,1+i); |
| 62 | + |
| 63 | + preRelSizes = round(preStepsSort(:,2)); |
| 64 | + preAbsSizes = round(preStepsSort(:,1)); |
| 65 | + preN = preStepsSort(:,7); |
| 66 | + preCellsSort = preCells(preI); |
| 67 | + preTracesSort = preTraces(:,preI); |
| 68 | + |
| 69 | + if i == 0 |
| 70 | + on_PreSteps = preStepsSort(:,[1 2 6 13]); |
| 71 | + on_PreTraces = preTracesSort; |
| 72 | + else |
| 73 | + off_PreSteps = preStepsSort(:,[1 2 6 13]); |
| 74 | + off_PreTraces = preTracesSort; |
| 75 | + end |
| 76 | + |
| 77 | + |
| 78 | + % Column 4 for off |
| 79 | + noPreSteps = vertcat(wtNoPreMRCs{:,3+i}); |
| 80 | + [noPreStepsSort, noPreI] = sortrows(noPreSteps,1+i); |
| 81 | + |
| 82 | + noPreSizes = round(noPreStepsSort(:,1)); |
| 83 | + noPreN = noPreStepsSort(:,7); |
| 84 | + noPreCellsSort = noPreCells(noPreI); |
| 85 | + noPreTracesSort = noPreTraces(:,noPreI); |
| 86 | + |
| 87 | + if i == 0 |
| 88 | + on_NoPreSteps = noPreStepsSort(:,[1 2 6 13]); |
| 89 | + on_NoPreTraces = noPreTracesSort; |
| 90 | + else |
| 91 | + off_NoPreSteps = noPreStepsSort(:,[1 2 6 13]); |
| 92 | + off_NoPreTraces = noPreTracesSort; |
| 93 | + end |
| 94 | +end |
| 95 | + |
| 96 | +% on/off_(no)PreSteps variable now contains: |
| 97 | +% absolute position, relative position (to 5um pre-step), current, nReps |
| 98 | + |
| 99 | +%% Calculate summary statistics for each step size |
| 100 | + |
| 101 | +% Relative displacement pre-step |
| 102 | +whichSteps = on_PreSteps(:,[2,3]); |
| 103 | + |
| 104 | +[~, sortIdx, eachDisp, dispStartIdx, dispEndIdx] = ... |
| 105 | + sortRowsTol(whichSteps, 0, 1); |
| 106 | +thisMean = arrayfun(@(x,y) mean(whichSteps(x:y,2)) ,dispStartIdx,dispEndIdx); |
| 107 | +thisSD = arrayfun(@(x,y) std(whichSteps(x:y,2)) ,dispStartIdx,dispEndIdx); |
| 108 | +thisSEM = thisSD./sqrt(dispEndIdx-dispStartIdx+1); |
| 109 | +thisDisp = eachDisp(:,1); |
| 110 | + |
| 111 | +relPreSummary = [thisDisp thisMean thisSD thisSEM]; |
| 112 | + |
| 113 | +% Absolute displacement pre-step |
| 114 | +whichSteps = on_PreSteps(:,[1,3]); |
| 115 | + |
| 116 | +[~, sortIdx, eachDisp, dispStartIdx, dispEndIdx] = ... |
| 117 | + sortRowsTol(whichSteps, 0, 1); |
| 118 | +thisMean = arrayfun(@(x,y) mean(whichSteps(x:y,2)) ,dispStartIdx,dispEndIdx); |
| 119 | +thisSD = arrayfun(@(x,y) std(whichSteps(x:y,2)) ,dispStartIdx,dispEndIdx); |
| 120 | +thisSEM = thisSD./sqrt(dispEndIdx-dispStartIdx+1); |
| 121 | +thisDisp = eachDisp(:,1); |
| 122 | + |
| 123 | +absPreSummary = [thisDisp thisMean thisSD thisSEM]; |
| 124 | + |
| 125 | +% No pre-step |
| 126 | +whichSteps = off_PreSteps(:,[2,3]); |
| 127 | +whichSteps(:,1) = -whichSteps(:,1); |
| 128 | + |
| 129 | +[~, sortIdx, eachDisp, dispStartIdx, dispEndIdx] = ... |
| 130 | + sortRowsTol(whichSteps, 0, 1); |
| 131 | +thisMean = arrayfun(@(x,y) mean(whichSteps(x:y,2)) ,dispStartIdx,dispEndIdx); |
| 132 | +thisSD = arrayfun(@(x,y) std(whichSteps(x:y,2)) ,dispStartIdx,dispEndIdx); |
| 133 | +thisSEM = thisSD./sqrt(dispEndIdx-dispStartIdx+1); |
| 134 | +thisDisp = eachDisp(:,1); |
| 135 | + |
| 136 | +noPreSummary = [thisDisp thisMean thisSD thisSEM]; |
| 137 | + |
| 138 | +relPreNorm = relPreSummary(:,1); |
| 139 | +relPreNorm(:,2:4) = relPreSummary(:,2:4)/max(noPreSummary(:,2)); |
| 140 | +absPreNorm = absPreSummary(:,1); |
| 141 | +absPreNorm(:,2:4) = absPreSummary(:,2:4)/max(noPreSummary(:,2)); |
| 142 | +noPreNorm = noPreSummary(:,1); |
| 143 | +noPreNorm(:,2:4) = noPreSummary(:,2:4)/max(noPreSummary(:,2)); |
| 144 | + |
| 145 | + |
| 146 | +%% Format tables and export source data and summary stats as text files for |
| 147 | +% reading or for Igor import |
| 148 | + |
| 149 | +% Turn arrays into tables and include variable names |
| 150 | +out_Names = {'Abs_Position_um','Rel_Disp_um','Current_pA','nReps'}; |
| 151 | + |
| 152 | +out_PreSummRel = array2table(relPreSummary,'Var',{'Pre_Rel_Disp_um','Mean_Current_pA','SD','SEM'}); |
| 153 | +out_PreSummAbs = array2table(absPreSummary,'Var',{'Pre_Abs_Disp_um','Mean_Current_pA','SD','SEM'}); |
| 154 | +out_NoPreSumm = array2table(noPreSummary,'Var',{'NoPre_Disp_um','Mean_Current_pA','SD','SEM'}); |
| 155 | + |
| 156 | +out_PreNormRel = array2table(relPreNorm,'Var',{'Pre_Rel_Disp_um','Norm_Current','SD','SEM'}); |
| 157 | +out_PreNormAbs = array2table(absPreNorm,'Var',{'Pre_Abs_Disp_um','Norm_Current','SD','SEM'}); |
| 158 | +out_NoPreNorm = array2table(noPreNorm,'Var',{'NoPre_Disp_um','Norm_Current','SD','SEM'}); |
| 159 | + |
| 160 | +out_PreStepsOn = array2table(on_PreSteps,'VariableNames',out_Names); |
| 161 | +out_PreStepsOff = array2table(off_PreSteps,'VariableNames',out_Names); |
| 162 | +out_NoPreStepsOn = array2table(on_NoPreSteps,'VariableNames',out_Names); |
| 163 | +out_NoPreStepsOff = array2table(off_NoPreSteps,'VariableNames',out_Names); |
| 164 | + |
| 165 | +% Write tables to xls file |
| 166 | +[fname, pname] = uiputfile({'*.xls','Excel file'},'Save source data as'); |
| 167 | + |
| 168 | +writetable(out_PreSummRel, fullfile(pname,fname),'Sheet','Summary','Range','A2'); |
| 169 | +writetable(out_PreSummAbs, fullfile(pname,fname),'Sheet','Summary','Range','F2'); |
| 170 | +writetable(out_NoPreSumm, fullfile(pname,fname),'Sheet','Summary','Range','K2'); |
| 171 | + |
| 172 | +writetable(out_PreNormRel, fullfile(pname,fname),'Sheet','Summary_Normalized','Range','A2'); |
| 173 | +writetable(out_PreNormAbs, fullfile(pname,fname),'Sheet','Summary_Normalized','Range','F2'); |
| 174 | +writetable(out_NoPreNorm, fullfile(pname,fname),'Sheet','Summary_Normalized','Range','K2'); |
| 175 | + |
| 176 | +writetable(out_PreStepsOn, fullfile(pname,fname),'Sheet','onPreSteps'); |
| 177 | +writetable(out_NoPreStepsOn, fullfile(pname,fname),'Sheet','onNoPreSteps'); |
| 178 | +writetable(out_PreStepsOff, fullfile(pname,fname),'Sheet','offPreSteps'); |
| 179 | +writetable(out_NoPreStepsOff, fullfile(pname,fname),'Sheet','offNoPreSteps'); |
| 180 | + |
| 181 | +%% Format wave names and export traces as text files for Igor |
71 | 182 | % Create name for Igor wave for each trace |
72 | 183 | preRelSizes = cellstr(num2str(preRelSizes)); |
73 | 184 | preRelSizes = cellfun(@(x) regexprep(x,'-','neg'), preRelSizes,'un',0); |
|
94 | 205 |
|
95 | 206 |
|
96 | 207 | % Write stimuli too |
97 | | -preStim = ephysData.FAT123.data{2,12}/0.408; |
| 208 | +preStim = ephysData.FAT123.data{2,12}/0.408; % V to um factor |
98 | 209 | noPreStim = ephysData.FAT123.data{2,15}/0.408; |
99 | 210 |
|
100 | 211 | preRelStimSizes = -2:7; |
|
0 commit comments