1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- function [offX, offY, onX, onY] = getRFsAlignedWithFit(StimTableCell, rSqThresh, respIndThresh, varargin)
- if nargin > 3
- alignAll = varargin{1};
- if nargin > 4
- alignOrientation = varargin{2};
- else
- alignOrientation = true;
- end
- else
- alignAll = false;
- alignOrientation = true;
- end
- [tcArrayCell, responseIndArrayCell, rSquareArrayCell, fitParamsCell, ...
- flyIndsCell, tcExtCellArray, tcArgExtCellArray] = getStimArraysForSameRois(StimTableCell);
- % Align to fit
- posCell = cellfun(@(x) arrayfun(@(y) y.b1, x, 'uni', 0), fitParamsCell, 'uni', 1);
- widthCell = cellfun(@(x) arrayfun(@(y) 2 * (2 * sqrt(log(2))) * y.c1, x, 'uni', 0), ...
- fitParamsCell, 'uni', 1); % The 2 factor is because of bar separation.
- lagsCell = cellfun(@(x, y) round(x - size(y, 2) / 2), posCell, tcArrayCell, 'uni', 0);
- barRFs = cellfun(@(x, y) alignRFsToAbsMax(x, 0, y'), tcArrayCell, lagsCell, 'uni', 0);
- validIndsCell = cellfun(@(x, y) x(:) > rSqThresh & y(:) > respIndThresh, ...
- rSquareArrayCell, responseIndArrayCell, 'uni', 0)';
- %% Blank epoch was already deleted, now delete vertical bars on edges of screen.
- barRFs{2}(:, end-1: end) = [];
- barRFs{4}(:, end-1: end) = [];
- barRFs{2}(:, 1: 2) = [];
- barRFs{4}(:, 1: 2) = [];
- %%
- if alignAll
- validAll = validIndsCell{1} & validIndsCell{2} & ...
- validIndsCell{3} & validIndsCell{4};
- offX = barRFs{1}(validAll, :);
- offY = barRFs{2}(validAll, :);
- onX = barRFs{3}(validAll, :);
- onY = barRFs{4}(validAll, :);
- elseif alignOrientation
- offX = barRFs{1}(validIndsCell{1}&validIndsCell{2}, :);
- offY = barRFs{2}(validIndsCell{2}&validIndsCell{1}, :);
- onX = barRFs{3}(validIndsCell{3}&validIndsCell{4}, :);
- onY = barRFs{4}(validIndsCell{4}&validIndsCell{3}, :);
- else
- offX = barRFs{1}(validIndsCell{1}, :);
- offY = barRFs{2}(validIndsCell{2}, :);
- onX = barRFs{3}(validIndsCell{3}, :);
- onY = barRFs{4}(validIndsCell{4}, :);
- end
- end
|