Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

getSubjectData.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. function [subjectData] = getSubjectData (sSubjectName, sVisualArea, sPenNumber, sDataType, sSelectedTimeWins)
  2. % varargin = sSubjectName, sVisualArea, sPenNumber, sDataType, sSelectedTimeWins // sSorted, sSNRThreshold
  3. % gets all of the data you may want for a selected subject
  4. % DEPENDS ON getSubjectInfos
  5. %
  6. % sSubjectName [monkey 1, monkey 2] *REQUIRED FIELD
  7. % sVisualArea [V1, V4] *REQUIRED FIELD
  8. % sPenNumber [double, GOOD, ALL] ALL is default
  9. % sDataType [LFPs, MUAEs, ALL] ALL is default
  10. % sSelectedTimeWins [PreStim, PostStim, Stationary, PostCue, PeFirstDim, PreSecondDim, PreThirdDim, ALL] MUTUALLY EXCLUSIVE, ALL is default
  11. %% PARSING INPUT PARAMETERS AND DEFAULT ASSIGNMENTS
  12. if nargin<5
  13. if nargin<4
  14. if nargin<3
  15. if nargin<2
  16. error('You should at least select a Subject Name and a Visual Area.');
  17. end
  18. sPenNumber='ALL';
  19. end
  20. sDataType='LFPs';
  21. end
  22. sSelectedTimeWins='ALL';
  23. end
  24. %% CHECKING SUBJECT NAME
  25. if ~sum(cellfun(@(x) strcmp(sSubjectName,x),{'Wyman','Taylor','monkey 1','monkey 2'}))
  26. error(['The selected Subject Name "' sSubjectName '" is not valid.']);
  27. elseif strcmpi(sSubjectName,'Wyman'); sSubjectName='monkey 1';
  28. elseif strcmpi(sSubjectName,'Taylor'); sSubjectName='monkey 2';
  29. end
  30. %% CHECKING VISUAL AREA
  31. if ~sum(cellfun(@(x) strcmp(sVisualArea,x),{'V1','V4'}))
  32. error(['The selected Visual Area "' sVisualArea '" is not valid.']);
  33. end
  34. %% PARSING PEN NUMBERS
  35. subjectInfos=getSubjectInfos(sSubjectName);
  36. if strcmp(sPenNumber,'ALL')
  37. penValues=subjectInfos.penIDs;
  38. penIndices=1:length(penValues);
  39. elseif strcmp(sPenNumber,'GOOD')
  40. penVec=subjectInfos.penIDs;
  41. px=1;
  42. for pp=1:length(penVec)
  43. if strcmp(subjectInfos.penInfos(pp).([sVisualArea 'Contacts']).Quality,'BAD')
  44. warning(['PEN ID ' num2str(penVec(pp)) ' was discarded, ' sSubjectName ' ' sVisualArea ' data have BAD quality.']);
  45. else
  46. penIndices(px)=pp;
  47. penValues(px)=penVec(pp);
  48. px=px+1;
  49. end
  50. end
  51. else % if you provide a penID or interval of penIDs
  52. penVec=str2num(sPenNumber);
  53. px=1;
  54. penIndices=[];
  55. for pv=1:length(penVec)
  56. penIndex=find(subjectInfos.penIDs==penVec(pv));
  57. if isempty(penIndex)
  58. warning(['PEN ID ' num2str(penVec(pv)) ' was discarded, not valid for ' sSubjectName ' ' sVisualArea '.']);
  59. else
  60. penIndices(px)=penIndex;
  61. penValues(px)=penVec(pv);
  62. px=px+1;
  63. end
  64. end
  65. end
  66. %% CHECKING PEN NUMBERS - DISCARDING NO V1/V4 DATA
  67. if ~isempty(penIndices)
  68. rmPenIndices=zeros(1,length(penIndices));
  69. for pv=1:length(penIndices)
  70. if strcmp(subjectInfos.penInfos(penIndices(pv)).([sVisualArea 'Contacts']).Quality,['NO ' sVisualArea ' DATA']) % REJECT (MAY BE IMPROVED)
  71. warning(['NO ' sVisualArea ' DATA for ' sSubjectName ' PEN ' num2str(penValues(pv))]);
  72. rmPenIndices(pv)=1;
  73. end
  74. end
  75. penIndices(logical(rmPenIndices))=[];
  76. penValues(logical(rmPenIndices))=[];
  77. if isempty(penIndices)
  78. error(['None of the selected PEN IDs "' sPenNumber '" is valid for ' sSubjectName ' ' sVisualArea '.']);
  79. end
  80. else
  81. error(['None of the selected PEN IDs "' sPenNumber '" is valid for ' sSubjectName ' ' sVisualArea '.']);
  82. end
  83. %% CHECKING DATATYPE
  84. if ~sum(cellfun(@(x) strcmp(sDataType,x),{'LFPs','iCSDs','MUAes','ALL'}))
  85. error(['The selected Data Type "' sDataType '" is not valid.']);
  86. end
  87. %% CHECKING THE TIME WINDOWS
  88. allTimeWins={'PreStim','PostStim','Stationary','PostCue','PreFirstDim','PreSecondDim','PreThirdDim','ALL'};
  89. % Parsing selected time windows
  90. if ~strcmp(sSelectedTimeWins,'ALL')
  91. error('Selecting a single timewin is not supported yet, write some code');
  92. end
  93. if ~sum(cellfun(@(x) strcmp(sSelectedTimeWins,x),allTimeWins))
  94. error(['The selected Time Window "' sSelectedTimeWins '" is not valid.']);
  95. end
  96. %% INITIALIZE THE DATA STRUCTURE
  97. subjectData.subjectName=sSubjectName;
  98. subjectData.penIDs=subjectInfos.penIDs(penIndices);
  99. for pp=1:length(penIndices)
  100. %% PARSING LAYERS TO GET DATA FROM OR PARSING SNRs - EVENTUALLY LATER
  101. %% GETTING LFPs
  102. if strcmp(sDataType,'LFPs') || strcmp(sDataType,'ALL')
  103. disp(['Loading ' sSelectedTimeWins ' LFPs for ' sSubjectName ' ' sVisualArea ' PEN ' num2str(penValues(pp))]);
  104. LLStr=load(subjectInfos.penInfos(penIndices(pp)).selectedTimeWinsFilePaths.([sVisualArea 'Contacts']).LFPs);
  105. if ~isempty(LLStr.LfpStruct)
  106. subjectData.LfpStruct(pp).Sorted=LLStr.LfpStruct.Sorted;
  107. subjectData.LfpStruct(pp).penNum=subjectInfos.penIDs(penIndices(pp));
  108. end
  109. clear LLStr
  110. end
  111. %% GETTING MUAes
  112. if strcmp(sDataType,'MUAEs') || strcmp(sDataType,'ALL')
  113. disp(['Loading ' sSelectedTimeWins ' MUAs for ' sSubjectName ' ' sVisualArea ' PEN ' num2str(penValues(pp))]);
  114. MMstr=load(subjectInfos.penInfos(penIndices(pp)).selectedTimeWinsFilePaths.([sVisualArea 'Contacts']).MUAs);
  115. if ~isempty(MMstr.MUAStruct)
  116. subjectData.MUAStruct(pp).Sorted=MMstr.MUAStruct.Sorted;
  117. subjectData.MUAStruct(pp).penNum=subjectInfos.penIDs(penIndices(pp));
  118. end
  119. clear MMstr
  120. end
  121. %% Appending penInfos
  122. subjectData.penInfos(pp)=subjectInfos.penInfos(penIndices(pp));
  123. end
  124. end