MakeRFNoiseComparison_Fig2ef.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. %% Make fig 2 e, f
  2. close all;
  3. clear all;
  4. clc;
  5. %% Define search path.
  6. rawDataFolder = 'D:\Data_LGRTL\Two_photon';
  7. dataFolder = 'D:\Data_LGRTL\Two_photonMat';
  8. datasetInd = 3;
  9. [saveFolder, figDir, stimSetCellStr] = parseDatasetVars(datasetInd);
  10. figDir = 'P:\Documents\Figures\Paper\Tm9\fig2\noise\';
  11. % Fig dir test.
  12. if ~exist(figDir, 'dir')
  13. mkdir(figDir);
  14. end
  15. if ~exist(saveFolder, 'dir')
  16. warning('%s Folder does not exist', saveFolder)
  17. end
  18. % load([saveFolder 'processedTableWithBackground'], 'ProcessedTable');
  19. % load([saveFolder 'processedTableWithBackgroundOnOff'], 'ProcessedTable');
  20. % this was used in the figure
  21. load([saveFolder 'processedTableWithBackgroundOnOffNoiseCropped'], 'ProcessedTable');
  22. %%
  23. ProcessedTable = ProcessedTable(ProcessedTable.typeOfProblem == 0, :);
  24. % Check only bars.
  25. nStims = 8; % 8 for fff, bars, and noise; 5 for fff and bars.
  26. stimSetCellStr = stimSetCellStr(1: nStims);
  27. %% Split table into cell types.
  28. tokens = arrayfun(@(x) regexp(x, '.*Tm(\d).*', 'tokens'), ProcessedTable.timeSeriesPath);
  29. cellTypeNumArray = cellfun(@(x) str2num(x{1}{1}), tokens);
  30. cellTypeNum = unique(cellTypeNumArray);
  31. for iNeuron = 1: numel(cellTypeNum)
  32. StimTableNeuronCell{iNeuron} = ProcessedTable(cellTypeNumArray == cellTypeNum(iNeuron), :);
  33. end
  34. %%
  35. stimInd = 1;
  36. nStims = numel(stimSetCellStr);
  37. for iNeuron = 1: numel(cellTypeNum)
  38. for jStim = 1: nStims
  39. StimTableNeuronStim{iNeuron, jStim} = getStimSubsetTable(StimTableNeuronCell{iNeuron}, stimSetCellStr, jStim);
  40. end
  41. end
  42. for iFly = 1: numel(unique(ProcessedTable.flyInd))
  43. flyInds = ProcessedTable.flyInd == iFly;
  44. flyStims = ProcessedTable(flyInds, :).stimParamFileName;
  45. % Find if stim is within the chosen subset.
  46. flyStimInds{iFly} = (cellfun(@(x) find(strcmp(x, stimSetCellStr)), flyStims, 'uni', 0));
  47. % If it contains stimuli, check that it includes the 5 chosen.
  48. if ~isempty(flyStimInds{iFly})
  49. setDiff{iFly} = setdiff(1: nStims, [flyStimInds{iFly}{:}]);
  50. else
  51. setDiff{iFly} = -1;
  52. end
  53. % For flies with all chosen stimuli order the table accordingly.
  54. if isempty(setDiff{iFly})
  55. sortFlyIndsTemp = find(flyInds);
  56. [~, sortInd] = sort([flyStimInds{iFly}{:}]);
  57. sortFlyInds{iFly} = sortFlyIndsTemp(sortInd);
  58. end
  59. end
  60. StimOrderedTable = ProcessedTable(cat(1, sortFlyInds{:}), :);
  61. %% Split table into cell types.
  62. tokens = arrayfun(@(x) regexp(x, '.*Tm(\d).*', 'tokens'), StimOrderedTable.timeSeriesPath);
  63. cellTypeNumArray = cellfun(@(x) str2num(x{1}{1}), tokens);
  64. cellTypeNum = unique(cellTypeNumArray);
  65. for iNeuron = 1: numel(cellTypeNum)
  66. StimTableNeuronCell{iNeuron} = StimOrderedTable(cellTypeNumArray == cellTypeNum(iNeuron), :);
  67. end
  68. %%
  69. nStims = numel(stimSetCellStr);
  70. for iNeuron = 1: numel(cellTypeNum)
  71. for jStim = 1: nStims
  72. StimTableNeuronStim{iNeuron, jStim} = getStimSubsetTable(StimTableNeuronCell{iNeuron}, stimSetCellStr, jStim);
  73. end
  74. end
  75. OriginalStimTableNeuronStim = StimTableNeuronStim;
  76. %% Delete invalid rois for all flies and stimuli.
  77. bgRois = cellfun(@(y) cellfun(@(x) x.backgroundRois, y.roiMeta), StimTableNeuronStim, 'uni', 0);
  78. %Test if all background rois are the same for all stimuli.
  79. assert(isequal(bgRois{:}));
  80. invalidRois = zeros(size(StimTableNeuronStim{1}, 1), size(StimTableNeuronStim, 2));
  81. for iFly = 1: size(StimTableNeuronStim{1}, 1)
  82. for jStim = 1: size(StimTableNeuronStim, 2)
  83. invalidInds = StimTableNeuronStim{jStim}.roiMeta{iFly}.invalidRois;
  84. if ~isempty(invalidInds)
  85. invalidRois(iFly, jStim) = invalidInds;
  86. end
  87. end
  88. end
  89. roisToDeletePerFly = sum(unique(invalidRois', 'rows'))';
  90. % Try a manual fix, delete one fly from bars, and delete ROI 10 from Noise
  91. % stimulus. Check how this compares to the data in Snippet_RF_comparison.
  92. % [tcArrayCell, responseIndArrayCell, rSquareArrayCell, fitParamsCell, ...
  93. % flyIndsCell, tcExtCellArray, tcArgExtCellArray, ...
  94. % roisToRemoveInds] = getStimArraysForSameRois(StimTableNeuronStim([2:5, 7,8]), 1)
  95. %% Extract the parameters for the analysis of spatial RFs.
  96. jBar = 1;
  97. for iStim = 2:5
  98. dummyTable = StimTableNeuronStim{iStim};
  99. paramsCell = cellfun(@(x) x(1: end - 1*0), dummyTable.paramTuning, 'uni', 0);
  100. responseIndex = cellfun(@(x, y) x(1: end - 1*0), dummyTable.responseIndex, 'uni', 0);
  101. for jFly = find(roisToDeletePerFly ~= 0)
  102. if invalidRois(jFly, iStim) == 0
  103. paramsCell{jFly}(roisToDeletePerFly(jFly) - 1*0) = [];
  104. responseIndex{jFly}(roisToDeletePerFly(jFly) - 1*0) = [];
  105. end
  106. end
  107. amp(jBar, :) = cell2mat(cellfun(@(x) arrayfun(@(y) y.fit.a1, x, 'uni', 1), paramsCell, 'uni', 0)');
  108. pos(jBar, :) = cell2mat(cellfun(@(x) arrayfun(@(y) y.fit.b1, x, 'uni', 1), paramsCell, 'uni', 0)');
  109. width(jBar, :) = cell2mat(cellfun(@(x) arrayfun(@(y) y.fit.c1, x, 'uni', 1), paramsCell, 'uni', 0)');
  110. rsquare(jBar, :) = cell2mat(cellfun(@(x) arrayfun(@(y) y.gof.rsquare, x, 'uni', 1), paramsCell, 'uni', 0)');
  111. jBar = jBar + 1;
  112. end
  113. for iStim = [7, 8]
  114. dummyTable = StimTableNeuronStim{iStim};
  115. paramsCell = cellfun(@(x) x(1: end - 1*0), dummyTable.paramTuning, 'uni', 0);
  116. % responseIndex = cellfun(@(x, y) x(1: end - 1), dummyTable.responseIndex, 'uni', 0);
  117. for jFly = find(roisToDeletePerFly ~= 0)
  118. if invalidRois(jFly, iStim) == 0
  119. paramsCell{jFly}(roisToDeletePerFly(jFly) - 1*0) = [];
  120. % responseIndex{jFly}(roisToDeletePerFly(jFly) - 1*0) = [];
  121. end
  122. end
  123. amp(jBar, :) = cell2mat(cellfun(@(x) arrayfun(@(y) y.fit.a1, x, 'uni', 1), paramsCell, 'uni', 0)');
  124. pos(jBar, :) = cell2mat(cellfun(@(x) arrayfun(@(y) y.fit.b1, x, 'uni', 1), paramsCell, 'uni', 0)');
  125. width(jBar, :) = cell2mat(cellfun(@(x) arrayfun(@(y) y.fit.c1, x, 'uni', 1), paramsCell, 'uni', 0)');
  126. rsquare(jBar, :) = cell2mat(cellfun(@(x) arrayfun(@(y) y.gof.rsquare, x, 'uni', 1), paramsCell, 'uni', 0)');
  127. jBar = jBar + 1;
  128. end
  129. pos(1: 4, :) = 2 * (pos(1: 4, :) - 1);
  130. pos(5: 6, :) = 5 * pos(5: 6, :);
  131. width = (2 * sqrt(log(2))) * width;
  132. width(1: 4, :) = 2 * width(1: 4, :);
  133. width(5: 6, :) = 5 * width(5: 6, :);
  134. validInds = all(rsquare([1, 2, 5, 6], :) > 0.5) & all(rsquare([3, 4], :) > 0.1);
  135. %%
  136. flyInds = repelem(1:size(StimTableNeuronStim{1}),cellfun(@numel, StimTableNeuronStim{1}.responseIndex));
  137. flyInds(roisToDeletePerFly(1)) = [];
  138. flyInds(validInds)
  139. numel(unique(flyInds(validInds)))
  140. %%
  141. clear allRFs
  142. for iStim = 2: 5
  143. tuningMethods = StimTableNeuronStim{iStim}.nonParamTuning{1}.tuningMethods;
  144. tuningMethodInd = strcmp(tuningMethods, 'extreme');
  145. tcCellArray = cellfun(@(x) squeeze(x.tc{tuningMethodInd}(:, 1: end - 1, :)), StimTableNeuronStim{iStim}.nonParamTuning, 'uni', 0);
  146. allRFs{iStim - 1} = cell2mat(tcCellArray);
  147. end
  148. %%
  149. noiseRFs{1} = getSpaceFilterArrayFromTable(StimTableNeuronStim{7}); % Az is horizontal
  150. noiseRFs{2} = getSpaceFilterArrayFromTable(StimTableNeuronStim{8}); % El is vertical
  151. %%
  152. % Delete invalid roi that shifts all images by one;
  153. barRFs = cellfun(@(x) x(setdiff(1: length(allRFs{1}), roisToDeletePerFly(1)), 1: end), ...
  154. allRFs, 'uni', 0);
  155. noiseRFs{1}(roisToDeletePerFly(1), :) = [];
  156. %%
  157. % The screen is about 48-60 deg, we center the RFs at about the center 24
  158. % deg, using the fit positions for higher presicion.
  159. lagsBars = round((pos(1: 4, :) - 25) / 2);
  160. for iBar = 1: numel(barRFs)
  161. barRFs{iBar} = alignRFsToAbsMax(barRFs{iBar}, 0, lagsBars(iBar, :)');
  162. end
  163. lagsNoise = round((pos(5: 6, :) - 30) / 5);
  164. for iBar = 1: numel(noiseRFs)
  165. noiseRFs{iBar} = alignRFsToAbsMax(noiseRFs{iBar}, 0, lagsNoise(iBar, :));
  166. end
  167. %% Blank epoch was already deleted, now delete vertical bars on edges of screen.
  168. barRFs{2}(:, end-1: end) = [];
  169. barRFs{4}(:, end-1: end) = [];
  170. barRFs{2}(:, 1: 2) = [];
  171. barRFs{4}(:, 1: 2) = [];
  172. %% Fig2e
  173. hFig = figure;
  174. splitSign = 1;
  175. doSmoothing = 1;
  176. indsToPlot = validInds;
  177. subplot_tight(1, 3, 1);
  178. plotRFEnsemble(noiseRFs{1}, noiseRFs{2}, splitSign, doSmoothing, indsToPlot);
  179. title('White noise spatial filters')
  180. % Plot bar RFs. OFF.
  181. subplot_tight(1, 3, 2);
  182. plotRFEnsemble(barRFs{1}, barRFs{2}, splitSign, doSmoothing, indsToPlot);
  183. title('OFF flashing bar filters')
  184. % Plot bar RFs. ON.
  185. subplot_tight(1, 3, 3);
  186. plotRFEnsemble(barRFs{3}, barRFs{4}, splitSign, doSmoothing, indsToPlot);
  187. title('ON flashing bar filters')
  188. suptitle('Cartesian product (X \times Y) of one dimensional tuning curves');
  189. figFileName = ['RFIm-ON-OFF-Noise'];
  190. print(hFig, [figDir figFileName '.pdf'], '-dpdf')
  191. % print(hFig, [figDir figFileName '.png'], '-dpng', '-r
  192. %% Write data for fig2e
  193. dataFileName = [figDir filesep 'Fig2.xls'];
  194. DataTable = createRFsTable(noiseRFs{1}(indsToPlot, :), 'Noise_horizontal_position_deg');
  195. % Correct spacing from 2 deg for bars to 5 deg for noise.
  196. DataTable(:, 1).Noise_horizontal_position_deg = 5 / 2 * DataTable(:, 1).Noise_horizontal_position_deg;
  197. writetable(DataTable, dataFileName, 'Sheet', 'Fig2e')
  198. DataTable = createRFsTable(noiseRFs{1}(indsToPlot, :), 'Noise_vertical_position_deg');
  199. % Correct spacing from 2 deg for bars to 5 deg for noise.
  200. DataTable(:, 1).Noise_vertical_position_deg = 5 / 2 * DataTable(:, 1).Noise_vertical_position_deg;
  201. writetable(DataTable, dataFileName, 'Sheet', 'Fig2e', 'Range', 'A15')
  202. DataTable = createRFsTable(barRFs{1}(indsToPlot, :), 'OFF_horizontal_position_deg');
  203. writetable(DataTable, dataFileName, 'Sheet', 'Fig2e', 'Range', 'A29')
  204. DataTable = createRFsTable(barRFs{2}(indsToPlot, :), 'OFF_vertical_position_deg');
  205. writetable(DataTable, dataFileName, 'Sheet', 'Fig2e', 'Range', 'A56')
  206. DataTable = createRFsTable(barRFs{3}(indsToPlot, :), 'ON_horizontal_position_deg');
  207. writetable(DataTable, dataFileName, 'Sheet', 'Fig2e', 'Range', 'A83')
  208. DataTable = createRFsTable(barRFs{4}(indsToPlot, :), 'ON_vertical_position_deg');
  209. writetable(DataTable, dataFileName, 'Sheet', 'Fig2e', 'Range', 'A110')
  210. %%
  211. offX = barRFs{1}(validInds, :);
  212. offY = barRFs{2}(validInds, :);
  213. onX = barRFs{3}(validInds, :);
  214. onY = barRFs{4}(validInds, :);
  215. lnX = noiseRFs{1}(validInds, :);
  216. lnY = noiseRFs{2}(validInds, :);
  217. % % Realign good cells.
  218. % [onX] = alignRFsToAbsMax(onX, 0, [], 'on');
  219. % [onY] = alignRFsToAbsMax(onY, 0, [], 'on');
  220. % [lnX] = alignRFsToAbsMax(lnX, 0, [], 'on');
  221. % [lnY] = alignRFsToAbsMax(lnY, 0, [], 'on');
  222. % lnX = interp1(2.5:5:60-2.5, lnX', linspace(4,46, 24))';
  223. % lnY = interp1(2.5:5:60-2.5, lnY', linspace(4,46, 24))';
  224. lnX = interp1(linspace(2.5,60, 12), lnX', linspace(2.5,60, 25))';
  225. lnY = interp1(linspace(2.5,60, 12), lnY', linspace(2.5,60, 25))';
  226. % Realign noise to center now at 2 deg precision.
  227. [~, peakInd] = max(abs(lnX), [], 2);
  228. lnX = alignRFsToAbsMax(lnX, 0, peakInd - round(length(lnX) / 2) - 1);
  229. [~, peakInd] = max(abs(lnY), [], 2);
  230. lnY = alignRFsToAbsMax(lnY, 0, peakInd - round(length(lnY) / 2) - 1);
  231. maxNorm = @(x, dim) x ./ max(abs(x), [], dim);
  232. getRow = @(x, nRow) x(nRow, :);
  233. normRFs = cellfun(@(x) cell2mat(arrayfun(@(y) smooth(getRow(maxNorm(x,2), y))', 1: size(x, 1), 'uni', 0)'), ...
  234. {offX, offY, onX, onY, lnX, lnY}, 'uni', 0);
  235. normRFs = cellfun(@(x) maxNorm(x,2), normRFs, 'uni', 0);
  236. hFig = createPrintFig(15 * [ 1 1 / 3]);
  237. for iRFType = 1:3
  238. subplot_tight(1, 3, iRFType);
  239. imshow(getRFIm(mean(normRFs{2*iRFType}), mean(normRFs{2*iRFType - 1})))
  240. end
  241. figFileName = ['RFIm-ON-OFF-Noise-mean'];
  242. print(hFig, [figDir figFileName '.pdf'], '-dpdf')
  243. hFig = createPrintFig(15 * [ 1 2/3]);
  244. hSubAx = plotLasagnaTracesFromCell(gcf, normRFs, brewermap(6, 'Paired'));
  245. ylim(hSubAx(:, 1), [-1 1]);
  246. arrayfun(@(x) set(get(x, 'YAxis'), 'Visible', 'on'), hSubAx(1, :))
  247. cellfun(@(x) caxis(ZeroCenteredBounds(x, [0 100])), normRFs, 'uni', 0)
  248. arrayfun(@prettifyAxes, hSubAx)
  249. arrayfun(@offsetAxes, hSubAx)
  250. set(hSubAx, 'Visible', 'off')
  251. figFileName = ['RFcurves-ON-OFF-Noise-XY-lasagna'];
  252. print(hFig, [figDir figFileName '.pdf'], '-dpdf')
  253. % figure;
  254. %
  255. % for iRFType = 1:3
  256. % plot(mean(normRFs{2*iRFType - 1}));
  257. % hold on;
  258. % plot(mean(normRFs{2*iRFType}));
  259. %
  260. % end
  261. %%
  262. hFig = createPrintFig(15 * [1 1/2]);
  263. pairsToAverage = {[1, 2], [3, 4], [5, 6]};
  264. meanWidths = cellfun(@(x) mean(width(x, validInds)), pairsToAverage, 'uni', 0);
  265. meanWidths = cellfun(@(x) mean(width(x, validInds)), pairsToAverage, 'uni', 0);
  266. beanPlot(meanWidths, {'off', 'on', 'noise'}, flipud(brewermap(3, 'Set1')), 1, gca, [0-eps 50], 'vertical', false, true)
  267. figFileName = ['RF-ON-OFF-Noise-FWHM-Bean'];
  268. print(hFig, [figDir figFileName '.pdf'], '-dpdf')
  269. %% Save data for Fig 2f
  270. xlswrite(dataFileName, {'FHWM-OFF-bars'}, 'Fig2f', 'A1')
  271. xlswrite(dataFileName, meanWidths{1}, 'Fig2f', 'B1')
  272. xlswrite(dataFileName, {'FHWM-ON-bars'}, 'Fig2f', 'A2')
  273. xlswrite(dataFileName, meanWidths{2}, 'Fig2f', 'B2')
  274. xlswrite(dataFileName, {'FHWM-Noise-bars'}, 'Fig2f', 'A3')
  275. xlswrite(dataFileName, meanWidths{3}, 'Fig2f', 'B3')
  276. %% Permutation test for mean RF width difference.
  277. [pValOFFvsON, obsDiff] = permutationTest(meanWidths{1},meanWidths{2}, 100000)
  278. [pValONvsNoise, obsDiff] = permutationTest(meanWidths{2},meanWidths{3}, 100000)
  279. [pValOFFvsNoise, obsDiff] = permutationTest(meanWidths{1},meanWidths{3}, 100000)
  280. %%
  281. hFig = createPrintFig(15 * [1/2 1/2]);
  282. meanAmps = cellfun(@(x) mean(amp(x, validInds)), pairsToAverage(1:2), 'uni', 0);
  283. beanPlot(meanAmps, {'off', 'on'}, flipud(brewermap(3, 'Set1')), 1, gca,'unbounded', 'vertical', false, true)
  284. figFileName = ['RF-ON-OFF-Noise-Amp-Bean'];
  285. print(hFig, [figDir figFileName '.pdf'], '-dpdf')
  286. %% Save data for Fig 2f
  287. xlswrite(dataFileName, {'Amp-OFF-bars'}, 'Fig2f', 'A5')
  288. xlswrite(dataFileName, meanAmps{1}, 'Fig2f', 'B5')
  289. xlswrite(dataFileName, {'Amp-ON-bars'}, 'Fig2f', 'A6')
  290. xlswrite(dataFileName, meanAmps{2}, 'Fig2f', 'B6')
  291. %%
  292. % pairsToPlot = {[1 5], [2 6], [3 5], [4 6]};
  293. pairsToPlot = {[1 2], [3 4], [1 4], [1 3], [2 4], [2 3]};
  294. labelsCell = {'X OFF', 'Y OFF', 'X ON', 'Y ON', 'X Noise', 'Y Noise'};
  295. indsToPlot = validInds;
  296. % fwhmArray = [mean(width(1: 2, :)); mean(width(3: 4, :)); mean(width(5: 6, :))]';
  297. fwhmArray = width';
  298. rSquare = rsquare';
  299. % hFig = createFullScreenFig;
  300. % set(hFig, 'Units', 'Centimeters')
  301. % set(hFig, 'Position', [hFig.Position(1:2) + 10 14 14]);
  302. hFig = createPrintFig(15 * [ 1 2/3]);
  303. for iPair = 1: numel(pairsToPlot)
  304. hScattAx(iPair) = subplot(2, 3, iPair); hold on;
  305. xInd = pairsToPlot{iPair}(1);
  306. yInd = pairsToPlot{iPair}(2);
  307. scatter(fwhmArray(indsToPlot, xInd), fwhmArray(indsToPlot, yInd), [], ...
  308. min(rSquare(indsToPlot, xInd), rSquare(indsToPlot, yInd)), 'filled');
  309. [correlation, pValue] = corr(fwhmArray(indsToPlot, xInd), fwhmArray(indsToPlot, yInd), 'type', 'Pearson' );
  310. x = fwhmArray(indsToPlot, xInd);
  311. [b, bInt]= regress(fwhmArray(indsToPlot, yInd), [ones(length(x), 1) x]);
  312. hFit = plot(x, b(1) + x*b(2), 'Color', [1 1 1] * 0.5);
  313. maxVal = max([fwhmArray(indsToPlot, xInd); fwhmArray(indsToPlot, yInd)]);
  314. maxVal = quantile(vec(fwhmArray(indsToPlot, :)), 1);
  315. plot([0 maxVal], [0 maxVal], 'Color', [1 1 1] * 0.5);
  316. prettifyAxes(gca);
  317. set(gca, 'XLim', [0 maxVal], 'YLim', [0 maxVal], 'CLim', [0 1]);
  318. axis square;
  319. xlabel(labelsCell{xInd});
  320. ylabel(labelsCell{yInd});
  321. title({['\rho = ' num2str(correlation, 2) ', p = ' num2str(pValue, 2) ],...
  322. ['m = ' num2str(b(2), 2) ' (' num2str(bInt(2, 1), 2) ', ' num2str(bInt(2, 2), 2) ')']})
  323. setFavoriteColormap
  324. end
  325. setFontForThesis(hScattAx, gcf);
  326. arrayfun(@prettifyAxes, hScattAx)
  327. arrayfun(@offsetAxes, hScattAx)
  328. % set(hSubAx, 'Visible', 'off')
  329. figFileName = ['BarRFs-Corr-Pearson'];
  330. print(hFig, [figDir figFileName '.pdf'], '-dpdf')
  331. %%
  332. offWidth = mean(width(1: 2, indsToPlot), 1);
  333. onWidth = mean(width(3: 4, indsToPlot), 1);
  334. [corrWidth, pCorrWidth] = corr(offWidth(:), onWidth(:))
  335. %%
  336. offWidth = width(1: 2, indsToPlot);
  337. onWidth = width(3: 4, indsToPlot);
  338. [corrWidth, pCorrWidth] = corr(offWidth(:), onWidth(:))
  339. %%
  340. [corrWidth, pCorrWidth] = corr(width(1:4, indsToPlot)', 'type','Spearman' )
  341. %% The rest of the code was erased, maybe was for older figure with fullfield variability.