User Tools

Site Tools


eeglabsessh1b

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
eeglabsessh1b [2014/01/29 16:25]
bastienboutonnet [2. Preparation of NightCrew script]
eeglabsessh1b [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>​ 
-/** 
 ===== Getting cosy with EEGLAB: Batch Crews ===== ===== Getting cosy with EEGLAB: Batch Crews =====
 ==== 1. Basic programming tips & loops ==== ==== 1. Basic programming tips & loops ====
Line 34: Line 26:
   - List operations to be performed e.g., ''​a=rand()''​   - List operations to be performed e.g., ''​a=rand()''​
   - end loop   - end loop
-*/ + 
-/** %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+
 Here are a few basic loops: Here are a few basic loops:
-''​write loops later''​ +
-*/ +
-/**+
 <code matlab> <code matlab>
 people=[1,​0,​0,​1,​1];​ people=[1,​0,​0,​1,​1];​
Line 78: Line 68:
 end end
 </​code>​ </​code>​
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/​+
  
 In our case, we will want to perform a series of operations which will be repeated **over participants**:​ In our case, we will want to perform a series of operations which will be repeated **over participants**:​
Line 197: Line 187:
 EEG = pop_checkset(EEG);​ EEG = pop_checkset(EEG);​
 </​code>​ </​code>​
 +
  
 <WRAP center round todo 80%> <WRAP center round todo 80%>
Line 242: Line 233:
  
  
-/**+
 <file matlab ​ NightCrew.m>​ <file matlab ​ NightCrew.m>​
-subject={'​504'​'​505'​};​+% This script runs the initial and time consuming routines which 
 +% are usually ran at night especially if ICA decomposition is included 
 +
 +% Author: Bastien Boutonnetbastien.b@icloud.com
  
-pathname_read='/​Users/​Shared/​HackathonFiles/​TutorialData/​EEGHack1/';​ 
-patname_write='/​Users/​Shared/​HackathonFiles/​TutorialData/​EEGHack1/​NightCrew';​ 
  
-for s=1:length(subject+subject={'505', ​'​510'​};
-   ​fprintf('Processing Subject #g : %s…\n', ​s, subject{s});+
  
-%creates the destination folder assuming you have not created it manually before +pathname_read='/​Users/​pss059/​Documents/​MATLAB/​TutorialData/​EEGLABHack1/';​ 
-if s=1+pathname_write='/​Users/​pss059/​Documents/​MATLAB/​TutorialData/​EEGLABHack1/​NightCrew/';​
  
 +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
 +%if test makes sure the folder only gets created once.
 +    if isequal(exist(pathname_write,​ '​dir'​),​7) %7 = directory
 +        display('​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Destination folder exists. All Good to go!');
 +    else
 +        [mdirstatus,​ mdirmessage]=mkdir(pathname_write)
 +        display('​%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Destination folder does not exist. Chillax! Will be created'​);​
 +    end
 +    ​
 +    %try
 +    %add electrode positions, and specify online ref
 + EEG = pop_loadcnt([pathname_read subject{i} '​.cnt'​] , '​dataformat',​ '​int32'​);​
 + 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'​});​
 +    ​
 +    %re-reference to common average & reconstruct signal at current reference
 +    EEG = pop_reref( EEG, [],'​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'​]);​
 +    EEG = eeg_checkset(EEG);​
 +    ​
 +    %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'​]);​
 +    ​
 +    %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
 </​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>​
  
 +
 +/**
  
  TODO:  TODO:
Line 271: Line 322:
 - programming tips & loops %%%%%%%%%%%%%%%%[done!] - programming tips & loops %%%%%%%%%%%%%%%%[done!]
 - go through steps again for NightCrew - go through steps again for NightCrew
- 
- 
-<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>​ 
 */ */
eeglabsessh1b.1391012727.txt.gz · Last modified: 2014/10/08 03:14 (external edit)