extractAllParamsFromTable.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. function outStruct = extractAllParamsFromTable(StimTableCell, varargin)
  2. switch nargin
  3. case 1
  4. threshold = 0;
  5. rSquareThreshold = -20;
  6. alignToOff = false;
  7. alignToAll = false;
  8. case 2
  9. threshold = varargin{1};
  10. rSquareThreshold = -20;
  11. alignToOff = false;
  12. alignToAll = false;
  13. case 3
  14. threshold = varargin{1};
  15. rSquareThreshold = varargin{2};
  16. alignToOff = false;
  17. alignToAll = false;
  18. case 4
  19. threshold = varargin{1};
  20. rSquareThreshold = varargin{2};
  21. alignToOff = varargin{3};
  22. alignToAll = false;
  23. case 5
  24. threshold = varargin{1};
  25. rSquareThreshold = varargin{2};
  26. alignToOff = varargin{3};
  27. alignToAll = varargin{4};
  28. otherwise
  29. warning('Too many arguments, cannot process them meaningfully!');
  30. end
  31. [~, ...
  32. ~, ...
  33. fitParams, ...
  34. flyInds, ...
  35. isAboveThreshold, ...
  36. tcExt, ...
  37. tcArgExt, ...
  38. respInd, ...
  39. rSquare ] = getAlignedTuningCurveArrayFromTable(StimTableCell, ...
  40. threshold, ...
  41. rSquareThreshold, ...
  42. alignToOff, ...
  43. alignToAll);
  44. nStims = numel(StimTableCell);
  45. for iStim = 1: nStims
  46. stimDegreeFactor = 2;
  47. amplitudeCell{iStim} = fitParams.a1{iStim};
  48. positionCell{iStim} = stimDegreeFactor * (fitParams.b1{iStim} - 1);
  49. widthCell{iStim} = stimDegreeFactor * 2 * sqrt(log(2)) * fitParams.c1{iStim}; % full-width half maximum conversion amplitudeCell{iStim} = a1;
  50. nRois(iStim) = sum(isAboveThreshold{iStim});
  51. nTotalRois(iStim) = numel(isAboveThreshold{iStim});
  52. % Check how many flies have good cells. This neeeds to include rSquare.
  53. nContributingFlies(iStim) = numel(unique(flyInds{iStim}));
  54. tcArgExt{iStim} = (tcArgExt{iStim} - 1) * stimDegreeFactor;
  55. end
  56. metadata.nRois = nRois;
  57. metadata.nTotalRois = nTotalRois;
  58. metadata.nContributingFlies = nContributingFlies;
  59. outStruct.metadata = metadata;
  60. outStruct.amplitude = amplitudeCell;
  61. outStruct.position = positionCell;
  62. outStruct.width = widthCell;
  63. outStruct.rSquare = rSquare;
  64. outStruct.respInd = respInd;
  65. outStruct.extremePos = tcArgExt;
  66. outStruct.extreme = tcExt;