Browse Source

Upload files to 'Code'

Demetrio Ferro 3 years ago
parent
commit
a0bdec0010
3 changed files with 1756 additions and 0 deletions
  1. 149 0
      Code/getSubjectData.m
  2. 644 0
      Code/getSubjectInfos.m
  3. 963 0
      Code/processSpectralPower.m

+ 149 - 0
Code/getSubjectData.m

@@ -0,0 +1,149 @@
+function [subjectData] = getSubjectData (sSubjectName, sVisualArea, sPenNumber, sDataType, sSelectedTimeWins)
+
+% varargin = sSubjectName, sVisualArea, sPenNumber, sDataType, sSelectedTimeWins, sSorted,
+%                                                                                               sSNRThreshold)
+% gets all of the data you may want for a selected subject
+% DEPENDS ON getSubjectInfos
+%
+% sSubjectName      [Jones, Wyman, Taylor] *REQUIRED FIELD
+% sVisualArea       [V1, V4] *REQUIRED FIELD
+% sPenNumber        [double, GOOD, ALL] ALL is default
+% sDataType         [LFPs, MUAEs, ALL] ALL is default 
+% sSelectedTimeWins [PreStim, PostStim, Stationary, PostCue, PeFirstDim, PreSecondDim, PreThirdDim, ALL] MUTUALLY EXCLUSIVE, ALL is default
+
+%% PARSING INPUT PARAMETERS AND DEFAULT ASSIGNMENTS
+
+if nargin<5
+    if nargin<4
+        if nargin<3
+            if nargin<2
+                error('You should at least select a Subject Name and a Visual Area.');
+            end
+            sPenNumber='ALL';
+        end
+        sDataType='ALL';
+    end
+    sSelectedTimeWins='ALL';
+end
+
+%% CHECKING SUBJECT NAME
+if ~sum(cellfun(@(x) strcmp(sSubjectName,x),{'Wyman','Taylor','monkey 1','monkey 2'}))
+    error(['The selected Subject Name "' sSubjectName '" is not valid.']);
+elseif strcmpi(sSubjectName,'monkey 1'); sSubjectName='Wyman'; 
+elseif strcmpi(sSubjectName,'monkey 2'); sSubjectName='Taylor'; 
+end
+%% CHECKING VISUAL AREA
+if ~sum(cellfun(@(x) strcmp(sVisualArea,x),{'V1','V4'}))
+    error(['The selected Visual Area "' sVisualArea '" is not valid.']);
+end
+
+%% PARSING PEN NUMBERS
+subjectInfos=getSubjectInfos(sSubjectName);
+
+if strcmp(sPenNumber,'ALL')
+    penValues=subjectInfos.penIDs;
+    penIndices=1:length(penValues);
+elseif strcmp(sPenNumber,'GOOD')
+    penVec=subjectInfos.penIDs;
+    px=1;
+    for pp=1:length(penVec)
+        if strcmp(subjectInfos.penInfos(pp).([sVisualArea 'Contacts']).Quality,'BAD')
+            warning(['PEN ID ' num2str(penVec(pp)) ' was discarded, ' sSubjectName ' ' sVisualArea ' data have BAD quality.']);
+        else
+            penIndices(px)=pp;
+            penValues(px)=penVec(pp);
+            px=px+1;
+        end
+    end
+else % if you provide a penID or interval of penIDs
+    penVec=str2num(sPenNumber);
+    
+    px=1;
+    penIndices=[];
+    
+    for pv=1:length(penVec)
+        penIndex=find(subjectInfos.penIDs==penVec(pv));
+        if isempty(penIndex)
+            warning(['PEN ID ' num2str(penVec(pv)) ' was discarded, not valid for ' sSubjectName ' ' sVisualArea '.']);
+        else
+            penIndices(px)=penIndex;
+            penValues(px)=penVec(pv);
+            px=px+1;
+        end
+    end
+end
+
+%% CHECKING PEN NUMBERS - DISCARDING NO V1/V4 DATA
+if ~isempty(penIndices)
+    rmPenIndices=zeros(1,length(penIndices));
+    for pv=1:length(penIndices)
+        if strcmp(subjectInfos.penInfos(penIndices(pv)).([sVisualArea 'Contacts']).Quality,['NO ' sVisualArea ' DATA']) % REJECT (MAY BE IMPROVED)
+            warning(['NO ' sVisualArea ' DATA for ' sSubjectName ' PEN ' num2str(penValues(pv))]);
+            rmPenIndices(pv)=1;
+        end
+    end
+    penIndices(logical(rmPenIndices))=[];
+    penValues(logical(rmPenIndices))=[];
+    if isempty(penIndices)
+        error(['None of the selected PEN IDs "' sPenNumber '" is valid for ' sSubjectName ' ' sVisualArea '.']);
+    end
+else
+    error(['None of the selected PEN IDs "' sPenNumber '" is valid for ' sSubjectName ' ' sVisualArea '.']);
+end
+
+%% CHECKING DATATYPE
+if ~sum(cellfun(@(x) strcmp(sDataType,x),{'LFPs','iCSDs','MUAes','ALL'}))
+    error(['The selected Data Type "' sDataType '" is not valid.']);
+end
+
+%% CHECKING THE TIME WINDOWS
+allTimeWins={'PreStim','PostStim','Stationary','PostCue','PreFirstDim','PreSecondDim','PreThirdDim','ALL'};
+% Parsing selected time windows
+if ~strcmp(sSelectedTimeWins,'ALL')
+    error('Selecting a single timewin is not supported yet, write some code');
+end
+if ~sum(cellfun(@(x) strcmp(sSelectedTimeWins,x),allTimeWins)) 
+    error(['The selected Time Window "' sSelectedTimeWins '" is not valid.']);
+end
+
+%% INITIALIZE THE DATA STRUCTURE
+subjectData.subjectName=sSubjectName;
+subjectData.penIDs=subjectInfos.penIDs(penIndices);
+
+for pp=1:length(penIndices)
+    
+    %% PARSING LAYERS TO GET DATA FROM OR PARSING SNRs - EVENTUALLY LATER
+    
+    %% GETTING LFPs
+    if  strcmp(sDataType,'LFPs') || strcmp(sDataType,'ALL')
+        disp(['Loading ' sSelectedTimeWins ' LFPs for ' sSubjectName ' ' sVisualArea ' PEN ' num2str(penValues(pp))]);
+        LLStr=load(subjectInfos.penInfos(penIndices(pp)).selectedTimeWinsFilePaths.([sVisualArea 'Contacts']).LFPs);
+        if ~isempty(LLStr.LfpStruct)
+            subjectData.LfpStruct(pp).Sorted=LLStr.LfpStruct.Sorted;
+        end
+        subjectData.LfpStruct(pp).penNum=subjectInfos.penIDs(penIndices(pp));
+        clear LLStr
+    end
+    
+    
+    %% GETTING MUAes
+    if  strcmp(sDataType,'MUAEs') || strcmp(sDataType,'ALL')
+        disp(['Loading ' sSelectedTimeWins ' MUAs for ' sSubjectName ' ' sVisualArea ' PEN ' num2str(penValues(pp))]);
+        MMstr=load(subjectInfos.penInfos(penIndices(pp)).selectedTimeWinsFilePaths.([sVisualArea 'Contacts']).MUAs);
+        if ~isempty(MMstr.MUAStruct)
+            subjectData.MUAStruct(pp).Sorted=MMstr.MUAStruct.Sorted;
+        end
+        subjectData.MUAStruct(pp).penNum=subjectInfos.penIDs(penIndices(pp));
+        clear MMstr
+    end
+    
+        
+    %% Appending penInfos
+    subjectData.penInfos(pp)=subjectInfos.penInfos(penIndices(pp));
+     
+end
+
+
+
+
+end

+ 644 - 0
Code/getSubjectInfos.m

@@ -0,0 +1,644 @@
+function subjectInfos=getSubjectInfos(sSubjectName)
+
+% gets all of the informations you may need for the subject you want to inspect.
+%
+% subjectName, penIDs,  subjectInfos.penInfos
+% Wyman        288      V1.Channels, V4.Channels, V1.ChRejected, V4.ChRejected, V1.Quality, V4.Quality, eventFileName, ctxFileName, lfpFilePath, cscFilePath
+%              ...      ...
+%              323      ...
+%
+% Taylor       1        ...
+%              ...      ...
+%              33       V1.Channels, V4.Channels, V1.ChRejected, V4.ChRejected, V1.Quality, V4.Quality, eventFileName, ctxFileName, lfpFilePath, cscFilePath
+
+if ~sum(cellfun(@(x) strcmp(sSubjectName,x),{'Wyman','Taylor','monkey 1','monkey 2'}))
+    error(['The selected Subject Name "' sSubjectName '" is not valid.']);
+elseif strcmpi(sSubjectName,'Wyman'); sSubjectName='monkey 1'; 
+elseif strcmpi(sSubjectName,'Taylor'); sSubjectName='monkey 2'; 
+end
+
+startPath='../Data/';
+
+switch sSubjectName
+        
+    case 'monkey 1'
+        
+        subjectInfos.subjectName='Wyman';
+        subjectInfos.penIDs=[288:293 295:323];
+        subjectInfos.grcIDs=[145 148 150 152:154 157 158 160 163 165 166 167 169 170:172 174:177 179 180 181 183 186 187 189 190:192 194:197];
+        subjectInfos.ctxIDs=160120+[1 2 6:9 83:85 89:92 96:99 103:106 181:184 195:196 285:288 292:295];
+        
+        
+        %% DATE-TIME AND V1-V4 DEPTHS (Manually selected from CSDs)
+        subjectInfos.penInfos(1).dateTime='2016-04-22_15-29-16'; % PEN 288
+        subjectInfos.penInfos(1).V1Contacts.Depths=-1.2313+.15*(0:15);
+        subjectInfos.penInfos(1).V4Contacts.Depths=-0.4312+.15*(0:15);
+        subjectInfos.penInfos(2).dateTime='2016-04-06_14-54-03'; % PEN 289
+        % MAYBE BETTER ALIGNMENT FOR PEN 289
+        subjectInfos.penInfos(2).V1Contacts.Depths=-1.5813+.15*(0:15);
+        %subjectInfos.penInfos(2).V1Contacts.Depths=-0.8812+.15*(0:15);
+        subjectInfos.penInfos(2).V4Contacts.Depths=-0.8187+.15*(0:15);
+        subjectInfos.penInfos(3).dateTime='2016-04-07_13-09-47'; % PEN 290
+        subjectInfos.penInfos(3).V1Contacts.Depths=-1.3687+.15*(0:15);
+        subjectInfos.penInfos(3).V4Contacts.Depths=-1.1937+.15*(0:15);
+        subjectInfos.penInfos(4).dateTime='2016-04-08_15-33-57'; % PEN 291
+        subjectInfos.penInfos(4).V1Contacts.Depths=-1.3438+.15*(0:15);
+        subjectInfos.penInfos(4).V4Contacts.Depths=-0.6437+.15*(0:15);
+        subjectInfos.penInfos(5).dateTime='2016-04-11_10-01-05'; % PEN 292
+        subjectInfos.penInfos(5).V1Contacts.Depths=-1.8218+.15*(0:15);
+        subjectInfos.penInfos(5).V4Contacts.Depths=-1.3562+.15*(0:15);
+        subjectInfos.penInfos(6).dateTime='2016-04-11_14-22-23'; % PEN 293
+        subjectInfos.penInfos(6).V1Contacts.Depths=-1.8562+.15*(0:15);
+        subjectInfos.penInfos(6).V4Contacts.Depths=-0.8187+.15*(0:15);
+        subjectInfos.penInfos(7).dateTime='2016-05-09_11-21-17'; % PEN 295
+        % MAYBE BETTER ALIGNMENT FOR PEN 295
+        % subjectInfos.penInfos(7).V1Contacts.Depths=-1.3437+.15*(0:15);
+        subjectInfos.penInfos(7).V1Contacts.Depths=-1.8437+.15*(0:15);
+        subjectInfos.penInfos(7).V4Contacts.Depths=-1.0062+.15*(0:15);
+        subjectInfos.penInfos(8).dateTime='2016-04-12_09-30-14'; % PEN 296
+        subjectInfos.penInfos(8).V1Contacts.Depths=-1.5062+.15*(0:15);
+        subjectInfos.penInfos(8).V4Contacts.Depths=-0.8687+.15*(0:15);
+        subjectInfos.penInfos(9).dateTime='2016-04-12_17-14-48'; % PEN 297
+        subjectInfos.penInfos(9).V1Contacts.Depths=-1.2568+.15*(0:15);
+        subjectInfos.penInfos(9).V4Contacts.Depths=-0.9438+.15*(0:15);
+        subjectInfos.penInfos(10).dateTime='2016-04-13_10-07-56'; % PEN 298
+        subjectInfos.penInfos(10).V1Contacts.Depths=[];
+        subjectInfos.penInfos(10).V4Contacts.Depths=-0.8813+.15*(0:15);
+        subjectInfos.penInfos(11).dateTime='2016-04-13_13-51-50'; % PEN 299
+        subjectInfos.penInfos(11).V1Contacts.Depths=-1.6812+.15*(0:15);
+        subjectInfos.penInfos(11).V4Contacts.Depths=-0.9687+.15*(0:15);
+        subjectInfos.penInfos(12).dateTime='2016-04-14_08-11-50'; % PEN 300
+        % MAYBE BETTER ALIGNMENT FOR PEN 300
+        % subjectInfos.penInfos(12).V1Contacts.Depths=-0.7169+.15*(0:15);
+        subjectInfos.penInfos(12).V1Contacts.Depths=-1.5169+.15*(0:15);
+        subjectInfos.penInfos(12).V4Contacts.Depths=-1.2438+.15*(0:15);
+        subjectInfos.penInfos(13).dateTime='2016-04-17_19-39-40'; % PEN 301
+        subjectInfos.penInfos(13).V1Contacts.Depths=-1.6614+.15*(0:15);
+        subjectInfos.penInfos(13).V4Contacts.Depths=-1.0813+.15*(0:15);
+        subjectInfos.penInfos(14).dateTime='2016-04-18_10-46-29'; % PEN 302
+        subjectInfos.penInfos(14).V1Contacts.Depths=-1.4075+.15*(0:15);
+        subjectInfos.penInfos(14).V4Contacts.Depths=-1.1063+.15*(0:15);
+        subjectInfos.penInfos(15).dateTime='2016-05-09_13-52-17'; % PEN 303
+        subjectInfos.penInfos(15).V1Contacts.Depths=-1.7312+.15*(0:15);
+        subjectInfos.penInfos(15).V4Contacts.Depths=-1.0559+.15*(0:15);
+        subjectInfos.penInfos(16).dateTime='2016-04-18_14-07-37'; % PEN 304
+        subjectInfos.penInfos(16).V1Contacts.Depths=-1.5437+.15*(0:15);
+        subjectInfos.penInfos(16).V4Contacts.Depths=-0.8062+.15*(0:15);
+        subjectInfos.penInfos(17).dateTime='2016-04-18_20-54-23'; % PEN 305
+        subjectInfos.penInfos(17).V1Contacts.Depths=-0.7653+.15*(0:15);
+        subjectInfos.penInfos(17).V4Contacts.Depths=-0.8937+.15*(0:15);
+        subjectInfos.penInfos(18).dateTime='2016-04-19_16-39-04'; % PEN 306
+        subjectInfos.penInfos(18).V1Contacts.Depths=-0.9312+.15*(0:15);
+        subjectInfos.penInfos(18).V4Contacts.Depths=-0.6937+.15*(0:15);
+        subjectInfos.penInfos(19).dateTime='2016-04-20_09-02-43'; % PEN 307
+        subjectInfos.penInfos(19).V1Contacts.Depths=-0.8562+.15*(0:15);
+        subjectInfos.penInfos(19).V4Contacts.Depths=-0.6437+.15*(0:15);
+        subjectInfos.penInfos(20).dateTime='2016-04-20_12-41-43'; % PEN 308
+        subjectInfos.penInfos(20).V1Contacts.Depths=-1.4312+.15*(0:15);
+        subjectInfos.penInfos(20).V4Contacts.Depths=-1.0188+.15*(0:15);
+        subjectInfos.penInfos(21).dateTime='2016-04-20_12-46-41'; % PEN 309
+        subjectInfos.penInfos(21).V1Contacts.Depths=-1.3938+.15*(0:15);
+        subjectInfos.penInfos(21).V4Contacts.Depths=-0.6313+.15*(0:15);
+        subjectInfos.penInfos(22).dateTime='2016-04-20_13-29-49'; % PEN 310
+        subjectInfos.penInfos(22).V1Contacts.Depths=-1.5188+.15*(0:15);
+        subjectInfos.penInfos(22).V4Contacts.Depths=-0.7812+.15*(0:15);
+        subjectInfos.penInfos(23).dateTime='2016-04-20_16-25-45'; % PEN 311
+        % MAYBE BETTER ALIGNMENT FOR PEN 311
+        %subjectInfos.penInfos(23).V1Contacts.Depths=-1.0813+.15*(0:15);
+        subjectInfos.penInfos(23).V1Contacts.Depths=-1.4813+.15*(0:15);
+        subjectInfos.penInfos(23).V4Contacts.Depths=-0.1562+.15*(0:15);
+        subjectInfos.penInfos(24).dateTime='2016-04-21_11-39-33'; % PEN 312
+        subjectInfos.penInfos(24).V1Contacts.Depths=-1.2688+.15*(0:15);
+        subjectInfos.penInfos(24).V4Contacts.Depths=-0.8062+.15*(0:15);
+        subjectInfos.penInfos(25).dateTime='2016-04-21_11-44-38'; % PEN 313
+        % MAYBE BETTER ALIGNMENT FOR PEN 311
+        % subjectInfos.penInfos(25).V1Contacts.Depths=-1.1937+.15*(0:15);
+        subjectInfos.penInfos(25).V1Contacts.Depths=-1.3937+.15*(0:15);
+        subjectInfos.penInfos(25).V4Contacts.Depths=-0.5562+.15*(0:15);
+        subjectInfos.penInfos(26).dateTime='2016-04-18_21-06-04'; % PEN 314
+        subjectInfos.penInfos(26).V1Contacts.Depths=-1.7062+.15*(0:15);
+        subjectInfos.penInfos(26).V4Contacts.Depths=-0.6312+.15*(0:15);
+        subjectInfos.penInfos(27).dateTime='2016-04-18_16-48-16'; % PEN 315
+        subjectInfos.penInfos(27).V1Contacts.Depths=-1.5937+.15*(0:15);
+        subjectInfos.penInfos(27).V4Contacts.Depths=-0.7312+.15*(0:15);
+        subjectInfos.penInfos(28).dateTime='2016-04-11_10-56-56'; % PEN 316
+        subjectInfos.penInfos(28).V1Contacts.Depths=-1.7062+.15*(0:15);
+        subjectInfos.penInfos(28).V4Contacts.Depths=-0.7937+.15*(0:15);
+        subjectInfos.penInfos(29).dateTime='2016-04-06_15-12-45'; % PEN 317
+        subjectInfos.penInfos(29).V1Contacts.Depths=-1.1187+.15*(0:15);
+        subjectInfos.penInfos(29).V4Contacts.Depths=-0.8299+.15*(0:15);
+        subjectInfos.penInfos(30).dateTime='2016-04-11_12-42-31'; % PEN 318
+        subjectInfos.penInfos(30).V1Contacts.Depths=-0.6813+.15*(0:15);
+        subjectInfos.penInfos(30).V4Contacts.Depths=-1.5188+.15*(0:15);
+        subjectInfos.penInfos(31).dateTime='2016-04-12_18-18-03'; % PEN 319
+        subjectInfos.penInfos(31).V1Contacts.Depths=-1.2562+.15*(0:15);
+        subjectInfos.penInfos(31).V4Contacts.Depths=-0.5437+.15*(0:15);
+        subjectInfos.penInfos(32).dateTime='2016-04-19_16-44-44'; % PEN 320
+        subjectInfos.penInfos(32).V1Contacts.Depths=-1.7312+.15*(0:15);
+        subjectInfos.penInfos(32).V4Contacts.Depths=-1.0188+.15*(0:15);
+        subjectInfos.penInfos(33).dateTime='2016-04-20_12-32-04'; % PEN 321
+        % MAYBE BETTER ALIGNMENT FOR PEN 321
+        % subjectInfos.penInfos(33).V1Contacts.Depths=-1.5562+.15*(0:15);
+        subjectInfos.penInfos(33).V1Contacts.Depths=-1.7562+.15*(0:15);
+        subjectInfos.penInfos(33).V4Contacts.Depths=-1.0687+.15*(0:15);
+        subjectInfos.penInfos(34).dateTime='2016-04-21_11-22-21'; % PEN 322
+        subjectInfos.penInfos(34).V1Contacts.Depths=-1.4937+.15*(0:15);
+        subjectInfos.penInfos(34).V4Contacts.Depths=-0.8687+.15*(0:15);
+        subjectInfos.penInfos(35).dateTime='2016-04-21_12-50-47'; % PEN 323
+        % MAYBE BETTER ALIGNMENT FOR PEN 323
+        % subjectInfos.penInfos(35).V1Contacts.Depths=-0.8187+.15*(0:15);
+        subjectInfos.penInfos(35).V1Contacts.Depths=-1.6187+.15*(0:15);
+        subjectInfos.penInfos(35).V4Contacts.Depths=-1.0562+.15*(0:15);
+        
+        
+        %% DEFAULT FORMAT INITIALIZATION
+        for jj=1:length(subjectInfos.penIDs)
+            subjectInfos.penInfos(jj).penNum=subjectInfos.penIDs(jj);
+            subjectInfos.penInfos(jj).grcNum=subjectInfos.grcIDs(jj);
+            subjectInfos.penInfos(jj).V1Contacts.Channels=1:16;
+            subjectInfos.penInfos(jj).V4Contacts.Channels=17:32;
+            subjectInfos.penInfos(jj).V1Contacts.ChRejected=[];
+            subjectInfos.penInfos(jj).V1Contacts.ChSNRLowEq3=[];
+            subjectInfos.penInfos(jj).V4Contacts.ChRejected=[];
+            subjectInfos.penInfos(jj).V4Contacts.ChSNRLowEq3=[];
+            subjectInfos.penInfos(jj).V1Contacts.Quality='OK';
+            subjectInfos.penInfos(jj).V4Contacts.Quality='OK';
+            
+            %% ORIGINAL FILENAMES (DEPRECATED)
+            %subjectInfos.penInfos(jj).originalFilePaths.lfpFilePath=[startPath1 'wyman/pen' num2str(subjectInfos.penIDs(jj)) '/NLX_control/' subjectInfos.penInfos(jj).dateTime '/'];
+            %subjectInfos.penInfos(jj).originalFilePaths.ctxFileName=[startPath1 'wyman/pen' num2str(subjectInfos.penIDs(jj)) '/Cortex/' num2str(subjectInfos.ctxIDs(jj)) '/GRCJDRU1.' num2str(subjectInfos.grcIDs(jj))];
+            %subjectInfos.penInfos(jj).originalFilePaths.eventFileName=[subjectInfos.penInfos(jj).originalFilePaths.lfpFilePath 'Events.nev'];
+            %subjectInfos.penInfos(jj).originalFilePaths.cscFilePath=[startPath1 'wyman/pen' num2str(subjectInfos.penIDs(jj)) '/NLX_control/gratc/'];
+            
+            %% SELECTED TIME WINS FILE PATHS
+            subjectInfos.penInfos(jj).selectedTimeWinsFilePaths.V1Contacts.LFPs=[startPath 'M1 V1 - LFP/Wyman_V1_LFP_PEN' num2str(subjectInfos.penIDs(jj)) '_sorted.mat'];
+            subjectInfos.penInfos(jj).selectedTimeWinsFilePaths.V4Contacts.LFPs=[startPath 'M1 V4 - LFP/Wyman_V4_LFP_PEN' num2str(subjectInfos.penIDs(jj)) '_sorted.mat'];
+            
+            subjectInfos.penInfos(jj).selectedTimeWinsFilePaths.V1Contacts.MUAs=[startPath 'M1 V1 - MUA/Wyman_V1_MUA_PEN' num2str(subjectInfos.penIDs(jj)) '_sorted.mat'];
+            subjectInfos.penInfos(jj).selectedTimeWinsFilePaths.V4Contacts.MUAs=[startPath 'M1 V4 - MUA/Wyman_V4_MUA_PEN' num2str(subjectInfos.penIDs(jj)) '_sorted.mat'];
+            
+            %% LAMINAR LAYER LABELS ASSIGNMENT
+            if  ~isempty(subjectInfos.penInfos(jj).V1Contacts.Depths)
+                [~,minV1Ch]=min((subjectInfos.penInfos(jj).V1Contacts.Depths).^2);
+                subjectInfos.penInfos(jj).V1Contacts.LaminarAlignments=(1:16)-minV1Ch;
+            end
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers((subjectInfos.penInfos(jj).V1Contacts.Depths>1))={'TS'}; % TOO SUPERFICIAL
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V1Contacts.Depths>.25).*(subjectInfos.penInfos(jj).V1Contacts.Depths<=1)))={'S'};  % SUPRAGRANULAR
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V1Contacts.Depths>=-.25).*(subjectInfos.penInfos(jj).V1Contacts.Depths<=.25)))={'G'}; % GRANULAR
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V1Contacts.Depths>=-.75).*(subjectInfos.penInfos(jj).V1Contacts.Depths<-.25)))={'I'}; % INFRAGRANULAR
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers((subjectInfos.penInfos(jj).V1Contacts.Depths<-.75))={'TD'}; % TOO DEEP
+            subjectInfos.penInfos(jj).V1Contacts.SelectedChs=subjectInfos.penInfos(jj).V1Contacts.Channels;
+            
+            if  ~isempty(subjectInfos.penInfos(jj).V4Contacts.Depths)
+                [~,minV4Ch]=min((subjectInfos.penInfos(jj).V4Contacts.Depths).^2);
+                subjectInfos.penInfos(jj).V4Contacts.LaminarAlignments=(1:16)-minV4Ch;
+            end
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers((subjectInfos.penInfos(jj).V4Contacts.Depths>1))={'TS'}; % TOO SUPERFICIAL
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V4Contacts.Depths>.1).*(subjectInfos.penInfos(jj).V4Contacts.Depths<=1)))={'S'};  % SUPRAGRANULAR
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V4Contacts.Depths>=-.1).*(subjectInfos.penInfos(jj).V4Contacts.Depths<=.1)))={'G'}; % GRANULAR
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V4Contacts.Depths>=-.75).*(subjectInfos.penInfos(jj).V4Contacts.Depths<-.1)))={'I'}; % INFRAGRANULAR
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers((subjectInfos.penInfos(jj).V4Contacts.Depths<-.75))={'TD'}; % TOO DEEP
+            subjectInfos.penInfos(jj).V4Contacts.SelectedChs=subjectInfos.penInfos(jj).V4Contacts.Channels;
+        end
+        
+        %% COLOR ORDERS [RF, OUT1, OUT2]
+        subjectInfos.penInfos(1).grcColorOrder='BRG'; % PEN 288
+        subjectInfos.penInfos(2).grcColorOrder='RGB'; % PEN 289
+        subjectInfos.penInfos(3).grcColorOrder='RBG'; % PEN 290
+        subjectInfos.penInfos(4).grcColorOrder='GRB'; % PEN 291
+        subjectInfos.penInfos(5).grcColorOrder='GBR'; % PEN 292
+        subjectInfos.penInfos(6).grcColorOrder='BGR'; % PEN 293
+        subjectInfos.penInfos(7).grcColorOrder='BRG'; % PEN 295
+        subjectInfos.penInfos(8).grcColorOrder='RGB'; % PEN 296
+        subjectInfos.penInfos(9).grcColorOrder='RBG'; % PEN 297
+        subjectInfos.penInfos(10).grcColorOrder='GRB'; % PEN 298
+        subjectInfos.penInfos(11).grcColorOrder='GBR'; % PEN 299
+        subjectInfos.penInfos(12).grcColorOrder='BGR'; % PEN 300
+        subjectInfos.penInfos(13).grcColorOrder='BRG'; % PEN 301
+        subjectInfos.penInfos(14).grcColorOrder='RGB'; % PEN 302
+        subjectInfos.penInfos(15).grcColorOrder='RBG'; % PEN 303
+        subjectInfos.penInfos(16).grcColorOrder='GRB'; % PEN 304
+        subjectInfos.penInfos(17).grcColorOrder='GBR'; % PEN 305
+        subjectInfos.penInfos(18).grcColorOrder='BRG'; % PEN 306
+        subjectInfos.penInfos(19).grcColorOrder='RGB'; % PEN 307
+        subjectInfos.penInfos(20).grcColorOrder='RBG'; % PEN 308
+        subjectInfos.penInfos(21).grcColorOrder='GRB'; % PEN 309
+        subjectInfos.penInfos(22).grcColorOrder='BGR'; % PEN 310
+        subjectInfos.penInfos(23).grcColorOrder='BRG'; % PEN 311
+        subjectInfos.penInfos(24).grcColorOrder='RGB'; % PEN 312
+        subjectInfos.penInfos(25).grcColorOrder='RBG'; % PEN 313
+        subjectInfos.penInfos(26).grcColorOrder='GRB'; % PEN 314
+        subjectInfos.penInfos(27).grcColorOrder='GBR'; % PEN 315
+        subjectInfos.penInfos(28).grcColorOrder='BGR'; % PEN 316
+        subjectInfos.penInfos(29).grcColorOrder='BRG'; % PEN 317
+        subjectInfos.penInfos(30).grcColorOrder='RGB'; % PEN 318
+        subjectInfos.penInfos(31).grcColorOrder='RBG'; % PEN 319
+        subjectInfos.penInfos(32).grcColorOrder='GRB'; % PEN 320
+        subjectInfos.penInfos(33).grcColorOrder='GBR'; % PEN 321
+        subjectInfos.penInfos(34).grcColorOrder='BGR'; % PEN 322
+        subjectInfos.penInfos(35).grcColorOrder='BRG'; % PEN 323
+        
+        %% CHANNEL RE-ARRANGEMENT/REJECTION ISSUES
+        
+        subjectInfos.penInfos(1).V1Contacts.ChSNRLowEq3=[15,16]; % PEN 288
+        subjectInfos.penInfos(1).V4Contacts.ChSNRLowEq3=12;
+        subjectInfos.penInfos(2).V1Contacts.ChSNRLowEq3=16; % 289
+        subjectInfos.penInfos(2).V4Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(3).V1Contacts.ChSNRLowEq3=[1,15,16]; % 290
+        subjectInfos.penInfos(4).V1Contacts.Quality='BAD'; % PEN 291
+        subjectInfos.penInfos(4).V4Contacts.Quality='BAD';
+        subjectInfos.penInfos(4).V1Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(5).V1Contacts.ChRejected=3; % PEN 292
+        subjectInfos.penInfos(5).V1Contacts.ChSNRLowEq3=[1,2];
+        subjectInfos.penInfos(5).V1Contacts.Quality='BAD';
+        subjectInfos.penInfos(6).V1Contacts.ChSNRLowEq3=[1,2]; % PEN 293
+        subjectInfos.penInfos(7).V1Contacts.ChSNRLowEq3=[1,2,15]; % PEN 295
+        subjectInfos.penInfos(7).V4Contacts.ChSNRLowEq3=11;
+        subjectInfos.penInfos(8).V1Contacts.Quality='UNCERTAIN'; % PEN 296
+        subjectInfos.penInfos(8).V4Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(9).V1Contacts.ChRejected=7; % PEN 297
+        subjectInfos.penInfos(9).V1Contacts.Quality='BAD';
+        subjectInfos.penInfos(10).V1Contacts.Channels=[]; % PEN 298
+        subjectInfos.penInfos(10).V1Contacts.Quality='NO V1 DATA'; % PEN 298
+        subjectInfos.penInfos(10).V4Contacts.Quality='BAD'; 
+        subjectInfos.penInfos(10).V4Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(11).V4Contacts.ChSNRLowEq3=[14,15,16]; % PEN 299
+        subjectInfos.penInfos(12).V1Contacts.ChRejected=7; % PEN 300
+        subjectInfos.penInfos(12).V1Contacts.Quality='BAD';
+        subjectInfos.penInfos(12).V1Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(12).V4Contacts.ChSNRLowEq3=11;
+        subjectInfos.penInfos(13).V1Contacts.ChRejected=[7 11]; % PEN 301
+        subjectInfos.penInfos(13).V1Contacts.Quality='BAD';
+        subjectInfos.penInfos(13).V1Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(14).V1Contacts.ChRejected=7; % PEN 302
+        subjectInfos.penInfos(14).V1Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(14).V4Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(14).V1Contacts.Quality='BAD';
+        subjectInfos.penInfos(15).V4Contacts.Quality='BAD'; % PEN 303
+        subjectInfos.penInfos(15).V1Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(15).V4Contacts.ChRejected=11;
+        subjectInfos.penInfos(15).V4Contacts.ChSNRLowEq3=[2,5,8,9,12];
+        subjectInfos.penInfos(16).V4Contacts.Quality='UNCERTAIN'; % PEN 304
+        subjectInfos.penInfos(16).V1Contacts.ChSNRLowEq3=[6,15,16];
+        subjectInfos.penInfos(16).V4Contacts.ChSNRLowEq3=[2,12,14,15,16];
+        subjectInfos.penInfos(17).V1Contacts.ChRejected=[3 7]; % PEN 305
+        subjectInfos.penInfos(17).V1Contacts.Quality='BAD';
+        subjectInfos.penInfos(17).V4Contacts.Quality='BAD';
+        subjectInfos.penInfos(17).V1Contacts.ChSNRLowEq3=[1,15,16];
+        subjectInfos.penInfos(17).V4Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(18).V1Contacts.ChSNRLowEq3=[1,3,15,16]; % PEN 306
+        subjectInfos.penInfos(18).V4Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(19).V1Contacts.ChSNRLowEq3=[1,2,12,13,14,15,16]; % PEN 307
+        subjectInfos.penInfos(19).V4Contacts.ChSNRLowEq3=[14,15,16];
+        subjectInfos.penInfos(20).V1Contacts.ChSNRLowEq3=16; % PEN 308
+        subjectInfos.penInfos(20).V4Contacts.ChSNRLowEq3=[1,15,16];
+        subjectInfos.penInfos(21).V1Contacts.Quality='BAD'; % PEN 309
+        subjectInfos.penInfos(21).V4Contacts.Quality='BAD';
+        subjectInfos.penInfos(21).V1Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(21).V4Contacts.ChSNRLowEq3=[12,13,14,15,16];
+        subjectInfos.penInfos(22).V1Contacts.ChSNRLowEq3=[15,16]; % PEN 310
+        subjectInfos.penInfos(22).V4Contacts.ChSNRLowEq3=[10,12,14,15,16];
+        subjectInfos.penInfos(23).V1Contacts.ChSNRLowEq3=[1,16]; % PEN 311
+        subjectInfos.penInfos(23).V4Contacts.ChSNRLowEq3=[13,14,15,16];
+        subjectInfos.penInfos(24).V1Contacts.ChSNRLowEq3=[14,15,16]; % PEN 312
+        subjectInfos.penInfos(25).V1Contacts.ChSNRLowEq3=[2,3,14,15,16]; % PEN 313
+        subjectInfos.penInfos(25).V4Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(26).V1Contacts.ChSNRLowEq3=[11,16]; % PEN 314
+        subjectInfos.penInfos(26).V4Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(27).V1Contacts.Quality='UNCERTAIN'; % PEN 315
+        subjectInfos.penInfos(27).V1Contacts.ChSNRLowEq3=[1,2,4,9,10,13,14,15,16];
+        subjectInfos.penInfos(27).V4Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(28).V1Contacts.Quality='UNCERTAIN'; % PEN 316
+        subjectInfos.penInfos(28).V1Contacts.ChSNRLowEq3=[1,3,4,5,7,8,13,14,15,16];
+        subjectInfos.penInfos(28).V4Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(29).V4Contacts.ChRejected=10; % PEN 317
+        subjectInfos.penInfos(29).V1Contacts.ChSNRLowEq3=[2,4,15,16];
+        subjectInfos.penInfos(29).V4Contacts.ChSNRLowEq3=[14,15,16];
+        subjectInfos.penInfos(30).V1Contacts.Quality='BAD'; % PEN 318
+        subjectInfos.penInfos(30).V4Contacts.Quality='BAD';
+        subjectInfos.penInfos(30).V1Contacts.ChSNRLowEq3=[2,15,16];
+        subjectInfos.penInfos(30).V4Contacts.ChSNRLowEq3=[14,15,16];
+        subjectInfos.penInfos(31).V1Contacts.ChSNRLowEq3=16; % PEN 319
+        subjectInfos.penInfos(31).V4Contacts.ChSNRLowEq3=[8,15,16];
+        subjectInfos.penInfos(32).V1Contacts.ChSNRLowEq3=16; % PEN 320
+        subjectInfos.penInfos(32).V4Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(33).V1Contacts.ChSNRLowEq3=[1,16]; % PEN 321
+        subjectInfos.penInfos(34).V1Contacts.ChSNRLowEq3=[1,2,3,4,5,14,15,16]; % PEN 322
+        subjectInfos.penInfos(34).V4Contacts.ChSNRLowEq3=[6,7,10,11,15,16];
+        subjectInfos.penInfos(35).V1Contacts.ChSNRLowEq3=[1,16]; % PEN 323
+        subjectInfos.penInfos(35).V4Contacts.ChSNRLowEq3=16;
+        
+        for jj=1:length(subjectInfos.penIDs)
+            subjectInfos.penInfos(jj).V1Contacts.SelectedChs=subjectInfos.penInfos(jj).V1Contacts.Channels;
+            if ~isempty(subjectInfos.penInfos(jj).V1Contacts.SelectedChs)
+            subjectInfos.penInfos(jj).V1Contacts.SelectedChs(unique([find(subjectInfos.penInfos(jj).V1Contacts.Depths<=-.75 | subjectInfos.penInfos(jj).V1Contacts.Depths>=1) ...
+                subjectInfos.penInfos(jj).V1Contacts.ChSNRLowEq3 subjectInfos.penInfos(jj).V1Contacts.ChRejected]))=[];
+            end
+            subjectInfos.penInfos(jj).V4Contacts.SelectedChs=subjectInfos.penInfos(jj).V4Contacts.Channels;
+            if ~isempty(subjectInfos.penInfos(jj).V4Contacts.SelectedChs)
+            subjectInfos.penInfos(jj).V4Contacts.SelectedChs(unique([find(subjectInfos.penInfos(jj).V4Contacts.Depths<=-.75 | subjectInfos.penInfos(jj).V4Contacts.Depths>=1) ...
+                subjectInfos.penInfos(jj).V4Contacts.ChSNRLowEq3 subjectInfos.penInfos(jj).V4Contacts.ChRejected]))=[];
+            end
+        end
+        
+    case 'monkey 2'
+        
+        subjectInfos.subjectName='Taylor';
+        subjectInfos.penIDs=[1:12 14:33];
+        subjectInfos.grcIDs=[22 23 26 28 29 31:34 36 38 39 44 45 47 49 50 51 53:55 59 67 69:71 73 74 76:79];
+        subjectInfos.ctxIDs=[];
+        
+        %% DATE-TIME AND V1-V4 DEPTHS (Manually selected from CSDs)
+        subjectInfos.penInfos(1).dateTime='2017-08-10_17-51-02'; % PEN 1
+        subjectInfos.penInfos(1).V1Contacts.Depths=-0.8645+.15*(0:15);
+        subjectInfos.penInfos(1).V4Contacts.Depths=-1+.15*(0:15); % 
+        subjectInfos.penInfos(2).dateTime='2017-08-14_10-09-28'; % PEN 2
+        subjectInfos.penInfos(2).V1Contacts.Depths=-0.6852+.15*(0:15);
+        subjectInfos.penInfos(2).V4Contacts.Depths=[]; %  
+        subjectInfos.penInfos(3).dateTime='2017-08-16_16-36-23'; % PEN 3
+        subjectInfos.penInfos(3).V1Contacts.Depths=-1.0469+.15*(0:15);
+        subjectInfos.penInfos(3).V4Contacts.Depths=-0.0063+.15*(0:15); % 
+        subjectInfos.penInfos(4).dateTime='2017-08-16_16-44-49'; % PEN 4
+        subjectInfos.penInfos(4).V1Contacts.Depths=[]; 
+        subjectInfos.penInfos(4).V4Contacts.Depths=-0.1438+.15*(0:15); % 
+        subjectInfos.penInfos(5).dateTime='2017-08-16_18-21-16'; % PEN 5
+        subjectInfos.penInfos(5).V1Contacts.Depths=-0.93281+.15*(0:15);
+        subjectInfos.penInfos(5).V4Contacts.Depths=-0.3062+.15*(0:15); % 
+        subjectInfos.penInfos(6).dateTime='2017-08-17_12-05-00'; % PEN 6
+        subjectInfos.penInfos(6).V1Contacts.Depths=-1.0453+.15*(0:15);
+        subjectInfos.penInfos(6).V4Contacts.Depths=-0.6062+.15*(0:15); % 
+        subjectInfos.penInfos(7).dateTime='2017-08-23_12-28-24'; % PEN 7 
+        subjectInfos.penInfos(7).V1Contacts.Depths=-1.1496+.15*(0:15);
+        subjectInfos.penInfos(7).V4Contacts.Depths=-0.7187+.15*(0:15); % 
+        subjectInfos.penInfos(8).dateTime='2017-08-17_12-51-15'; % PEN 8
+        subjectInfos.penInfos(8).V1Contacts.Depths=-0.59102+.15*(0:15);
+        subjectInfos.penInfos(8).V4Contacts.Depths=-0.5937+.15*(0:15); % 
+        subjectInfos.penInfos(9).dateTime='2017-08-23_12-40-01'; % PEN 9
+        subjectInfos.penInfos(9).V1Contacts.Depths=-1.0293+.15*(0:15);
+        subjectInfos.penInfos(9).V4Contacts.Depths=-0.7562+.15*(0:15); % 
+        subjectInfos.penInfos(10).dateTime='2017-09-07_13-30-24'; % PEN 10
+        subjectInfos.penInfos(10).V1Contacts.Depths=-0.98906+.15*(0:15);
+        subjectInfos.penInfos(10).V4Contacts.Depths=-0.5562+.15*(0:15); % 
+        subjectInfos.penInfos(11).dateTime='2017-08-25_10-20-16'; % PEN 11
+        subjectInfos.penInfos(11).V1Contacts.Depths=-1.5711+.15*(0:15);
+        subjectInfos.penInfos(11).V4Contacts.Depths=-1.2063+.15*(0:15); % 
+        subjectInfos.penInfos(12).dateTime='2017-08-25_09-37-10'; % PEN 12
+        subjectInfos.penInfos(12).V1Contacts.Depths=-1.068+.15*(0:15);
+        subjectInfos.penInfos(12).V4Contacts.Depths=-0.6062+.15*(0:15); % 
+        subjectInfos.penInfos(13).dateTime='2017-08-29_13-42-45'; % PEN 14
+        subjectInfos.penInfos(13).V1Contacts.Depths=-1.2867+.15*(0:15);
+        subjectInfos.penInfos(13).V4Contacts.Depths=-0.7687+.15*(0:15); % 
+        subjectInfos.penInfos(14).dateTime='2017-08-31_10-58-27'; % PEN 15
+        subjectInfos.penInfos(14).V1Contacts.Depths=-1.3305+.15*(0:15);
+        subjectInfos.penInfos(14).V4Contacts.Depths=-0.9312+.15*(0:15); % 
+        subjectInfos.penInfos(15).dateTime='2017-09-07_14-09-17'; % PEN 16
+        subjectInfos.penInfos(15).V1Contacts.Depths=-1.0676+.15*(0:15);
+        subjectInfos.penInfos(15).V4Contacts.Depths=-0.9312+.15*(0:15); % 
+        subjectInfos.penInfos(16).dateTime='2017-09-07_14-07-34'; % PEN 17
+        subjectInfos.penInfos(16).V1Contacts.Depths=-1.0168+.15*(0:15);
+        subjectInfos.penInfos(16).V4Contacts.Depths=-0.9062+.15*(0:15); % 
+        subjectInfos.penInfos(17).dateTime='2017-08-03_14-38-16'; % PEN 18
+        subjectInfos.penInfos(17).V1Contacts.Depths=-1.1496+.15*(0:15);
+        subjectInfos.penInfos(17).V4Contacts.Depths=-0.1687+.15*(0:15); % 
+        subjectInfos.penInfos(18).dateTime='2017-08-04_14-25-44'; % PEN 19
+        subjectInfos.penInfos(18).V1Contacts.Depths=-1.057+.15*(0:15);
+        subjectInfos.penInfos(18).V4Contacts.Depths=-0.8879+.15*(0:15); % 
+        subjectInfos.penInfos(19).dateTime='2017-08-15_16-05-20'; % PEN 20
+        subjectInfos.penInfos(19).V1Contacts.Depths=-1.0066+.15*(0:15); 
+        subjectInfos.penInfos(19).V4Contacts.Depths=-0.8937+.15*(0:15); % 
+        subjectInfos.penInfos(20).dateTime='2017-08-16_17-52-11'; % PEN 21
+        subjectInfos.penInfos(20).V1Contacts.Depths=-1.027+.15*(0:15);
+        subjectInfos.penInfos(20).V4Contacts.Depths=-1.0562+.15*(0:15); % 
+        subjectInfos.penInfos(21).dateTime='2017-08-17_14-31-50'; % PEN 22
+        subjectInfos.penInfos(21).V1Contacts.Depths=-0.70273+.15*(0:15);
+        subjectInfos.penInfos(21).V4Contacts.Depths=-0.7312+.15*(0:15); % 
+        subjectInfos.penInfos(22).dateTime='2017-08-25_09-44-38'; % PEN 23
+        subjectInfos.penInfos(22).V1Contacts.Depths=[];
+        subjectInfos.penInfos(22).V4Contacts.Depths=-0.4563+.15*(0:15); % 
+        subjectInfos.penInfos(23).dateTime='2017-09-19_16-04-07'; % PEN 24
+        subjectInfos.penInfos(23).V1Contacts.Depths=-1.0473+.15*(0:15);
+        subjectInfos.penInfos(23).V4Contacts.Depths=-0.9062+.15*(0:15); % 
+        subjectInfos.penInfos(24).dateTime='2017-09-25_13-18-58'; % PEN 25
+        subjectInfos.penInfos(24).V1Contacts.Depths=-0.8832+.15*(0:15);
+        subjectInfos.penInfos(24).V4Contacts.Depths=-0.9312+.15*(0:15); %  
+        subjectInfos.penInfos(25).dateTime='2017-09-21_17-57-59'; % PEN 26
+        subjectInfos.penInfos(25).V1Contacts.Depths=-1.243+.15*(0:15);
+        subjectInfos.penInfos(25).V4Contacts.Depths=-1.0437+.15*(0:15); %  
+        subjectInfos.penInfos(26).dateTime='2017-09-22_17-19-04'; % PEN 27
+        subjectInfos.penInfos(26).V1Contacts.Depths=-1.0574+.15*(0:15);
+        subjectInfos.penInfos(26).V4Contacts.Depths=-1.1812+.15*(0:15); %  
+        subjectInfos.penInfos(27).dateTime='2017-10-09_12-02-05'; % PEN 28
+        subjectInfos.penInfos(27).V1Contacts.Depths=-1.2539+.15*(0:15);
+        subjectInfos.penInfos(27).V4Contacts.Depths=-1.1812+.15*(0:15); %  
+        subjectInfos.penInfos(28).dateTime='2017-10-02_12-56-39'; % PEN 29
+        subjectInfos.penInfos(28).V1Contacts.Depths=-1.0879+.15*(0:15);
+        subjectInfos.penInfos(28).V4Contacts.Depths=-1.0312+.15*(0:15); %  
+        subjectInfos.penInfos(29).dateTime='2017-10-03_15-36-18'; % PEN 30
+        subjectInfos.penInfos(29).V1Contacts.Depths=-1.3723+.15*(0:15);
+        subjectInfos.penInfos(29).V4Contacts.Depths=-1.1812+.15*(0:15); %  
+        subjectInfos.penInfos(30).dateTime='2017-10-04_16-57-23'; % PEN 31
+        subjectInfos.penInfos(30).V1Contacts.Depths=-0.84844+.15*(0:15);
+        subjectInfos.penInfos(30).V4Contacts.Depths=-1.1812+.15*(0:15); %  
+        subjectInfos.penInfos(31).dateTime='2017-10-05_16-29-41'; % PEN 32
+        subjectInfos.penInfos(31).V1Contacts.Depths=-1.2082+.15*(0:15);
+        subjectInfos.penInfos(31).V4Contacts.Depths=-1.1812+.15*(0:15); %  
+        subjectInfos.penInfos(32).dateTime='2017-10-06_17-02-05'; % PEN 33
+        subjectInfos.penInfos(32).V1Contacts.Depths=-1.1555+.15*(0:15);
+        subjectInfos.penInfos(32).V4Contacts.Depths=-1.2187+.15*(0:15); %  
+        
+    
+        %% DEFAULT FORMAT INITIALIZATION
+        for jj=1:length(subjectInfos.penIDs)
+            subjectInfos.penInfos(jj).penNum=subjectInfos.penIDs(jj);
+            subjectInfos.penInfos(jj).grcNum=subjectInfos.grcIDs(jj);
+            subjectInfos.penInfos(jj).V1Contacts.Channels=1:16;
+            subjectInfos.penInfos(jj).V4Contacts.Channels=17:32;
+            subjectInfos.penInfos(jj).V1Contacts.ChRejected=[];
+            subjectInfos.penInfos(jj).V1Contacts.ChSNRLowEq3=[];
+            subjectInfos.penInfos(jj).V4Contacts.ChRejected=[];
+            subjectInfos.penInfos(jj).V4Contacts.ChSNRLowEq3=[];
+            subjectInfos.penInfos(jj).V1Contacts.Quality='OK';
+            subjectInfos.penInfos(jj).V4Contacts.Quality='OK';
+            
+            %% ORIGINAL FILENAMES (DEPRECATED)
+            %subjectInfos.penInfos(jj).originalFilePaths.lfpFilePath=[startPath1(1:end-28) 'Taylor/PEN' num2str(subjectInfos.penIDs(jj)) '/NLX_control/' subjectInfos.penInfos(jj).dateTime '/'];
+            %subjectInfos.penInfos(jj).originalFilePaths.ctxFileName=[startPath1(1:end-28) 'Taylor/PEN' num2str(subjectInfos.penIDs(jj)) '/Cortex/GRCJDRU1.' num2str(subjectInfos.grcIDs(jj))];
+            %subjectInfos.penInfos(jj).originalFilePaths.eventFileName=[subjectInfos.penInfos(jj).originalFilePaths.lfpFilePath 'Events.nev'];
+            %subjectInfos.penInfos(jj).originalFilePaths.cscFilePath=subjectInfos.penInfos(jj).originalFilePaths.lfpFilePath;
+            
+            %% SELECTED TIME WINS FILE PATHS
+            subjectInfos.penInfos(jj).selectedTimeWinsFilePaths.V1Contacts.LFPs=[startPath 'M2 V1 - LFP/Taylor_V1_LFP_PEN' num2str(subjectInfos.penIDs(jj)) '_sorted.mat'];
+            subjectInfos.penInfos(jj).selectedTimeWinsFilePaths.V4Contacts.LFPs=[startPath 'M2 V4 - LFP/Taylor_V4_LFP_PEN' num2str(subjectInfos.penIDs(jj)) '_sorted.mat'];
+            
+            subjectInfos.penInfos(jj).selectedTimeWinsFilePaths.V1Contacts.MUAs=[startPath 'M2 V1 - MUA/Taylor_V1_MUA_PEN' num2str(subjectInfos.penIDs(jj)) '_sorted.mat'];
+            subjectInfos.penInfos(jj).selectedTimeWinsFilePaths.V4Contacts.MUAs=[startPath 'M2 V4 - MUA/Taylor_V4_MUA_PEN' num2str(subjectInfos.penIDs(jj)) '_sorted.mat'];
+            
+            %% LAMINAR LAYER LABELS ASSIGNMENT
+            if  ~isempty(subjectInfos.penInfos(jj).V1Contacts.Depths)
+                [~,minV1Ch]=min((subjectInfos.penInfos(jj).V1Contacts.Depths).^2);
+                subjectInfos.penInfos(jj).V1Contacts.LaminarAlignments=(1:16)-minV1Ch;
+            end
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers((subjectInfos.penInfos(jj).V1Contacts.Depths>1))={'TS'}; % TOO SUPERFICIAL
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V1Contacts.Depths>.25).*(subjectInfos.penInfos(jj).V1Contacts.Depths<=1)))={'S'};  % SUPRAGRANULAR
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V1Contacts.Depths>=-.25).*(subjectInfos.penInfos(jj).V1Contacts.Depths<=.25)))={'G'}; % GRANULAR
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V1Contacts.Depths>=-.75).*(subjectInfos.penInfos(jj).V1Contacts.Depths<-.25)))={'I'}; % INFRAGRANULAR
+            subjectInfos.penInfos(jj).V1Contacts.LaminarLayers((subjectInfos.penInfos(jj).V1Contacts.Depths<-.75))={'TD'}; % TOO DEEP
+            
+            if  ~isempty(subjectInfos.penInfos(jj).V4Contacts.Depths)
+                [~,minV4Ch]=min((subjectInfos.penInfos(jj).V4Contacts.Depths).^2);
+                subjectInfos.penInfos(jj).V4Contacts.LaminarAlignments=(1:16)-minV4Ch;
+            end
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers((subjectInfos.penInfos(jj).V4Contacts.Depths>1))={'TS'}; % TOO SUPERFICIAL
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V4Contacts.Depths>.1).*(subjectInfos.penInfos(jj).V4Contacts.Depths<=1)))={'S'};  % SUPRAGRANULAR
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V4Contacts.Depths>=-.1).*(subjectInfos.penInfos(jj).V4Contacts.Depths<=.1)))={'G'}; % GRANULAR
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers(logical((subjectInfos.penInfos(jj).V4Contacts.Depths>=-.75).*(subjectInfos.penInfos(jj).V4Contacts.Depths<-.1)))={'I'}; % INFRAGRANULAR
+            subjectInfos.penInfos(jj).V4Contacts.LaminarLayers((subjectInfos.penInfos(jj).V4Contacts.Depths<-.75))={'TD'}; % TOO DEEP
+            
+        end
+        
+        
+                %% COLOR ORDERS [RF, OUT1, OUT2]
+        subjectInfos.penInfos(1).grcColorOrder='RBG'; % PEN 1
+        subjectInfos.penInfos(2).grcColorOrder='GRB'; % PEN 2
+        subjectInfos.penInfos(3).grcColorOrder='GBR'; % PEN 3
+        subjectInfos.penInfos(4).grcColorOrder='BRG'; % PEN 4
+        subjectInfos.penInfos(5).grcColorOrder='BGR'; % PEN 5
+        subjectInfos.penInfos(6).grcColorOrder='RGB'; % PEN 6
+        subjectInfos.penInfos(7).grcColorOrder='RBG'; % PEN 7
+        subjectInfos.penInfos(8).grcColorOrder='GRB'; % PEN 8
+        subjectInfos.penInfos(9).grcColorOrder='GBR'; % PEN 9
+        subjectInfos.penInfos(10).grcColorOrder='BRG'; % PEN 10
+        subjectInfos.penInfos(11).grcColorOrder='BGR'; % PEN 11
+        subjectInfos.penInfos(12).grcColorOrder='RGB'; % PEN 12
+        subjectInfos.penInfos(13).grcColorOrder='GRB'; % PEN 14
+        subjectInfos.penInfos(14).grcColorOrder='GBR'; % PEN 15
+        subjectInfos.penInfos(15).grcColorOrder='BRG'; % PEN 16
+        subjectInfos.penInfos(16).grcColorOrder='BGR'; % PEN 17
+        subjectInfos.penInfos(17).grcColorOrder='RGB'; % PEN 18
+        subjectInfos.penInfos(18).grcColorOrder='RBG'; % PEN 19
+        subjectInfos.penInfos(19).grcColorOrder='GRB'; % PEN 20
+        subjectInfos.penInfos(20).grcColorOrder='GBR'; % PEN 21
+        subjectInfos.penInfos(21).grcColorOrder='BRG'; % PEN 22
+        subjectInfos.penInfos(22).grcColorOrder='BGR'; % PEN 23
+        subjectInfos.penInfos(23).grcColorOrder='RGB'; % PEN 24
+        subjectInfos.penInfos(24).grcColorOrder='RBG'; % PEN 25
+        subjectInfos.penInfos(25).grcColorOrder='GRB'; % PEN 26
+        subjectInfos.penInfos(26).grcColorOrder='GBR'; % PEN 27
+        subjectInfos.penInfos(27).grcColorOrder='BRG'; % PEN 28
+        subjectInfos.penInfos(28).grcColorOrder='BGR'; % PEN 29
+        subjectInfos.penInfos(29).grcColorOrder='RGB'; % PEN 30
+        subjectInfos.penInfos(30).grcColorOrder='RBG'; % PEN 31
+        subjectInfos.penInfos(31).grcColorOrder='GRB'; % PEN 32
+        subjectInfos.penInfos(32).grcColorOrder='GBR'; % PEN 33
+        
+        %% CHANNEL RE-ARRANGEMENT/REJECTION ISSUES
+        
+        subjectInfos.penInfos(1).V1Contacts.Quality='UNCERTAIN'; % PEN 1
+        subjectInfos.penInfos(1).V4Contacts.Quality='BAD';
+        subjectInfos.penInfos(1).V1Contacts.ChSNRLowEq3=14:16;
+        subjectInfos.penInfos(1).V4Contacts.ChSNRLowEq3=1:16;
+        subjectInfos.penInfos(2).V4Contacts.Quality='NO V4 DATA'; % PEN 2
+        subjectInfos.penInfos(2).V4Contacts.Channels=[];
+        subjectInfos.penInfos(2).V1Contacts.ChSNRLowEq3=[15,16];
+        subjectInfos.penInfos(3).V4Contacts.Quality='UNCERTAIN'; % PEN 3
+        subjectInfos.penInfos(3).V1Contacts.ChSNRLowEq3=[1:4 13:16];
+        subjectInfos.penInfos(3).V4Contacts.ChSNRLowEq3=[13,14,15,16];
+        subjectInfos.penInfos(4).V1Contacts.Quality='NO V1 DATA'; % PEN 4
+        subjectInfos.penInfos(4).V1Contacts.Channels=[];
+        subjectInfos.penInfos(4).V4Contacts.ChSNRLowEq3=[14,15,16];
+        subjectInfos.penInfos(5).V1Contacts.ChSNRLowEq3=13:16; % PEN 5
+        subjectInfos.penInfos(5).V4Contacts.ChSNRLowEq3=9:16;
+        subjectInfos.penInfos(6).V1Contacts.ChSNRLowEq3=[1 2 15 16]; % PEN 6
+        subjectInfos.penInfos(6).V4Contacts.ChSNRLowEq3=14:16;
+        subjectInfos.penInfos(7).V1Contacts.Quality='UNCERTAIN'; % PEN 7
+        subjectInfos.penInfos(7).V1Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(7).V4Contacts.ChSNRLowEq3=14:16;
+        subjectInfos.penInfos(8).V1Contacts.Quality='BAD'; % PEN 8
+        subjectInfos.penInfos(8).V1Contacts.ChSNRLowEq3=12:16;
+        subjectInfos.penInfos(8).V4Contacts.ChSNRLowEq3=12:16;
+        subjectInfos.penInfos(9).V1Contacts.ChSNRLowEq3=12:16; % PEN 9
+        subjectInfos.penInfos(9).V4Contacts.ChSNRLowEq3=12:16;
+        subjectInfos.penInfos(10).V1Contacts.Quality='UNCERTAIN'; % PEN 10
+        subjectInfos.penInfos(10).V1Contacts.ChSNRLowEq3=13:16;
+        subjectInfos.penInfos(10).V4Contacts.Quality='UNCERTAIN';
+        subjectInfos.penInfos(10).V4Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(11).V1Contacts.Quality='UNCERTAIN'; % PEN 11
+        subjectInfos.penInfos(11).V1Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(11).V4Contacts.Quality='UNCERTAIN';
+        subjectInfos.penInfos(11).V4Contacts.ChSNRLowEq3=13:16;
+        subjectInfos.penInfos(12).V1Contacts.ChSNRLowEq3=15:16; % PEN 12
+        subjectInfos.penInfos(12).V4Contacts.ChSNRLowEq3=13:16;
+        subjectInfos.penInfos(13).V1Contacts.Quality='UNCERTAIN'; % PEN 14
+        subjectInfos.penInfos(13).V1Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(13).V4Contacts.ChSNRLowEq3=13:16;
+        subjectInfos.penInfos(14).V1Contacts.ChSNRLowEq3=15:16; % PEN 15
+        subjectInfos.penInfos(14).V4Contacts.ChSNRLowEq3=12:16;
+        subjectInfos.penInfos(15).V1Contacts.ChSNRLowEq3=16; % PEN 16
+        subjectInfos.penInfos(15).V4Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(16).V1Contacts.ChSNRLowEq3=14:16; % PEN 17
+        subjectInfos.penInfos(16).V4Contacts.ChSNRLowEq3=13:16;
+        subjectInfos.penInfos(17).V4Contacts.Quality='UNCERTAIN'; % PEN 18
+        subjectInfos.penInfos(17).V1Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(17).V4Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(18).V4Contacts.Quality='BAD'; % PEN 19
+        subjectInfos.penInfos(18).V4Contacts.ChRejected=1:3;
+        subjectInfos.penInfos(18).V1Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(18).V4Contacts.ChSNRLowEq3=13:16;
+        subjectInfos.penInfos(19).V1Contacts.ChSNRLowEq3=14:16; % PEN 20
+        subjectInfos.penInfos(19).V4Contacts.ChSNRLowEq3=13:16;
+        subjectInfos.penInfos(20).V1Contacts.ChSNRLowEq3=14:16; % PEN 21
+        subjectInfos.penInfos(20).V4Contacts.ChSNRLowEq3=14:16;
+        subjectInfos.penInfos(21).V1Contacts.Quality='UNCERTAIN'; % PEN 22
+        subjectInfos.penInfos(21).V1Contacts.ChSNRLowEq3=12:16;
+        subjectInfos.penInfos(21).V4Contacts.ChSNRLowEq3=14:16;
+        subjectInfos.penInfos(22).V1Contacts.Quality='NO V1 DATA'; % PEN 23
+        subjectInfos.penInfos(22).V1Contacts.Channels=[];
+        subjectInfos.penInfos(22).V4Contacts.ChSNRLowEq3=14:16;
+        subjectInfos.penInfos(23).V1Contacts.Quality='UNCERTAIN'; % PEN 24
+        subjectInfos.penInfos(23).V1Contacts.ChSNRLowEq3=14:16;
+        subjectInfos.penInfos(23).V4Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(24).V1Contacts.ChSNRLowEq3=12:16; % PEN 25
+        subjectInfos.penInfos(24).V4Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(25).V1Contacts.ChSNRLowEq3=15:16; % PEN 26
+        subjectInfos.penInfos(25).V4Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(26).V4Contacts.Quality='UNCERTAIN'; % PEN 27
+        subjectInfos.penInfos(26).V1Contacts.ChSNRLowEq3=14:16;
+        subjectInfos.penInfos(26).V4Contacts.ChSNRLowEq3=11:16;
+        subjectInfos.penInfos(27).V4Contacts.Quality='BAD'; % PEN 28
+        subjectInfos.penInfos(27).V1Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(27).V4Contacts.ChSNRLowEq3=12:16;
+        subjectInfos.penInfos(28).V4Contacts.Quality='UNCERTAIN'; % PEN 29
+        subjectInfos.penInfos(28).V1Contacts.ChSNRLowEq3=14:16;
+        subjectInfos.penInfos(28).V4Contacts.ChSNRLowEq3=12:16;
+        subjectInfos.penInfos(29).V4Contacts.Quality='BAD'; % PEN 30
+        subjectInfos.penInfos(29).V1Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(29).V4Contacts.ChSNRLowEq3=11:16;
+        subjectInfos.penInfos(30).V4Contacts.Quality='BAD'; % PEN 31
+        subjectInfos.penInfos(30).V1Contacts.ChSNRLowEq3=13:16;
+        subjectInfos.penInfos(30).V4Contacts.ChSNRLowEq3=12:16;
+        subjectInfos.penInfos(31).V1Contacts.Quality='UNCERTAIN'; % PEN 32
+        subjectInfos.penInfos(31).V1Contacts.ChSNRLowEq3=16;
+        subjectInfos.penInfos(31).V4Contacts.Quality='BAD';
+        subjectInfos.penInfos(31).V4Contacts.ChSNRLowEq3=12:16;
+        subjectInfos.penInfos(32).V1Contacts.Quality='UNCERTAIN'; % PEN 33
+        subjectInfos.penInfos(32).V1Contacts.ChSNRLowEq3=15:16;
+        subjectInfos.penInfos(32).V4Contacts.Quality='BAD';
+        subjectInfos.penInfos(32).V4Contacts.ChSNRLowEq3=[10,12:16];
+        
+        for jj=1:length(subjectInfos.penIDs)
+            subjectInfos.penInfos(jj).V1Contacts.SelectedChs=subjectInfos.penInfos(jj).V1Contacts.Channels;
+            if ~isempty(subjectInfos.penInfos(jj).V1Contacts.SelectedChs)
+            subjectInfos.penInfos(jj).V1Contacts.SelectedChs(unique([find(subjectInfos.penInfos(jj).V1Contacts.Depths<=-.75 | subjectInfos.penInfos(jj).V1Contacts.Depths>=1) ...
+                subjectInfos.penInfos(jj).V1Contacts.ChSNRLowEq3 subjectInfos.penInfos(jj).V1Contacts.ChRejected]))=[];
+            end
+            subjectInfos.penInfos(jj).V4Contacts.SelectedChs=subjectInfos.penInfos(jj).V4Contacts.Channels;
+            if ~isempty(subjectInfos.penInfos(jj).V4Contacts.SelectedChs)
+            subjectInfos.penInfos(jj).V4Contacts.SelectedChs(unique([find(subjectInfos.penInfos(jj).V4Contacts.Depths<=-.75 | subjectInfos.penInfos(jj).V4Contacts.Depths>=1) ...
+                subjectInfos.penInfos(jj).V4Contacts.ChSNRLowEq3 subjectInfos.penInfos(jj).V4Contacts.ChRejected]))=[];
+            end
+        end
+    otherwise
+        error(['The Selected Subject name "' sSubjectName '" is not valid.']);
+end
+
+end

+ 963 - 0
Code/processSpectralPower.m

@@ -0,0 +1,963 @@
+addpath('./support_routines');
+addpath(genpath('./support_tools'));
+
+clear all; close all; clc;
+
+sSubjectName='monkey 2';
+sVisualArea='V4';
+subjectInfos=getSubjectInfos(sSubjectName);
+subjectData=getSubjectData(sSubjectName,sVisualArea,'ALL','LFPs','ALL');
+
+SAMPLING_FREQ=1017.38;
+NUM_TIME_SAMPLES=512;
+NUM_FREQ_SAMPLES=NUM_TIME_SAMPLES/2+1;
+
+timeAxisPostCue=linspace(0,NUM_TIME_SAMPLES/SAMPLING_FREQ,NUM_TIME_SAMPLES);
+timeAxisPreStim=linspace(-NUM_TIME_SAMPLES/SAMPLING_FREQ,0,NUM_TIME_SAMPLES);
+
+lamLayerTag={'Supra','Granr','Infra'};
+gratCondTag={'RF','OUT1','OUT2'};
+spectWinTag={'Full'};
+
+plotPmtsSinglePens=0;
+plotPmtsPenAvg=0;
+plotPmtsPenAvgOutMean=1;
+plotPmtsPenAvgColorCoded=0;
+
+
+for reportPmtMinusMean=1%0:1 
+    % reportPmtMinusMean allows to choose how to apply baseline normalization 
+    % 0 reports (Pmt) ./ (MeanPmtbaseline) 
+    % 1 reports (Pmt - MeanPmtbaseline)./(stdPmtbaseline)
+    
+    %% compute Pmts
+    paramsMT=[];
+    paramsMT.Fs=SAMPLING_FREQ;
+    paramsMT.tapers = [2 3];
+    paramsMt.pad = 0;
+    [~,freqAxisPreStim] = mtspectrumc(timeAxisPreStim*1e-3, paramsMT);
+    [~,freqAxisPostCue] = mtspectrumc(timeAxisPostCue*1e-3, paramsMT);
+    
+    pr=1;
+    for pp=1:length(subjectData.penIDs) % LOOP OVER PENS
+        if ~isempty(subjectData.LfpStruct(pp).Sorted)
+            for bb=1%:4 % LOOP OVER SPECTRAL WINS
+                for ll=1:3 % LOOP OVER LAMINAR LAYERS
+                    for cnd=1:3 % LOOP OVER GRAT CONDITIONS
+                        if bb==1
+                            currLFPsPreStim=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreStimDataBi(:,:,end-NUM_TIME_SAMPLES+1:end);
+                            currLFPsPostStim=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostStimDataBi(:,:,1:NUM_TIME_SAMPLES);
+                            currLFPsStationary=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).StationaryDataBi(:,:,1:NUM_TIME_SAMPLES);
+                            currLFPsPostCue=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostCueDataBi(:,:,1:NUM_TIME_SAMPLES);
+                            currLFPsPreFirstDim=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreFirstDimDataBi(:,:,end-NUM_TIME_SAMPLES+1:end);
+                            
+                            % SELECT GRATCONDS 2, 3, 4, 5, 9, 11, 15, 17, 20, 21, 22, 23, 27, 29, 33, 35
+                            if ~isempty(subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimDataBi)
+                                currNumTrials2=length(subjectData.LfpStruct(pp).Sorted.Full.(lamLayerTag{ll}).(gratCondTag{cnd}).gratCondSecondDim);
+                                currCorrectSecondDimTrials=find(arrayfun(@(jj) any([2 3 4 5 20 21 22 23 9 11 15 17 27 29 33 35]==subjectData.LfpStruct(pp).Sorted.Full.(lamLayerTag{ll}).(gratCondTag{cnd}).gratCondSecondDim(jj)), 1:currNumTrials2));
+                                currLFPsPreSecondDim=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimDataBi(:,currCorrectSecondDimTrials,end-NUM_TIME_SAMPLES+1:end);
+                            else
+                                currLFPsPreSecondDim=[];
+                            end
+                            
+                            % PROBABLY TO FIX FOR THIRD DIM
+                            if ~isempty(subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimDataBi)
+                                currNumTrials3=length(subjectData.LfpStruct(pp).Sorted.Full.(lamLayerTag{ll}).(gratCondTag{cnd}).gratCondThirdDim);
+                                currCorrectThirdDimTrials=find(arrayfun(@(jj) any([2 3 4 5 20 21 22 23 9 11 15 17 27 29 33 35]==subjectData.LfpStruct(pp).Sorted.Full.(lamLayerTag{ll}).(gratCondTag{cnd}).gratCondThirdDim(jj)), 1:currNumTrials3));
+                                currLFPsPreThirdDim=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimDataBi(:,currCorrectThirdDimTrials,end-NUM_TIME_SAMPLES+1:end);
+                            else
+                                currLFPsPreThirdDim=[];
+                            end
+                            
+                            currNumChs=size(currLFPsPreStim,1);  currNumTrials=size(currLFPsPreFirstDim,2);
+                            currNumTrials2=size(currLFPsPreSecondDim,2); currNumTrials3=size(currLFPsPreThirdDim,2);
+                        else
+                            currLFPsPostStimZSc=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostStimDataBiZSc(:,:,1:NUM_TIME_SAMPLES);
+                            currLFPsStationaryZSc=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).StationaryDataBiZSc(:,:,1:NUM_TIME_SAMPLES);
+                            currLFPsPostCueZSc=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostCueDataBiZSc(:,:,1:NUM_TIME_SAMPLES);
+                            currLFPsPreFirstDimZSc=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreFirstDimDataBiZSc(:,:,end-NUM_TIME_SAMPLES+1:end);
+                            
+                            % SELECT GRATCONDS 2, 3, 4, 5, 9, 11, 15, 17, 20, 21, 22, 23, 27, 29, 33, 35
+                            if ~isempty(subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimDataBiZSc)
+                                currNumTrials2=length(subjectData.LfpStruct(pp).Sorted.Full.(lamLayerTag{ll}).(gratCondTag{cnd}).gratCondSecondDim);
+                                currCorrectSecondDimTrials=find(arrayfun(@(jj) any([2 3 4 5 20 21 22 23 9 11 15 17 27 29 33 35]==subjectData.LfpStruct(pp).Sorted.Full.(lamLayerTag{ll}).(gratCondTag{cnd}).gratCondSecondDim(jj)), 1:currNumTrials2));
+                                currLFPsPreSecondDimZSc=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimDataBiZSc(:,currCorrectSecondDimTrials,end-NUM_TIME_SAMPLES+1:end);
+                            else
+                                currLFPsPreSecondDimZSc=[];
+                            end
+                            
+                            % PROBABLY TO FIX FOR THIRD DIM
+                            if ~isempty(subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimDataBiZSc)
+                                currNumTrials3=length(subjectData.LfpStruct(pp).Sorted.Full.(lamLayerTag{ll}).(gratCondTag{cnd}).gratCondThirdDim);
+                                currCorrectThirdDimTrials=find(arrayfun(@(jj) any([2 3 4 5 20 21 22 23 9 11 15 17 27 29 33 35]==subjectData.LfpStruct(pp).Sorted.Full.(lamLayerTag{ll}).(gratCondTag{cnd}).gratCondThirdDim(jj)), 1:currNumTrials3));
+                                currLFPsPreThirdDimZSc=subjectData.LfpStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimDataBiZSc(:,currCorrectThirdDimTrials,end-NUM_TIME_SAMPLES+1:end);
+                            else
+                                currLFPsPreThirdDimZSc=[];
+                            end
+                            
+                            currNumChs=size(currLFPsPreFirstDimZSc,1);  currNumTrials=size(currLFPsPreFirstDimZSc,2);
+                            currNumTrials2=size(currLFPsPreSecondDimZSc,2); currNumTrials3=size(currLFPsPreThirdDimZSc,2);
+                        end
+                        currPmtPrSt=nan(currNumChs,currNumTrials,NUM_FREQ_SAMPLES);
+                        currPmtPsSt=nan(currNumChs,currNumTrials,NUM_FREQ_SAMPLES);
+                        currPmtStat=nan(currNumChs,currNumTrials,NUM_FREQ_SAMPLES);
+                        currPmtPsCu=nan(currNumChs,currNumTrials,NUM_FREQ_SAMPLES);
+                        currPmtPFDm=nan(currNumChs,currNumTrials,NUM_FREQ_SAMPLES);
+                        
+                        currPmtPostStimZSc=nan(currNumChs,currNumTrials,NUM_FREQ_SAMPLES);
+                        currPmtStationaryZSc=nan(currNumChs,currNumTrials,NUM_FREQ_SAMPLES);
+                        currPmtPostCueZSc=nan(currNumChs,currNumTrials,NUM_FREQ_SAMPLES);
+                        currPmtPreFirstDimZSc=nan(currNumChs,currNumTrials,NUM_FREQ_SAMPLES);
+                        currPmtPreSecondDimZSc=nan(currNumChs,currNumTrials2,NUM_FREQ_SAMPLES);
+                        currPmtPreThirdDimZSc=nan(currNumChs,currNumTrials3,NUM_FREQ_SAMPLES);
+                        
+                        for ch=1:currNumChs
+                            if bb==1
+                                % FULL BAND CASE: Pmt of LFPs ZScored in frequency domain
+                                currPmtPreStim=mtspectrumc(squeeze(currLFPsPreStim(ch,:,:))',paramsMT)';
+                                currPmtPostStim=mtspectrumc(squeeze(currLFPsPostStim(ch,:,:))',paramsMT)';
+                                currPmtStationary=mtspectrumc(squeeze(currLFPsStationary(ch,:,:))',paramsMT)';
+                                currPmtPostCue=mtspectrumc(squeeze(currLFPsPostCue(ch,:,:))',paramsMT)';
+                                currPmtPreFirstDim=mtspectrumc(squeeze(currLFPsPreFirstDim(ch,:,:))',paramsMT)';
+                                currPmtPreSecondDim=mtspectrumc(squeeze(currLFPsPreSecondDim(ch,:,:))',paramsMT)';
+                                currPmtPreThirdDim=mtspectrumc(squeeze(currLFPsPreThirdDim(ch,:,:))',paramsMT)';
+                                currPmtPreStimRepMean=repmat(nanmean(currPmtPreStim,1),currNumTrials,1);
+                                currPmtPreStimRepStd=repmat(nanstd(currPmtPreStim,[],1),currNumTrials,1);
+                                
+                                %TRY ALSO
+                                % data=iddata(y,[],Ts)cw
+                                % Py=spa(data,winsize,freq)
+                                
+                                if reportPmtMinusMean
+                                    currPmtPostStimZSc(ch,:,:)=(currPmtPostStim-currPmtPreStimRepMean)./(currPmtPreStimRepStd+eps);
+                                    currPmtStationaryZSc(ch,:,:)=(currPmtStationary-currPmtPreStimRepMean)./(currPmtPreStimRepStd+eps);
+                                    currPmtPostCueZSc(ch,:,:)=(currPmtPostCue-currPmtPreStimRepMean)./(currPmtPreStimRepStd+eps);
+                                    currPmtPreFirstDimZSc(ch,:,:)=(currPmtPreFirstDim-currPmtPreStimRepMean)./(currPmtPreStimRepStd+eps);
+                                    currPmtPreSecondDimZSc(ch,:,:)=(currPmtPreSecondDim-currPmtPreStimRepMean(1:currNumTrials2,:))./(currPmtPreStimRepStd(1:currNumTrials2,:)+eps);
+                                    currPmtPreThirdDimZSc(ch,:,:)=(currPmtPreThirdDim-currPmtPreStimRepMean(1:currNumTrials3,:))./(currPmtPreStimRepStd(1:currNumTrials3,:)+eps);
+                                else
+                                    currPmtPostStimZSc(ch,:,:)=(currPmtPostStim)./(currPmtPreStimRepMean+eps);
+                                    currPmtStationaryZSc(ch,:,:)=(currPmtStationary)./(currPmtPreStimRepMean+eps);
+                                    currPmtPostCueZSc(ch,:,:)=(currPmtPostCue)./(currPmtPreStimRepMean+eps);
+                                    currPmtPreFirstDimZSc(ch,:,:)=(currPmtPreFirstDim)./(currPmtPreStimRepMean+eps);
+                                    currPmtPreSecondDimZSc(ch,:,:)=(currPmtPreSecondDim(1:currNumTrials2,:))./(currPmtPreStimRepMean(1:currNumTrials2,:)+eps);
+                                    currPmtPreThirdDimZSc(ch,:,:)=(currPmtPreThirdDim(1:currNumTrials3,:))./(currPmtPreStimRepMean(1:currNumTrials3,:)+eps);
+                                end
+                                currPmtPrSt(ch,:,:)=currPmtPreStim;
+                                currPmtPsSt(ch,:,:)=currPmtPostStim;
+                                currPmtStat(ch,:,:)=currPmtStationary;
+                                currPmtPsCu(ch,:,:)=currPmtPostCue;
+                                currPmtPFDm(ch,:,:)=currPmtPreFirstDim;
+                                
+                            else
+                                % ALPHA, BETA, GAMMA BAND CASES: Pmt of LFPs ZScored in time domain
+                                currPmtPostStimZSc(ch,:,:)=mtspectrumc(squeeze(currLFPsPostStimZSc(ch,:,:))',paramsMT)';
+                                currPmtStationaryZSc(ch,:,:)=mtspectrumc(squeeze(currLFPsStationaryZSc(ch,:,:))',paramsMT)';
+                                currPmtPostCueZSc(ch,:,:)=mtspectrumc(squeeze(currLFPsPostCueZSc(ch,:,:))',paramsMT)';
+                                currPmtPreFirstDimZSc(ch,:,:)=mtspectrumc(squeeze(currLFPsPreFirstDimZSc(ch,:,:))',paramsMT)';
+                                currPmtPreSecondDimZSc(ch,:,:)=mtspectrumc(squeeze(currLFPsPreSecondDimZSc(ch,:,:))',paramsMT)';
+                                currPmtPreThirdDimZSc(ch,:,:)=mtspectrumc(squeeze(currLFPsPreThirdDimZSc(ch,:,:))',paramsMT)';
+                            end
+                        end
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostStimZSc=permute(nanmean(currPmtPostStimZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).StationaryZSc=permute(nanmean(currPmtStationaryZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostCueZSc=permute(nanmean(currPmtPostCueZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreFirstDimZSc=permute(nanmean(currPmtPreFirstDimZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimZSc=permute(nanmean(currPmtPreSecondDimZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimZSc=permute(nanmean(currPmtPreThirdDimZSc,2),[1 3 2]);
+                        
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PrStim=permute(nanmean(currPmtPrSt,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PsStim=permute(nanmean(currPmtPsSt,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).Statry=permute(nanmean(currPmtStat,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PstCue=permute(nanmean(currPmtPsCu,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PrFDim=permute(nanmean(currPmtPFDm,2),[1 3 2]);
+                                                
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(subjectData.penInfos(pp).grcColorOrder).PostStimZSc=permute(nanmean(currPmtPostStimZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(subjectData.penInfos(pp).grcColorOrder).StationaryZSc=permute(nanmean(currPmtStationaryZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(subjectData.penInfos(pp).grcColorOrder).PostCueZSc=permute(nanmean(currPmtPostCueZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(subjectData.penInfos(pp).grcColorOrder).PreFirstDimZSc=permute(nanmean(currPmtPreFirstDimZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(subjectData.penInfos(pp).grcColorOrder).PreSecondDimZSc=permute(nanmean(currPmtPreSecondDimZSc,2),[1 3 2]);
+                        PmtStruct(pr).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(subjectData.penInfos(pp).grcColorOrder).PreThirdDimZSc=permute(nanmean(currPmtPreThirdDimZSc,2),[1 3 2]);
+                        clear -regexp ^curr % saves memory at runtime
+                    end
+                end
+            end
+            pr=pr+1;
+        end
+    end
+    
+    
+    %% PLOT SINGLE PENs
+    if plotPmtsSinglePens
+        rgbCmap=eye(3);
+        timeWinTag={'PostStim','Stationary','PostCue','PreFirstDim','PreSecondDim','PreThirdDim'};
+        close all
+        
+        for pp=1:length(subjectData.penIDs) % LOOP OVER PENS
+            for bb=1%:4 % LOOP OVER SPECTRAL WINS
+                hfig=figure('units','normalized','outerposition',[0 0 1 1]);
+                yaxislim=0;
+                for tt=1:6
+                    for ll=1:3 % LOOP OVER LAMINAR LAYERS
+                        subplot(3,6,(ll-1)*6+tt)
+                        for cnd=1:3 % LOOP OVER GRAT CONDITIONS
+                            plotcmapdots(rgbCmap);
+                            plotmsem(freqAxisPostCue,PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).([timeWinTag{tt} 'ZSc']),rgbCmap(cnd,:)); hold on;
+                            title([timeWinTag{tt} ' - ' lamLayerTag{ll} ' Layer']);
+                            yaxislim=max([yaxislim; max(nanmean(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).([timeWinTag{tt} 'ZSc']),1))]);
+                            if bb==1
+                                xlim([0 128]);  ylim([-1 10]);
+                                ylabel('Z-Scored Power');
+                            elseif bb==2
+                                xlim([0 20]);  %ylim([0 0.05]);
+                                ylabel('Spectral Power');
+                            elseif bb==3
+                                xlim([10 35]); %ylim([0 0.05*2/3]);
+                                ylabel('Spectral Power');
+                            elseif bb==4
+                                xlim([20 100]);  %ylim([0 0.05/3]);
+                                ylabel('Spectral Power');
+                            end
+                            xlabel('Frequency [Hz]');
+                        end
+                    end
+                end
+                if bb>1
+                    for yl=1:18;   subplot(3,6,yl); ylim([0 yaxislim+0.002]);  end
+                else
+                    for yl=1:18;   subplot(3,6,yl); ylim([-1 yaxislim+1]);  end
+                end
+                legend('Attend RF','Attend OUT1','Attend OUT2');
+                supertitle([sSubjectName ' ' sVisualArea ' - PEN ' num2str(subjectData.penIDs(pp)) ' - LFPs Spectral Power ' spectWinTag{bb} ' Band']);
+                %saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/SinglePens' sSubjectName(1) sVisualArea '-PEN' num2str(subjectData.penIDs(pp)) '-Pmt-' spectWinTag{bb} '.fig']);
+                %saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/SinglePens/' sSubjectName(1) sVisualArea '-PEN' num2str(subjectData.penIDs(pp)) '-Pmt-' spectWinTag{bb} '.png']);
+            end
+            close all
+        end
+    end
+    
+    %% POOL CHANNELS ACROSS PENs
+    
+    for bb=1%:4
+        for ll=1:3
+            for cnd=1:3
+                currPmtPostStimZSc=[];
+                currPmtStationaryZSc=[];
+                currPmtPostCueZSc=[];
+                currPmtPreFirstDimZSc=[];
+                currPmtPreSecondDimZSc=[];
+                currPmtPreThirdDimZSc=[];
+                
+                currPmtPreStim=[];
+                currPmtPostStim=[];
+                currPmtStationary=[];
+                currPmtPostCue=[];
+                currPmtPreFirstDim=[];
+                
+                for pp=1:length(PmtStruct)
+                    %currSz=size(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreFirstDimZSc);
+                    %currSz2=size(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimZSc);
+                    %currSz3=size(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimZSc);
+                    currPmtPreStim=      [currPmtPreStim;         PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PrStim];
+                    currPmtPostStim=     [currPmtPostStim;        PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PsStim];
+                    currPmtStationary=   [currPmtStationary;      PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).Statry];
+                    currPmtPostCue=      [currPmtPostCue;         PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PstCue];
+                    currPmtPreFirstDim=  [currPmtPreFirstDim;     PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PrFDim];
+                    
+                    currPmtPostStimZSc=     [currPmtPostStimZSc;        PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostStimZSc];
+                    currPmtStationaryZSc=   [currPmtStationaryZSc;      PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).StationaryZSc];
+                    currPmtPostCueZSc=      [currPmtPostCueZSc;         PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostCueZSc];
+                    currPmtPreFirstDimZSc=  [currPmtPreFirstDimZSc;     PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreFirstDimZSc];
+                    currPmtPreSecondDimZSc= [currPmtPreSecondDimZSc;    PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimZSc];
+                    currPmtPreThirdDimZSc=  [currPmtPreThirdDimZSc;     PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimZSc];
+                end
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostStimZSc=currPmtPostStimZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).StationaryZSc=currPmtStationaryZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PostCueZSc=currPmtPostCueZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreFirstDimZSc=currPmtPreFirstDimZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimZSc=currPmtPreSecondDimZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimZSc=currPmtPreThirdDimZSc;
+                
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PrStim=currPmtPreStim;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PsStim=currPmtPostStim;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).Statry=currPmtStationary;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PstCue=currPmtPostCue;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PrFDim=currPmtPreFirstDim;
+                
+                clear -regexp ^curr % saves memory at runtime
+            end
+        end
+    end
+    
+%    save(['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PowSpectsAllTimeWins.mat' ],'PoolPmtStruct')
+%     %% SAME AS ABOVE BUT RF COLOR-SPECIFIC
+%     grcColorLabel={'RGB','GRB','BGR'};
+%     f
+%     %penColorsRFlabels={};
+%     %penColorsRFlabnum=nan(1,length(PmtStruct));
+%     %for pp=1:length(PmtStruct)
+%     %    penColorsRF{pp}=subjectInfos.penInfos(pp).grcColorOrder(1);
+%     %    penColorsRFlabnum(pp)=strcmpi(subjectInfos.penInfos(pp).grcColorOrder(1),'R')+...
+%     %                          strcmpi(subjectInfos.penInfos(pp).grcColorOrder(1),'G')*2+...
+%     %                          strcmpi(subjectInfos.penInfos(pp).grcColorOrder(1),'B')*3;
+%     %end
+%     
+%     for bb=1%:4
+%         for ll=1:3
+%             for cnd=1:3
+%                 for grc=1:3
+%                 currPmtPostStimZSc=[];
+%                 currPmtStationaryZSc=[];
+%                 currPmtPostCueZSc=[];
+%                 currPmtPreFirstDimZSc=[];
+%                 currPmtPreSecondDimZSc=[];
+%                 currPmtPreThirdDimZSc=[];
+%                 for pp=1:length(PmtStruct)
+%                     %if strcmpi(subjectData.penInfos(pp).grcColorOrder(1),grcColorLabel{grc})
+%                     %currSz=size(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreFirstDimZSc);
+%                     %currSz2=size(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimZSc);
+%                     %currSz3=size(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimZSc);
+%                     if isfield(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}),grcColorLabel{grc})
+%                     currPmtPostStimZSc=[currPmtPostStimZSc; PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PostStimZSc];
+%                     currPmtStationaryZSc=[currPmtStationaryZSc; PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).StationaryZSc];
+%                     currPmtPostCueZSc=[currPmtPostCueZSc; PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PostCueZSc];
+%                     currPmtPreFirstDimZSc=[currPmtPreFirstDimZSc; PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PreFirstDimZSc];
+%                     currPmtPreSecondDimZSc=[currPmtPreSecondDimZSc; PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PreSecondDimZSc];
+%                     currPmtPreThirdDimZSc=[currPmtPreThirdDimZSc; PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PreThirdDimZSc];
+%                     end
+%                 end
+%                 PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PostStimZSc=currPmtPostStimZSc;
+%                 PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).StationaryZSc=currPmtStationaryZSc;
+%                 PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PostCueZSc=currPmtPostCueZSc;
+%                 PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PreFirstDimZSc=currPmtPreFirstDimZSc;
+%                 PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PreSecondDimZSc=currPmtPreSecondDimZSc;
+%                 PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel{grc}).PreThirdDimZSc=currPmtPreThirdDimZSc;
+%                 
+%                 clear -regexp ^curr % saves memory at runtime
+%                 end
+%             end
+%         end
+%     end
+%     
+%     clearvars curr*
+
+
+
+
+
+
+    
+    %% SAME AS ABOVE BUT COLOR-SPECIFIC
+    
+    grcColorLabel3={'RGB','RBG','GRB','GBR','BRG','BGR'};
+    
+    for bb=1%:4
+        for ll=1:3
+            for cnd=1:3
+                for grc=1:6%3
+                currPmtPostStimZSc=[];
+                currPmtStationaryZSc=[];
+                currPmtPostCueZSc=[];
+                currPmtPreFirstDimZSc=[];
+                currPmtPreSecondDimZSc=[];
+                currPmtPreThirdDimZSc=[];
+                for pp=1:length(PmtStruct)
+                    %if strcmpi(subjectData.penInfos(pp).grcColorOrder,grcColorLabel3{grc})
+                       %strcmpi(subjectInfos.penInfos(pp).grcColorOrder(1),grcColorLabel{grc})
+                    %currSz=size(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreFirstDimZSc);
+                    %currSz2=size(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreSecondDimZSc);
+                    %currSz3=size(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).PreThirdDimZSc);
+                    if isfield(PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}),grcColorLabel3{grc})
+                    currPmtPostStimZSc=     [currPmtPostStimZSc;        PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PostStimZSc];
+                    currPmtStationaryZSc=   [currPmtStationaryZSc;      PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).StationaryZSc];
+                    currPmtPostCueZSc=      [currPmtPostCueZSc;         PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PostCueZSc];
+                    currPmtPreFirstDimZSc=  [currPmtPreFirstDimZSc;     PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PreFirstDimZSc];
+                    currPmtPreSecondDimZSc= [currPmtPreSecondDimZSc;    PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PreSecondDimZSc];
+                    currPmtPreThirdDimZSc=  [currPmtPreThirdDimZSc;     PmtStruct(pp).Sorted.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PreThirdDimZSc];
+                    end
+                end
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PostStimZSc=currPmtPostStimZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).StationaryZSc=currPmtStationaryZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PostCueZSc=currPmtPostCueZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PreFirstDimZSc=currPmtPreFirstDimZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PreSecondDimZSc=currPmtPreSecondDimZSc;
+                PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{grc}).PreThirdDimZSc=currPmtPreThirdDimZSc;
+                
+                clear -regexp ^curr % saves memory at runtime
+                end
+            end
+        end
+    end
+    
+    
+    clearvars curr*
+    
+    %% PLOT MEAN ACROSS PENS
+    if plotPmtsPenAvg
+        timeWinTag={'PostStim','Stationary','PostCue','PreFirstDim','PreSecondDim','PreThirdDim'};
+        rgbCmap=eye(3);
+        close all
+        for bb=1%:4
+            hfig=figure('units','normalized','outerposition',[0 0 1 1]);
+            for tt=1:6
+                for ll=1:3
+                    currSpectPowRF=PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.([timeWinTag{tt} 'ZSc']);
+                    currSpectPowOUT=nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.([timeWinTag{tt} 'ZSc']),...
+                        PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.([timeWinTag{tt} 'ZSc'])),4);
+                    numPooledChs=size(currSpectPowRF,1);
+                    subplot(3,6,(ll-1)*6+tt);
+                    plotcmapdots([eye(3); .5 .5 .5]);
+                    if reportPmtMinusMean
+                        plot(freqAxisPostCue,zeros(1,length(freqAxisPostCue)),'k');
+                    end
+                    for cnd=1:(1+2*double(tt<6)) % Pre3rdDim is just RF
+                        plotmsem(freqAxisPostCue,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).([timeWinTag{tt} 'ZSc']),rgbCmap(cnd,:)); hold on;
+                    end
+                    title([timeWinTag{tt} ' - ' lamLayerTag{ll} ' Layer']);
+                    if bb==1
+                        xlim([0 100]);
+                        if strcmp(sVisualArea,'V1')
+                            if reportPmtMinusMean
+                                ylim([-1 8]);
+                            else
+                                ylim([0 8]);
+                            end
+                        else
+                            if reportPmtMinusMean
+                                ylim([-1 2.5]);
+                            else
+                                ylim([0 2.5]);
+                            end
+                        end
+                    elseif bb==2
+                        xlim([0 20]);  ylim([0 0.025]);
+                        ylabel('Spectral Power');
+                    elseif bb==3
+                        xlim([10 35]); ylim([0 0.015]);
+                        ylabel('Spectral Power');
+                    elseif bb==4
+                        xlim([20 100]);  ylim([0 0.006]);
+                        ylabel('Spectral Power');
+                    end
+                    if ll==3; xlabel('Frequency [Hz]'); end;
+                    if tt==1; ylabel('Baseline-Normalized Power');
+                        if strcmp(sVisualArea,'V1')
+                            text(3,7.5,['n=' num2str(numPooledChs) ';']);
+                        else
+                            text(3,2.3,['n=' num2str(numPooledChs) ';']);
+                        end
+                    end
+                    if tt<6
+                        freqIndices2Plot=find(freqAxisPostCue<=100);
+                        pValuesVec=nan(1,length(freqIndices2Plot));
+                        for ff=1:length(freqIndices2Plot)
+                            pValuesVec(ff)=signrank(currSpectPowRF(:,ff),currSpectPowOUT(:,ff));
+                        end
+                        [~,~,~,pValuesVecFDR]=fdr_bh(pValuesVec);
+                        pValuesBar05FDR=nan(1,length(freqIndices2Plot));
+                        if reportPmtMinusMean
+                            pValuesBar05FDR(pValuesVecFDR<=.05)=-1;
+                        else
+                            pValuesBar05FDR(pValuesVecFDR<=.05)=0;
+                        end
+                        plot(freqAxisPostCue(freqIndices2Plot),pValuesBar05FDR,'color',[.5 .5 .5],'linewidth',2.5);
+                    end
+                    set(gca,'XTick',0:20:100);%set(gca,'XTickLabel',{'0','10','20','30','40','50','60','70','80','90','100'});
+                end
+            end
+            legend('RF','OUT1','OUT2','p\leq 0.05');
+            supertitle([sSubjectName ' ' sVisualArea ' - Avg across PENs - LFPs Spectral Power ' spectWinTag{bb} ' Band']);
+            
+            %if reportPmtMinusMean
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.png']);
+            %else
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.png']);
+            %end
+       end
+    end
+    
+    %%
+    %% PLOT MEAN ACROSS PENS OUT=OUT1/2+OUT2/2
+    if plotPmtsPenAvgOutMean
+        timeWinTag={'PostStim','Stationary','PostCue','PreFirstDim','PreSecondDim','PreThirdDim'};
+        rgbCmap=eye(3);
+        close all
+        for bb=1%:4
+            hfig=figure('units','normalized','outerposition',[0 0 1 1]);
+            for tt=1:6
+                for ll=1:3
+                    currSpectPowRF=PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.([timeWinTag{tt} 'ZSc']);
+                    currSpectPowOUT=nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.([timeWinTag{tt} 'ZSc']),...
+                        PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.([timeWinTag{tt} 'ZSc'])),4);
+                    numPooledChs=size(currSpectPowRF,1);
+                    subplot(3,6,(ll-1)*6+tt);
+                    plotcmapdots([1 0 0; 0 0 1; .5 .5 .5]);
+                    if reportPmtMinusMean
+                        plot(freqAxisPostCue,zeros(1,length(freqAxisPostCue)),'k');
+                    end
+                    plotmsem(freqAxisPostCue,currSpectPowRF,'r');
+                    if tt<6
+                        plotmsem(freqAxisPostCue,currSpectPowOUT,'b');
+                    end
+                    %for cnd=1:(1+2*double(tt<6)) % Pre3rdDim is just RF
+                    %    plotmsem(freqAxisPostCue,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).([timeWinTag{tt} 'ZSc']),rgbCmap(cnd,:)); hold on;
+                    %end
+                    title([timeWinTag{tt} ' - ' lamLayerTag{ll} ' Layer']);
+                    if bb==1
+                        xlim([0 100]);
+                        if strcmp(sVisualArea,'V1')
+                            if reportPmtMinusMean
+                                ylim([-1 8]);
+                            else
+                                ylim([0 8]);
+                            end
+                        else
+                            if reportPmtMinusMean
+                                ylim([-1 2.5]);
+                            else
+                                ylim([0 2.5]);
+                            end
+                        end
+                    elseif bb==2
+                        xlim([0 20]);  ylim([0 0.025]);
+                        ylabel('Spectral Power');
+                    elseif bb==3
+                        xlim([10 35]); ylim([0 0.015]);
+                        ylabel('Spectral Power');
+                    elseif bb==4
+                        xlim([20 100]);  ylim([0 0.006]);
+                        ylabel('Spectral Power');
+                    end
+                    if ll==3; xlabel('Frequency [Hz]'); end;
+                    if tt==1; ylabel('Baseline-Normalized Power');
+                        if strcmp(sVisualArea,'V1')
+                            text(3,7.5,['n=' num2str(numPooledChs) ';']);
+                        else
+                            text(3,2.3,['n=' num2str(numPooledChs) ';']);
+                        end
+                    end
+                    if tt<6
+                        freqIndices2Plot=find(freqAxisPostCue<=100);
+                        pValuesVec=nan(1,length(freqIndices2Plot));
+                        for ff=1:length(freqIndices2Plot)
+                            pValuesVec(ff)=signrank(currSpectPowRF(:,ff),currSpectPowOUT(:,ff));
+                        end
+                        [~,~,~,pValuesVecFDR]=fdr_bh(pValuesVec);
+                        pValuesBar05FDR=nan(1,length(freqIndices2Plot));
+                        if reportPmtMinusMean
+                            pValuesBar05FDR(pValuesVecFDR<=.05)=-1;
+                        else
+                            pValuesBar05FDR(pValuesVecFDR<=.05)=0;
+                        end
+                        plot(freqAxisPostCue(freqIndices2Plot),pValuesBar05FDR,'color',[0 0 0],'linewidth',2.5);
+                    end
+                    set(gca,'XTick',0:20:100);%set(gca,'XTickLabel',{'0','10','20','30','40','50','60','70','80','90','100'});
+                end
+            end
+            legend('RF','OUT','p\leq 0.05');
+            supertitle([sSubjectName ' ' sVisualArea ' - Avg across PENs - LFPs Spectral Power ' spectWinTag{bb} ' Band']);
+            
+            if reportPmtMinusMean
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg_OUT-Pmt-MinusMean-' spectWinTag{bb} '.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg_OUT-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg_OUT-Pmt-MinusMean-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.png']);
+            else
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.png']);
+            end
+       end
+    end
+    
+    
+        %% PLOT MEAN ACROSS PENS OVERLAY FIRST DIM OUT=OUT1/2+OUT2/2, OVERLAYED PREFIRSTDIM
+    if plotPmtsPenAvgOutMean
+        timeWinTag={'PostStim','Stationary','PostCue','PreFirstDim','PreSecondDim','PreThirdDim'};
+        rgbCmap=eye(3);
+        for bb=1%:4
+            hfig=figure('units','normalized','outerposition',[0 0 1 1]);
+            for tt=1:3%6
+                for ll=1:3
+                    currSpectPowRF=PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.([timeWinTag{tt} 'ZSc']);
+                    currSpectPowOUT=nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.([timeWinTag{tt} 'ZSc']),...
+                        PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.([timeWinTag{tt} 'ZSc'])),4);
+                    numPooledChs=size(currSpectPowRF,1);
+                    subplot(3,3,(ll-1)*3+tt);
+                    plotcmapdots([1 0 0; 0 0 1; .5 .5 .5]);
+                    if reportPmtMinusMean
+                        plot(freqAxisPostCue,zeros(1,length(freqAxisPostCue)),'k');
+                    end
+                    plotmsem(freqAxisPostCue,currSpectPowRF,'r');
+                    if tt<6
+                        plotmsem(freqAxisPostCue,currSpectPowOUT,'b');
+                    end
+                    currSpectPowPFDRF=PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.PreFirstDimZSc;
+                    currSpectPowPFDOUT=nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.PreFirstDimZSc,...
+                        PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.PreFirstDimZSc),4);
+                    
+                    plotmsem(freqAxisPostCue,currSpectPowPFDRF,'r:');
+                    plotmsem(freqAxisPostCue,currSpectPowPFDOUT,'b:');
+                    
+                    %for cnd=1:(1+2*double(tt<6)) % Pre3rdDim is just RF
+                    %    plotmsem(freqAxisPostCue,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).([timeWinTag{tt} 'ZSc']),rgbCmap(cnd,:)); hold on;
+                    %end
+                    title([timeWinTag{tt} ' - ' lamLayerTag{ll} ' Layer']);
+                    if bb==1
+                        xlim([0 100]);
+                        if strcmp(sVisualArea,'V1')
+                            if reportPmtMinusMean
+                                if strcmpi(sSubjectName,'Wyman')
+                                ylim([-1 8]);
+                                else
+                                    ylim([-.5 4]);
+                                end
+                            else
+                                ylim([0 8]);
+                            end
+                        else
+                            if reportPmtMinusMean
+                                ylim([-1 2.5]);
+                            else
+                                ylim([0 2.5]);
+                            end
+                        end
+                    elseif bb==2
+                        xlim([0 20]);  ylim([0 0.025]);
+                        ylabel('Spectral Power');
+                    elseif bb==3
+                        xlim([10 35]); ylim([0 0.015]);
+                        ylabel('Spectral Power');
+                    elseif bb==4
+                        xlim([20 100]);  ylim([0 0.006]);
+                        ylabel('Spectral Power');
+                    end
+                    if ll==3; xlabel('Frequency [Hz]'); end;
+                    if tt==1; ylabel('Baseline-Normalized Power');
+                        if strcmp(sVisualArea,'V1')
+                            if strcmpi(sSubjectName,'Wyman')
+                            text(3,7.5,['n=' num2str(numPooledChs) ';']);
+                            else
+                            text(3,3.5,['n=' num2str(numPooledChs) ';']);
+                            end
+                        else
+                            text(3,2.3,['n=' num2str(numPooledChs) ';']);
+                        end
+                    end
+                    if tt<6
+                        freqIndices2Plot=find(freqAxisPostCue<=100);
+                        pValuesVec=nan(1,length(freqIndices2Plot));
+                        for ff=1:length(freqIndices2Plot)
+                            pValuesVec(ff)=signrank(currSpectPowRF(:,ff),currSpectPowOUT(:,ff));
+                        end
+                        [~,~,~,pValuesVecFDR]=fdr_bh(pValuesVec);
+                        pValuesBar05FDR=nan(1,length(freqIndices2Plot));
+                        if reportPmtMinusMean
+                            pValuesBar05FDR(pValuesVecFDR<=.05)=-1;
+                        else
+                            pValuesBar05FDR(pValuesVecFDR<=.05)=0;
+                        end
+                        plot(freqAxisPostCue(freqIndices2Plot),pValuesBar05FDR,'color',[0 0 0],'linewidth',2.5);
+                    end
+                    set(gca,'XTick',0:20:100);%set(gca,'XTickLabel',{'0','10','20','30','40','50','60','70','80','90','100'});
+                end
+            end
+            legend('RF','OUT','p\leq 0.05');
+            supertitle([sSubjectName ' ' sVisualArea ' - Avg across PENs - LFPs Spectral Power ' spectWinTag{bb} ' Band']);
+            
+            %if reportPmtMinusMean
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg_OUT-Pmt-MinusMean-' spectWinTag{bb} '.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg_OUT-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg_OUT-Pmt-MinusMean-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.png']);
+            %else
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.png']);
+            %end
+       end
+    end
+    
+    
+    %% PLOT MEAN ACROSS PENS FIRST DIM OUT=OUT1/2+OUT2/2, LAYERS POOLED, OVERLAY PREFIRSTDIM/POSTSTIM
+    if plotPmtsPenAvgOutMean
+        timeWinTag={'PostStim','Stationary','PostCue','PreFirstDim','PreSecondDim','PreThirdDim'};
+        rgbCmap=eye(3);
+        for bb=1%:4
+            hfig=figure('units','normalized','outerposition',[0 0 1 1]);
+            for tt=2%1:3%6
+                %for ll=1:3
+                    currSpectPowRF=[PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{1}).RF.([timeWinTag{tt} 'ZSc']);...
+                                    PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{2}).RF.([timeWinTag{tt} 'ZSc']);...
+                                    PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{3}).RF.([timeWinTag{tt} 'ZSc'])];
+                    currSpectPowOUT=[nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{1}).OUT1.([timeWinTag{tt} 'ZSc']),...
+                                                   PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{1}).OUT2.([timeWinTag{tt} 'ZSc'])),4);
+                                     nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{2}).OUT1.([timeWinTag{tt} 'ZSc']),...
+                                                   PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{2}).OUT2.([timeWinTag{tt} 'ZSc'])),4);
+                                     nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{3}).OUT1.([timeWinTag{tt} 'ZSc']),...
+                                                   PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{3}).OUT2.([timeWinTag{tt} 'ZSc'])),4)];
+                    numPooledChs=size(currSpectPowRF,1);
+                    %subplot(3,6,(ll-1)*6+tt);
+                    %plotcmapdots([1 0 0; 0 0 1; .5 .5 .5]);
+                    if reportPmtMinusMean
+                        plot(freqAxisPostCue,zeros(1,length(freqAxisPostCue)),'k');
+                    end
+                    plotmsem(freqAxisPostCue,currSpectPowRF,'r:');
+                    %if tt<6
+                    plotmsem(freqAxisPostCue,currSpectPowOUT,'b:');
+                    %end
+                    currSpectPowPFDRF=[PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{1}).RF.PreFirstDimZSc;...
+                                       PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{2}).RF.PreFirstDimZSc;...
+                                       PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{3}).RF.PreFirstDimZSc];
+                    currSpectPowPFDOUT=[nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{1}).OUT1.PreFirstDimZSc,...
+                                                      PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{1}).OUT2.PreFirstDimZSc),4);...
+                                        nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{2}).OUT1.PreFirstDimZSc,...
+                                                      PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{2}).OUT2.PreFirstDimZSc),4);...
+                                        nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{3}).OUT1.PreFirstDimZSc,...
+                                                      PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{3}).OUT2.PreFirstDimZSc),4)];
+                    
+                    plotmsem(freqAxisPostCue,currSpectPowPFDRF,'r');
+                    plotmsem(freqAxisPostCue,currSpectPowPFDOUT,'b');
+                    
+                    
+                    %for cnd=1:(1+2*double(tt<6)) % Pre3rdDim is just RF
+                    %    plotmsem(freqAxisPostCue,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).([timeWinTag{tt} 'ZSc']),rgbCmap(cnd,:)); hold on;
+                    %end
+                    title([timeWinTag{tt} ' - ' lamLayerTag{ll} ' Layer']);
+                    if bb==1
+                        xlim([0 100]);
+                        if strcmp(sVisualArea,'V1')
+                            if reportPmtMinusMean
+                                if strcmpi(sSubjectName,'Wyman')
+                                ylim([-1 8]);
+                                else
+                                    ylim([-1 6]);
+                                end
+                            else
+                                ylim([0 8]);
+                            end
+                        else
+                            if reportPmtMinusMean
+                                ylim([-1 2.5]);
+                            else
+                                ylim([0 2.5]);
+                            end
+                        end
+                    elseif bb==2
+                        xlim([0 20]);  ylim([0 0.025]);
+                        ylabel('Spectral Power');
+                    elseif bb==3
+                        xlim([10 35]); ylim([0 0.015]);
+                        ylabel('Spectral Power');
+                    elseif bb==4
+                        xlim([20 100]);  ylim([0 0.006]);
+                        ylabel('Spectral Power');
+                    end
+                    if ll==3; xlabel('Frequency [Hz]'); end;
+                    if tt==1; ylabel('Baseline-Normalized Power');
+                        if strcmp(sVisualArea,'V1')
+                            if strcmpi(sSubjectName,'Wyman')
+                            text(3,7.5,['n=' num2str(numPooledChs) ';']);
+                            else
+                            text(3,3.5,['n=' num2str(numPooledChs) ';']);
+                            end
+                        else
+                            text(3,2.3,['n=' num2str(numPooledChs) ';']);
+                        end
+                    end
+                    if tt<6
+                        freqIndices2Plot=find(freqAxisPostCue<=100);
+                        pValuesVec=nan(1,length(freqIndices2Plot));
+                        for ff=1:length(freqIndices2Plot)
+                            pValuesVec(ff)=signrank(currSpectPowPFDRF(:,ff),currSpectPowPFDOUT(:,ff));
+                        end
+                        [~,~,~,pValuesVecFDR]=fdr_bh(pValuesVec);
+                        pValuesBar05FDR=nan(1,length(freqIndices2Plot));
+                        if reportPmtMinusMean
+                            pValuesBar05FDR(pValuesVecFDR<=.05)=-.5;
+                        else
+                            pValuesBar05FDR(pValuesVecFDR<=.05)=0;
+                        end
+                        plot(freqAxisPostCue(freqIndices2Plot),pValuesBar05FDR,'color',[0 0 0],'linewidth',2.5);
+                    end
+                    set(gca,'XTick',0:20:100);%set(gca,'XTickLabel',{'0','10','20','30','40','50','60','70','80','90','100'});
+                %end
+            end
+            %legend('RF','OUT','p\leq 0.05');
+            supertitle([sSubjectName ' ' sVisualArea ' - Avg across PENs - LFPs Spectral Power ' spectWinTag{bb} ' Band']);
+            
+            %if reportPmtMinusMean
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg_OUT-Pmt-MinusMean-' spectWinTag{bb} '.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg_OUT-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg_OUT-Pmt-MinusMean-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.png']);
+            %else
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.png']);
+            %end
+       end
+    end
+    
+    
+    %% PLOT MEAN ACROSS PENS COLOR CODED
+    if plotPmtsPenAvgColorCoded
+        timeWinTag={'PostStim','Stationary','PostCue','PreFirstDim','PreSecondDim','PreThirdDim'};
+        rgbCmap=eye(3);
+        close all
+        for bb=1%:4
+            hfig=figure('units','normalized','outerposition',[0 0 1 1]);
+            for tt=[1 3 4 5]%1:4%6
+                for ll=1:3
+                    currSpectPowRF=PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.([timeWinTag{tt} 'ZSc']);
+                    currSpectPowOUT=nanmean(cat(4,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.([timeWinTag{tt} 'ZSc']),...
+                        PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.([timeWinTag{tt} 'ZSc'])),4);
+                    numPooledChs=size(currSpectPowRF,1);
+                    subplot(3,4,(ll-1)*4+tt-(tt>2));%subplot(3,6,(ll-1)*6+tt);
+                    plotcmapdots([eye(3)]); plot(-inf,-inf,'-','linewidth',2,'color','k'); plot(-inf,-inf,':','linewidth',2,'color','k');
+                    if reportPmtMinusMean
+                        plot(freqAxisPostCue,zeros(1,length(freqAxisPostCue)),'k');
+                    end
+                    %for cnd=1:(1+2*double(tt<6)) % Pre3rdDim is just RF
+                    %    plotmsem(freqAxisPostCue,PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).([timeWinTag{tt} 'ZSc']),rgbCmap(cnd,:)); hold on;
+                    %end
+                    %for cnd=1:(1+2*double(tt<6)) % RF is RED
+                    %    PmtRFgrcRed=PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).(gratCondTag{cnd}).(grcColorLabel3{1}).([timeWinTag{tt} 'ZSc']);
+                    %plotmsem(freqAxisPostCue,,rgbCmap(cnd,:)); hold on;
+                    
+                    % RF case when RF is R/G/B and OUT case when RF is R/G/B
+                    PmtRFgrcR=[PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.RGB.([timeWinTag{tt} 'ZSc']);...;
+                               PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.RBG.([timeWinTag{tt} 'ZSc'])];
+                           
+                    PmtRFgrcG=[PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.GRB.([timeWinTag{tt} 'ZSc']);...
+                               PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.GBR.([timeWinTag{tt} 'ZSc'])];
+                           
+                    PmtRFgrcB=[PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.BRG.([timeWinTag{tt} 'ZSc']);...
+                               PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).RF.BGR.([timeWinTag{tt} 'ZSc'])];
+                           
+                    PmtOUTgrcR=[ 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.RGB.([timeWinTag{tt} 'ZSc'])+...
+                                 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.RGB.([timeWinTag{tt} 'ZSc']);...
+                                 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.RBG.([timeWinTag{tt} 'ZSc'])+...
+                                 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.RBG.([timeWinTag{tt} 'ZSc'])];
+                             
+                    PmtOUTgrcG=[ 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.GRB.([timeWinTag{tt} 'ZSc'])+...
+                                 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.GRB.([timeWinTag{tt} 'ZSc']);...
+                                 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.GBR.([timeWinTag{tt} 'ZSc'])+...
+                                 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.GBR.([timeWinTag{tt} 'ZSc'])];
+                             
+                    PmtOUTgrcB=[ 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.BRG.([timeWinTag{tt} 'ZSc'])+...
+                                 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.BRG.([timeWinTag{tt} 'ZSc']);...
+                                 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT1.BGR.([timeWinTag{tt} 'ZSc'])+...
+                                 1/2*PoolPmtStruct.(spectWinTag{bb}).(lamLayerTag{ll}).OUT2.BGR.([timeWinTag{tt} 'ZSc'])];
+                    
+                             if 1
+                                 plotmsem(freqAxisPostCue,PmtRFgrcR,[1 0 0],.001); hold on;
+                                 plotmsem(freqAxisPostCue,PmtRFgrcG,[0 1 0],.001); hold on;
+                                 plotmsem(freqAxisPostCue,PmtRFgrcB,[0 0 1],.001); hold on;
+                                 if tt<6
+                                     plotmsem(freqAxisPostCue,PmtOUTgrcR,[1 0 0],.001,':'); hold on;
+                                     plotmsem(freqAxisPostCue,PmtOUTgrcG,[0 1 0],.001,':'); hold on;
+                                     plotmsem(freqAxisPostCue,PmtOUTgrcB,[0 0 1],.001,':'); hold on;
+                                 end
+                             else % Peak Normalization
+                                 plotmsem(freqAxisPostCue,PmtRFgrcR/max(nanmean(PmtRFgrcR,1)),[1 0 0],.001); hold on;
+                                 plotmsem(freqAxisPostCue,PmtRFgrcG/max(nanmean(PmtRFgrcG,1)),[0 1 0],.001); hold on;
+                                 plotmsem(freqAxisPostCue,PmtRFgrcB/max(nanmean(PmtRFgrcB,1)),[0 0 1],.001); hold on;
+                                 if tt<6
+                                     plotmsem(freqAxisPostCue,PmtOUTgrcR/max(nanmean(PmtOUTgrcR,1)),[1 0 0],.001,':'); hold on;
+                                     plotmsem(freqAxisPostCue,PmtOUTgrcG/max(nanmean(PmtOUTgrcG,1)),[0 1 0],.001,':'); hold on;
+                                     plotmsem(freqAxisPostCue,PmtOUTgrcB/max(nanmean(PmtOUTgrcB,1)),[0 0 1],.001,':'); hold on;
+                                 end
+                             end
+                    %plotmsem(freqAxisPostCue,[PmtRFgrcR; PmtRFgrcR; PmtRFgrcR],[1 0 0],.001); hold on;
+                    %plotmsem(freqAxisPostCue,[PmtOUTgrcR; PmtOUTgrcR; PmtOUTgrcR],[0 0 1],.001); hold on;
+                                         
+                    title([timeWinTag{tt} ' - ' lamLayerTag{ll} ' Layer']);
+                    
+                    if bb==1
+                        xlim([0 100]);
+                        if strcmp(sVisualArea,'V1') && strcmpi(sSubjectName,'Wyman')
+                            ylimtop=22;
+                        elseif strcmp(sVisualArea,'V1') && strcmpi(sSubjectName,'Taylor')
+                            ylimtop=6;
+                        elseif strcmp(sVisualArea,'V4') && strcmpi(sSubjectName,'Wyman')
+                            ylimtop=2;
+                        elseif strcmp(sVisualArea,'V4') && strcmpi(sSubjectName,'Taylor')
+                            ylimtop=2;
+                        end
+                        %ylimtop=2;
+                        if reportPmtMinusMean
+                            ylim([-1 ylimtop]);
+                        else
+                            ylim([0 ylimtop]);
+                        end
+                    elseif bb==2
+                        xlim([0 20]);  ylim([0 0.025]);
+                        ylabel('Spectral Power');
+                    elseif bb==3
+                        xlim([10 35]); ylim([0 0.015]);
+                        ylabel('Spectral Power');
+                    elseif bb==4
+                        xlim([20 100]);  ylim([0 0.006]);
+                        ylabel('Spectral Power');
+                    end
+                    if ll==3; xlabel('Frequency [Hz]'); end;
+                    if tt==1; ylabel('Baseline-Normalized Power');
+                        text(3,ylimtop*.95,['n=' num2str(size(PmtRFgrcR,1)) ';'],'color','r');
+                        text(3,ylimtop*.85,['n=' num2str(size(PmtRFgrcG,1)) ';'],'color','g');
+                        text(3,ylimtop*.75,['n=' num2str(size(PmtRFgrcB,1)) ';'],'color','b');
+                    end
+                    %if tt<6
+                    %    freqIndices2Plot=find(freqAxisPostCue<=100);
+                    %    pValuesVec=nan(1,length(freqIndices2Plot));
+                    %    for ff=1:length(freqIndices2Plot)
+                    %        pValuesVec(ff)=signrank(currSpectPowRF(:,ff),currSpectPowOUT(:,ff));
+                    %    end
+                    %    [~,~,~,pValuesVecFDR]=fdr_bh(pValuesVec);
+                    %    pValuesBar05FDR=nan(1,length(freqIndices2Plot));
+                    %    if reportPmtMinusMean
+                    %        pValuesBar05FDR(pValuesVecFDR<=.05)=-1;
+                    %    else
+                    %        pValuesBar05FDR(pValuesVecFDR<=.05)=0;
+                    %    end
+                    %    plot(freqAxisPostCue(freqIndices2Plot),pValuesBar05FDR,'color',[.5 .5 .5],'linewidth',2.5);
+                    %end
+                    set(gca,'XTick',0:20:100);%set(gca,'XTickLabel',{'0','10','20','30','40','50','60','70','80','90','100'});
+                end
+            end
+            legend('RF is red','RF is green','RF is blue','Attend RF','Attend OUT');
+            supertitle([sSubjectName ' ' sVisualArea ' - Avg across PENs - LFPs Spectral Power ' spectWinTag{bb} ' Band']);
+            
+            if reportPmtMinusMean
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '_COLORCODED.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-MinusMean-' spectWinTag{bb} '.png']);
+            else
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '_COLORCODED.png']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./Summary/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.svg']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.fig']);
+            %    saveas(hfig,['./' sSubjectName ' ' sVisualArea '/PowSpects/' sSubjectName(1) sVisualArea '-PEN_Avg-Pmt-' spectWinTag{bb} '.png']);
+            end
+       end
+    end
+end