Difference between revisions of "LocalGlobal Details"

From NeuroTychoWiki
Jump to: navigation, search
(Sample code for Monkey Ji and Rc)
 
Line 79: Line 79:
 
== Sample code for Monkey Ji and Rc ==
 
== Sample code for Monkey Ji and Rc ==
  
clear
+
    clear
 
addpath(genpath('D:\MATLAB_toolboxes\eeglab14_1_1b'))
 
cd G:\Local_global_marmoset
 
 
Subject='Ji';
 
% Subject='Rc';
 
 
Expt_name=sprintf('%s20*',Subject);
 
Expt=ls(Expt_name);
 
Expt_num=size(Expt,1);
 
 
FS=1000; %Hz
 
DS=1;
 
 
Channel_num=96;
 
 
%%
 
Data_all=[];
 
Time=[];
 
Stim_time=[];
 
Block_idx=[];
 
Trial_idx=[];
 
Expt_idx=[];
 
 
Time_offset=0;
 
 
for expt=1:Expt_num
 
 
      
 
      
     cd(Expt(expt,:))
+
     addpath(genpath('D:\MATLAB_toolboxes\eeglab14_1_1b'))
     load Event %allBlockIdx allTrialIdx StimOn
+
     cd G:\Local_global_marmoset
 
      
 
      
     fprintf(1,'>> Expt%d/%d: %s (%.1f min)(%d trials)\n',expt, Expt_num,Expt(expt,:),length(EventTime)/1000/60,length(StimOn))
+
     Subject='Ji';
+
    % Subject='Rc';
     
+
   
     Data=zeros(Channel_num,length([1:DS:length(EventTime)]));
+
    Expt_name=sprintf('%s20*',Subject);
 +
    Expt=ls(Expt_name);
 +
    Expt_num=size(Expt,1);
 +
   
 +
    FS=1000; %Hz
 +
     DS=1;
 +
   
 +
    Channel_num=96;
 +
   
 +
    %%
 +
   
 +
    Data_all=[];
 +
    Time=[];
 +
    Stim_time=[];
 +
    Block_idx=[];
 +
    Trial_idx=[];
 +
    Expt_idx=[];
 +
   
 +
    Time_offset=0;
 
      
 
      
     for ch=1:Channel_num
+
     for expt=1:Expt_num
        FN=sprintf('ECoG_ch%d',ch);
 
        load(FN)
 
 
          
 
          
         str=sprintf('Data(ch,:)=ECoGData_ch%d(1:DS:end);',ch);
+
         cd(Expt(expt,:))
         eval(str)
+
         load Event %allBlockIdx allTrialIdx StimOn
    end
 
 
          
 
          
    Data_all=[Data_all Data];
+
        fprintf(1,'>> Expt%d/%d: %s (%.1f min)(%d trials)\n',expt, Expt_num,Expt(expt,:),length(EventTime)/1000/60,length(StimOn))
    Time=[Time EventTime(1:DS:end)/FS+Time_offset];
 
    Stim_time=[Stim_time StimOn/FS+Time_offset];
 
    Block_idx=[Block_idx allBlockIdx];
 
    Trial_idx=[Trial_idx allTrialIdx];
 
    Expt_idx=[Expt_idx ones(1,length(allTrialIdx))*expt];
 
 
      
 
      
    Time_offset=Time(end)+DS/FS;
+
       
 +
        Data=zeros(Channel_num,length([1:DS:length(EventTime)]));
 +
       
 +
        for ch=1:Channel_num
 +
            FN=sprintf('ECoG_ch%d',ch);
 +
            load(FN)
 +
           
 +
            str=sprintf('Data(ch,:)=ECoGData_ch%d(1:DS:end);',ch);
 +
            eval(str)
 +
        end
 +
           
 +
        Data_all=[Data_all Data];
 +
        Time=[Time EventTime(1:DS:end)/FS+Time_offset];
 +
        Stim_time=[Stim_time StimOn/FS+Time_offset];
 +
        Block_idx=[Block_idx allBlockIdx];
 +
        Trial_idx=[Trial_idx allTrialIdx];
 +
        Expt_idx=[Expt_idx ones(1,length(allTrialIdx))*expt];
 +
       
 +
        Time_offset=Time(end)+DS/FS;
 +
           
 +
        clear Data EventTime  StimOn
 +
     
 +
        cd ..
 
          
 
          
     clear Data EventTime  StimOn
+
     end
 
 
    cd ..
 
   
 
end
 
  
 
== Sample code for Monkey Yo, Ca and Rm ==
 
== Sample code for Monkey Yo, Ca and Rm ==

Latest revision as of 22:13, 6 July 2024

Experiment Settings

Not that the followings are default settings, and the actual details are in the each paper.


Stimuli: x=800 Hz, Y=1600 Hz, 50 ms duration No raise/fall time

Trial: ISI = 150 ms (thus SOA = 200 ms), ITI = [1.8 2.0] s

Block: 10 types, randomized order

1 block contains 100 trials (20 habituation, 64 standards, and 16 deviants).


Tone Index:

1. xxxxx

2. xxxxY

3. xxxx_

4. YYYYY

5. YYYYx

6. YYYY_


Block Index:

1. xxxxx with deviant xxxxY

2. xxxxx with omission xxxx_

3. xxxxY with deviant xxxxx

4. xxxxY with omission xxxx_

5. pure omission xxxx_

6. YYYYY with deviant YYYYx

7. YYYYY with omission YYYY_

8. YYYYx with deviant YYYYY

9. YYYYx with omission YYYY_

10. pure omission YYYY_

Data format

Data can be download from Brain/MINDS data portal.

One zip file has one date data which consists of a session.


For Monkey Ji and Rc:

‘ECoG_ch**.mat‘ had ECoG data of electrode. ** means number of electrode. Sampling rate was 1 kHz.

‘ECoGTime.mat‘ had time of ECoG data.

‘Event.mat‘ had information of condition.

‘Eye.mat‘ had eye tracking data recorded from right eye.

‘Audio.mat‘ had a audio data.


For Monkey Yo, Ca and Rm:

‘ECoG_ch**.mat‘ had ECoG data of electrode. ** means number of electrode. Sampling rate was 1017.25 Hz.

‘TriG_ch2.mat‘ had information of condition.

‘Aud_ch1.mat‘ had a audio data.

Sample code for Monkey Ji and Rc

   clear
   
   addpath(genpath('D:\MATLAB_toolboxes\eeglab14_1_1b'))
   cd G:\Local_global_marmoset
   
   Subject='Ji';
   % Subject='Rc';
   
   Expt_name=sprintf('%s20*',Subject);
   Expt=ls(Expt_name);
   Expt_num=size(Expt,1);
   
   FS=1000; %Hz
   DS=1;
   
   Channel_num=96;
   
   %%
   
   Data_all=[];
   Time=[];
   Stim_time=[];
   Block_idx=[];
   Trial_idx=[];
   Expt_idx=[];
   
   Time_offset=0;
   
   for expt=1:Expt_num
       
       cd(Expt(expt,:))
       load Event %allBlockIdx allTrialIdx StimOn
       
       fprintf(1,'>> Expt%d/%d: %s (%.1f min)(%d trials)\n',expt, Expt_num,Expt(expt,:),length(EventTime)/1000/60,length(StimOn))
   
        
       Data=zeros(Channel_num,length([1:DS:length(EventTime)]));
       
       for ch=1:Channel_num
           FN=sprintf('ECoG_ch%d',ch);
           load(FN)
           
           str=sprintf('Data(ch,:)=ECoGData_ch%d(1:DS:end);',ch);
           eval(str)
       end
           
       Data_all=[Data_all Data];
       Time=[Time EventTime(1:DS:end)/FS+Time_offset];
       Stim_time=[Stim_time StimOn/FS+Time_offset];
       Block_idx=[Block_idx allBlockIdx];
       Trial_idx=[Trial_idx allTrialIdx];
       Expt_idx=[Expt_idx ones(1,length(allTrialIdx))*expt];
       
       Time_offset=Time(end)+DS/FS;
           
       clear Data EventTime  StimOn
     
       cd ..
       
   end

Sample code for Monkey Yo, Ca and Rm

   clear
   
   addpath(genpath('D:\MATLAB_toolboxes\eeglab14_1_1b'))
   cd G:\Local_global_marmoset
   
   Subject='Ca';
   % Subject='Rm';
   % Subject='Yo';
   
   Expt_name=sprintf('%s20*',Subject);
   Expt=ls(Expt_name);
   Expt_num=size(Expt,1);
   
   FS=1017.25; %Hz
   DS=1;
   
   Channel_num=96;
   
   Trial_per_block=100;
   
   %% Block info
   
   Block_type_name{1}='xxxxx with deviant xxxxY';
   Block_type_name{2}='xxxxx with omission xxxx_';
   Block_type_name{3}='xxxxY with deviant xxxxx';
   Block_type_name{4}='xxxxY with omission xxxx_';
   
   Anag_xx=40;
   Anag_xY=80;
   Anag_xo=120;
   
   %%
   Data_all=[];
   Block_idx=[];
   Trial_idx=[];
   Expt_idx=[];
   Stim_idx=[];
   
   Idx_offset=0;
    
   for expt=1:Expt_num
       
       cd(Expt(expt,:))
           
       %% Event
       load('TriG_ch2.mat')
       
       %trim Trig if longer than wave
       load('ECoG_ch1');
       
       if length(Trig)>length(wave)
           Trig=Trig(1:length(wave));
       end   
       
       %downsample
       Trig=Trig(1:DS:end);
       
       Onset=find(diff(Trig)>10);
       Nope=find(Trig(Onset)>10);
       Onset(Nope)=[];
           
       Trial_idx_expt=round(Trig(Onset+10)/40); %1: xxxxx; 2: xxxxY; 3:xxxxo
       
       Block_idx_expt=zeros(1,length(Onset));
    
       %%% Could be only 3 blocks
       Block_per_expt=ceil(length(Block_idx_expt)/Trial_per_block);
       
       for block=1:Block_per_expt
           if block<Block_per_expt
               XX=Trial_idx_expt([1:Trial_per_block]+(block-1)*Trial_per_block);
           else % the last block could be short
               XX=Trial_idx_expt((1+(block-1)*Trial_per_block):end);
           end
           Stand=XX(1);
           Dev=find(XX~=Stand);
           Dev=XX(Dev(1));
           
           if Stand==1 & Dev==2
               B_type=1;
           elseif Stand==1 & Dev==3
               B_type=2;
           elseif Stand==2 & Dev==1
               B_type=3;
           elseif Stand==2 & Dev==3
               B_type=4;
           else
               B_type=-1;
           end
           
           if block<Block_per_expt
               Block_idx_expt([1:Trial_per_block]+(block-1)*Trial_per_block)=B_type;
           else
               Block_idx_expt((1+(block-1)*Trial_per_block):end)=B_type;
           end
           
       end
           
       Trial_idx=[Trial_idx Trial_idx_expt];
       Block_idx=[Block_idx Block_idx_expt];
       Expt_idx=[Expt_idx ones(1,length(Onset))*expt];
       
       Stim_idx=[Stim_idx  Onset+Idx_offset];
       
       Idx_offset=Idx_offset+length(Trig); 
       
       %%
       fprintf(1,'>> Expt %d/%d: %s (%d trials)\n',expt, Expt_num,Expt(expt,:),length(Onset))
    
       Data=zeros(Channel_num,length(Trig));
       for ch=1:Channel_num
           FN=sprintf('ECoG_ch%d',ch);
           load(FN)
           
           Data(ch,:)=wave(1:DS:end);
       end
           
       Data_all=[Data_all Data];
      
       clear Data wave
       cd ..    
   end
   Time=[0:size(Data_all,2)-1]/FS*DS;
   Stim_time=Time(Stim_idx);