User Tools

Site Tools


eeglabsessh2b

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
eeglabsessh2b [2014/02/02 20:29]
bastienboutonnet
eeglabsessh2b [2014/10/08 03:14] (current)
Line 1: Line 1:
-<color Gray> 
-Be patient :) This page will go live on Wed, 5th at 10am.\\ 
-\\ 
-Until then, check the [[overview|overview]] page where you will find all the info about the hackathon.\\ 
-You can also download the necessary files [[download|here]]. 
- 
-</​color>​ 
-/** 
 ====== Session Two: Post-Processing & Analysis (GUI) ====== ====== Session Two: Post-Processing & Analysis (GUI) ======
 ===== Preparation of Day Crew Script for analysis in ERPLAB ​ ===== ===== Preparation of Day Crew Script for analysis in ERPLAB ​ =====
Line 109: Line 101:
   * make matlab create the destination directory. Maybe you want to keep your ERPsets in a different folder from the other EEGLAB-type sets? If you feel brave think about this too.   * make matlab create the destination directory. Maybe you want to keep your ERPsets in a different folder from the other EEGLAB-type sets? If you feel brave think about this too.
 </​WRAP>​ </​WRAP>​
-*/ 
  
  
-/** 
-<file matlab ​ NightCrew.m>​ 
-subject={'​504',​ '​505'​};​ 
  
-pathname_read='/​Users/​Shared/​HackathonFiles/​TutorialData/​EEGHack2/​NightCrew/';​ 
-pathname_writePostProc='/​Users/​Shared/​HackathonFiles/​TutorialData/​EEGLABHack2/​2PostICACorr/​PostProc/';​ 
-pathname_writeERPSets='/​Users/​Shared/​HackathonFiles/​TutorialData/​EEGLABHack2/​2PostICACorr/​ERPSets/'​ 
  
-for i=1:​length(subject) 
-   ​fprintf('​Processing Subject #g : %s?​\n',​ i, subject{i});​ 
  
-%creates the destination ​folder ​assuming you have not created it manually before+ 
 +<file matlab ​ DayCrew_ERPLAB.m>​ 
 +% This script runs the second set of pre-processing up to averaging.  
 +% it is designed to prepare the data for analysis in ERPLAB! 
 +% Datasets created as the output of this scrip are only going to be 
 +% compatible for analysis in ERPLAB 
 +
 +%%%%%%%%%%% IMPORTANT NOTE: Until further notice this routine should be 
 +% ran on an installation of ERPLAB within a version of EEGLAB no  
 +% higher than 12 as the epoching routine creates a bug in EEGLAB 13. 
 +% developers of ERPLAB are working on a fix and should release it in  
 +% further versions. 
 +
 +% Author: Bastien Boutonnet, bastien.b@icloud.com 
 +  
 +  
 +subject={'​505'​};​ 
 +  
 +pathname_read='/​Users/​Shared/​HackathonFiles/​TutorialData/​EEGLABHack2/​2PostICACorr/';​ 
 +pathname_writePostProc='/​Users/​Shared/​HackathonFiles/​TutorialData/​EEGLABHack2/​2PostICACorr/​PostProc/';​ 
 +pathname_writeERPSets='/​Users/​Shared/​HackathonFiles/​TutorialData/​EEGLABHack2/​2PostICACorr/​ERPSets/';​ 
 +  
 +for i=1:​length(subject) 
 +   ​fprintf('​Processing Subject #%g : %s...\n',​ i, subject{i});​ 
 +  
 +%creates the destination ​folders ​assuming you have not created it manually before
 %if test makes sure the folder only gets created once. %if test makes sure the folder only gets created once.
-    if isequal(exist(pathname_write, '​dir'​),​7) %7 = directory+    if isequal(exist(pathname_writePostProc, '​dir'​),​7) %7 = directory
         display('​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Destination folder exists. All Good to go!');         display('​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Destination folder exists. All Good to go!');
     else     else
-        [mdirstatus,​ mdirmessage]=mkdir(pathname_writePostProc)+        [mdirstatus,​ mdirmessage]=mkdir(pathname_writePostProc);
         display('​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Destination folder does not exist. Chillax! Will be created'​);​         display('​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Destination folder does not exist. Chillax! Will be created'​);​
     end     end
-    ​ +  
-    try +     ​if isequal(exist(pathname_writeERPSets, 'dir'),7) %7 = directory 
-    %add electrode positions, and specify online ref +        ​display('​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ​Destination folder exists. All Good to go!'​);​ 
- EEG = pop_loadcnt([pathname_read subject{i} '​.cnt'​] , '​dataformat',​ '​int32',​ '​memmapfile'​, ''​)+    else 
- EEG = pop_chanedit(EEG'​append',​66,'​changefield',​{67 '​labels'​ '​Cz'​},'​lookup','/​Users/​pss059/​Documents/​MATLAB/​eeglab12_0_2_5b/​plugins/​dipfit2.2/​standard_BESA/​standard-10-5-cap385.elp','​setref',​{'​1:​67'​ '​Cz'​})+        [mdirstatus,​ mdirmessage]=mkdir(pathname_writeERPSets);​ 
-     +        display('​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Destination folder does not exist. Chillax! Will be created');
-    ​%re-reference to common average & reconstruct signal at current reference +
-    EEG = pop_rerefEEG, [],'refloc',​struct('​labels',​{'​Cz'​},'​type',​{''​},'​theta',​{0},'​radius',​{0},'​X',​{5.2047e-15},'​Y',​{0},'​Z',​{85},'​sph_theta',​{0},'​sph_phi',​{90},'​sph_radius',​{85},'​urchan',​{67},'​ref',​{'​Cz'​},'​datachan',​{0}),​ '​exclude',​[65 66]); +
-     +
-     +
-    ​%make epochs (all triggers of interest individually +
-    ​%we will in fact comment the remove baseline step since at the minute +
-    ​%we just want to cut the file to reduce dimensions. +
-    EEG = pop_epoch( EEG, {  '​111' ​ '​112' ​ '​113' ​ '​114' ​ '​121' ​ '​122' ​ '​123' ​ '​124' ​ '​131' ​ '​132' ​ '​133' ​ '​134' ​ '​141' ​ '​142' ​ '​143' ​ '​144' ​ '​151' ​ '​152' ​ '​153' ​ '​154' ​ '​211' ​ '​212' ​ '​213' ​ '​214' ​ '​221' ​ '​222' ​ '​223' ​ '​224' ​ '​231' ​ '​232' ​ '​233' ​ '​234' ​ '​241' ​ '​242' ​ '​243' ​ '​244' ​ '​251' ​ '​252' ​ '​253' ​ '​254' ​ }, [-0.1 1], '​epochinfo',​ '​yes'​);​ +
-    ​%EEG = pop_rmbase( EEG, [-100    0]); +
-     +
-    ​%We could already delete epochs which are followed by an incorrect +
-    ​%response. Although I prefer to keep this for the subsequent Day Crews +
-    ​%EEG = pop_selectevent( EEG, '​type',​1,'​deleteevents','​off','​deleteepochs','​on','​invertepochs','​off'​);​ +
-     +
-    ​%Save set prior to filtering (in case of crash) +
-    EEG.setname = [subject{i} '​RREP'​];​ +
-    EEG = pop_saveset( EEG,  '​filename',​ [pathname_write subject{i} '​_RREP.set'​]);​ +
-     +
-    ​%filter the data +
-    EEG  = pop_basicfilter( EEG,  1:67 , '​Cutoff',​ [ 0.1 30], '​Design',​ '​butter',​ '​Filter',​ '​bandpass',​ '​Order', ​ 4 ); +
-     +
-    ​%Save intermediary set in case ICA crashes +
-    EEG.setname = [subject{i} '​RREPF'​];​ +
-    EEG = pop_saveset( EEG,  '​filename',​ [pathname_write subject{i} '​_RREPF.set'​]);​ +
-     +
-    ​%run ICA decomposition +
-    EEG = pop_runica(EEG,​ '​extended',​1,'​interupt','​on'​);​ +
-     +
-    ​%Save final set +
-    EEG.setname = [subject{i} '​RREPFICA'​];​ +
-    EEG = pop_saveset( EEG,  '​filename',​ [pathname_write subject{i} '​_RREPFICA.set'​]);​ +
-    catch +
-        disp(['​%%%%%%%%%%%%%%%%%%%%%%%%%Something went wrong with participant ' subject{i} ' ! Skipping to next participant ​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'​]);+
     end     end
 + 
 +    %try
 + 
 +    %Loads ICA corrected set
 +    EEG = pop_loadset('​filename',​ [pathname_read subject{i} '​RRCOREPFICAC.set'​]);​
 + 
 +    %epoched to continuous set
 +    EEG = pop_epoch2continuous(EEG);​
 + 
 +    %create basic eventlist
 +    EEG  = pop_creabasiceventlist( EEG , '​AlphanumericCleaning',​ '​on',​ '​Newboundary',​ { -99 }, '​Stringboundary',​ { '​boundary'​ }, '​Warning',​ '​on'​ );
 + 
 +    %assign bins
 +    EEG  = pop_binlister( EEG , '​BDF',​ '/​Users/​Shared/​HackathonFiles/​TutorialData/​bindesc.txt',​ '​ExportEL',​ [pathname_writePostProc subject{i} '​_bins.txt'​],​ '​IndexEL', ​ '​no',​ '​SendEL2',​ '​Workspace&​EEG',​ '​UpdateEEG',​ '​on'​);​
 +
 +    %extract bin-based epochs & baseline correct
 +    EEG = pop_epochbin(EEG , [-100  1000], '​pre'​);​
 + 
 +    %Artefact detection, save summary, save set
 +    EEG  = pop_artextval(EEG,'​Channel',​[1:​65 67],'​Flag',​1,'​Threshold',​[-75 75],'​Twindow',​[-100 1000]);
 +    pop_summary_AR_eeg_detection(EEG,​ [pathname_writePostProc subject{i} '​_AR_Summary.txt'​]);​
 +    EEG = pop_saveset(EEG,'​filename',​[pathname_writePostProc subject{i} '​_RREPFICACAR.set'​]);​
 +    EEG = eeg_checkset(EEG);​
 + 
 +    %Average
 +    ERP = pop_averager(EEG ,'​Criterion',​1,'​SEM','​on'​);​
 +    ERP = pop_savemyerp(ERP,'​erpname',​[subject{i} '​_ERPs'​],'​filename',​[pathname_writeERPSets subject{i} '​_ERPs.erp'​]);​
 + 
 +    %Once you have fully debugged your script and that you know it goes
 +    %through without problems (Due to scripting) uncomment the following
 +    %lines. It allows you to jump participants if the sets are buggy but
 +    %won't give you error messages.
 + 
 +    %catch
 +    %   ​disp(['​%%%%%%%%%%%%%%%%%%%%%%%%%Something went wrong with participant ' subject{i} ' :'( Skipping to next participant %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'​]);​
 +    %end
 + 
 end end
 </​file>​ </​file>​
-*/+ 
 +<color indianred>​DISCLAIMER:​ The tutorials provided on this wiki are not intended to compete with the tutorials written by the EEGLAB'​s (and other toolboxes) developers ([[http://​sccn.ucsd.edu/​wiki/​Main_Page|EEGLAB website]]). It intends to be a condensed version for educational/​reference purposes for members of the lab/​department to which this workshop was given.</​color>​
eeglabsessh2b.1391372951.txt.gz · Last modified: 2014/10/08 03:14 (external edit)