banner



How To Load Emotiv Data In Eeglab

ORIGINAL POST

EEGLAB can be used for the analysis and visualization of EEG datasets recorded using OpenBCI hardware and software. EEGLAB tin work with a diversity of unlike file types, including those that are exported from the OpenBCI GUI, as we saw in the previous mail service.

Get your data set up

EEG Data File

EEG data can be stored ASCII files (oftentimes saved with the ".txt" extension). The OpenBCI Processing GUI saves data in text or comma separated value (csv) files, which are output into the "SavedData" directory inside the OpenBCI_Processing directory.

Import the CSV file equally a MATLAB matrix using the following command:

> information = csvread('.../directory/yourfile.txt', row offset, cavalcade first)

For instance:

> information = csvread('.../OpenBCI-RAW-__.txt', 5, ane);

Row offset is the number of rows in your txt file before the commencement of your EEG data (in the electric current version of the OpenBCI GUI, there are 5 commented lines earlier the kickoff of the data, so the offset should exist v to make the matrix commencement on line 6). Cavalcade showtime skips the sample number column.

Yous can also write a function to open up files and avert writing and changing the name of the file everytime. To practice and then, you must write the lawmaking showed below and save it as a ".grand" file.

role [information] = open_files()  % Prompt user for filename    [fname, fdir] = uigetfile( ...    {'*.csv', 'CSV Files (*.csv)'; ...    '*.xlsx', 'Excel Files (*.xlsx)'; ...    '*.txt*', 'Text Files (*.txt*)'}, ...    'Option a file');   % Create fully-formed filename equally a string    filename = fullfile(fdir, fname);   % Check that file exists    assert(exist(filename, 'file') == 2, '%southward does not be.', filename);   % Read in the data, skipping the 5 start rows    data = csvread(filename,five,0); end

You lot can phone call the function from the Command Window with the following line (Remember to salve both scripts at the same folder):

[information] = open_files();

If you are using the OpenBCI V3 board with accelerometer data and aux information, you might want to carve up the final three channels of your data before yous send it into EEGLAB in order to only work with the EEG data and the accelerometer data separetly. To separte the dissimilar information with the respective variables, enter the command:

% Create full general variables Time = information(:,1); EEGData = data(:,2:nine); AuxData = data(:,x:12);
1.5 - eegdata
Effigy ane. Channels data should exist save in columns, not in rows.

Aqueduct Location File

Channel locations are useful for plotting EEG scalp maps in 2-D or 3-D format. OpenBCI uses the standard ten-xx format for the 8 and 16 channel models, which can be found within these .ced files: 8 channel and 16 aqueduct. You can then import aqueduct data by click "Browse" next to "Channel location file or info" and locating the OpenBCI .ced file yous downloaded.

1.5 - chlocs
Figure two. Channel location file. All the elements are separated by tabs.

If yous demand to edit the aqueduct locations, I would propose you editing either "eeglab_chan32.locs" located in "\EEGLAB\sample_data" or "Standard-x-20-Cap25.ced" located in"\EEGLAB\sample_locs". You should use whatever text editors such every bit WordPad, NotePad++, Cantlet… Whichever works improve for you and edit the files. Remember to save it as a ".ced" file, and not a txt file.

Number labels theta radius X Y Z sph_theta sph_phi sph_radius  one Fp1 -18 0.511 0.95 0.309 -0.0349 18 -2 1  2 Fp2 xviii 0.511 0.95 -0.309 -0.0349 -18 -ii 1  3 F9 -55 0.639 0.52 0.742 -0.423 55 -25 1  four F7 -54 0.511 0.587 0.809 -0.0349 54 -2 1  five F3 -39 0.333 0.673 0.545 0.v 39 30 1  6 Fz 0 0.256 0.719 -0 0.695 -0 44 1  7 F4 39 0.333 0.673 -0.545 0.5 -39 30 1  8 F8 54 0.511 0.587 -0.809 -0.0349 -54 -2 1  9 F10 55 0.639 0.52 -0.742 -0.423 -55 -25 1  10 T9 -ninety 0.639 5.55e-17 0.906 -0.423 90 -25 1  11 T7 -90 0.511 vi.12e-17 0.999 -0.0349 ninety -2 ane  12 C3 -ninety 0.256 four.4e-17 0.719 0.695 xc 44 1  13 Cz 90 0 3.75e-33 -6.12e-17 ane -ninety ninety 1  fourteen C4 90 0.256 iv.4e-17 -0.719 0.695 -90 44 1  15 T8 90 0.511 six.12e-17 -0.999 -0.0349 -ninety -2 one  xvi T10 90 0.639 5.55e-17 -0.906 -0.423 -90 -25 i  17 P9 -126 0.639 -0.533 0.733 -0.423 126 -25 1  18 P7 -126 0.511 -0.587 0.809 -0.0349 126 -2 i  19 P3 -141 0.333 -0.673 0.545 0.five 141 30 one  20 Pz 180 0.256 -0.719 -viii.81e-17 0.695 -180 44 1  21 P4 141 0.333 -0.673 -0.545 0.five -141 xxx 1  22 P8 126 0.511 -0.587 -0.809 -0.0349 -126 -two 1  23 P10 126 0.639 -0.533 -0.733 -0.423 -126 -25 1  24 O1 -162 0.511 -0.95 0.309 -0.0349 162 -2 1  25 O2 162 0.511 -0.95 -0.309 -0.0349 -162 -2 1

Events File

If yous are working with Motor Imagery, Event Related Cortical Potentials (ERPs) or you just interested in the data followed by a specific moment, yous need to upload Events Information in a ".txt" file.

Since I am working with Motor Imagery and Motor Execution and I am using OpenBCI axelerometer information to save my events, I wrote an script that finds all the events that I am interested in.

%% FINDING EVENTS  % Trials Events  RF_Re = discover(Trials == 1); % Motion Right Finger  LF_Re = find(Trials == 2); % Move Left Finger  RF_Im = find(Trials == 3); % Imagine Moving Right Finger  LF_Im = find(Trials == 4); % Imagine Moving Left Finger  Events_row = [RF_Re; LF_Re; RF_Im; LF_Im]; % List of events (based on counts)  Eastward = sort(Events_row); % List of events (based on counts) sorted  % Two External Buttons  RightButton = discover(Correct == 25120); % RightButton is pressed  Events_RB = RightButton*4-4; % Translate the row to time  for RB_Char = {'RightButton'}; % Create 'Right Push button' column  RB = repmat (RB_Char, length(Events_RB),1);  end  R = table(Events_RB,RB); % Create a table with Correct Push events    LeftButton = find(Left == 25120); % LeftButton is pressed  Events_LB = LeftButton*4-4; % Translate the row to time   for LB_Char = {'LeftButton'}; % Create 'Left Push button' column  LB = repmat (LB_Char, length(Events_LB),1);  stop  L = table(Events_LB,LB); % Create a table with Left Button events   % OBSERVATION: Some events are non saved. There is a difference of 2506ms  % between two different type of events (RF_Re and LF_Re, for case).  % This means that between 2 values of the same event in that location is difference  % of 10000ms. Currently, you must add this new values manually.    MoveRF = RF_Re(1,:); % Find 1st Move RF Result  MoveLF = LF_Re(i,:); % Find 1st Move LF Event  ImagineRF = RF_Im(1,:); % Find 1st Imagine RF Event  ImagineLF = LF_Im(1,:); % Find 1st Imagine RF Event    Move_RF = (MoveRF:10000:(MoveRF+100000-thousand))'; % Create Move RF Event Variable  Move_LF = (MoveLF:10000:(MoveLF+100000-1000))'; % Create Movement LF Event Variable  Imagine_RF = (ImagineRF:10000:(ImagineRF+100000-1000))'; % Create Imagine RF Result Variable  Imagine_LF = (ImagineLF:10000:(ImagineLF+100000-k))'; % Create Imagine LF Event Variable    % Conversion of variables (From counts to fourth dimension)  Events_RFRe = Move_RF*iv-iv; % Interpret MoveRF counts into time  Events_LFRe = Move_LF*four-4; % Interpret MoveLF counts into time  Events_RFIm = Imagine_RF*4-4; % Interpret ImagineRF counts into time  Events_LFIm = Imagine_LF*iv-4; % Interpret ImagineLF counts into time    Events = [Events_RFRe; Events_LFRe; Events_RFIm; Events_LFIm]; % List of events (based on time)  Events_Time = sort(Events); % Sort of the 2nd List of Events

Also, to make my life easier, I wrote a legit script to salve the events accordingly to EEGLAB requirements. , where all the events are label and sort in fourth dimension.

          % EEGLAB Event file (.xls)  % Latency (1st Column)     Latency = sort(Events); % Sort of 1st Events Listing (EEGLAB variable)  % Blazon (second Column)     for Cues = {'MoveRF';'MoveLF'; 'ImagineRF';'ImagineLF'};       % Repeat matix x times (ten trials) in column ane       Type = repmat(Cues, 10, 1);     end  % Duration (third Column)     for Sec = 4;       Duration = repmat(Sec,xl,1);     end  % Full general Variable     EEGLAB_Events = tabular array(Latency, Type, Duration);  % Save EEGLAB_Events.xlsx in Excel File (Ready to upload in EEGLAB)     filename = 'EEGLAB_Events.xlsx';     writetable(EEGLAB_Events,filename,'Sheet',ane,'Range','A1');

Thus, the result is a ".csv" file distributed in three dissimilar columns:

  • Latency column has the specific times event happend sorted past time.
  • Type column distinguish among the different types of events.
  • Duration column shows the length of the outcome.
3 - events
Figure iii. Events File format

Outset with EEGLAB

If EEGLAB isn't already running, enter "eeglab" into the Matlab command line to start the plan. Check that you are in the right path before you run information technology.

1 - eeglab
Figure 4. MATLAB window with "eeglab" command executed.

The primary EEGLAB window will popular-upward in your screen:

0 - eeglab
Figure 5. Main window of EEGLAB.

Import your matrix into EEGLAB using the EEGLAB GUI: File -> Import Data -> Using EEGLAB functions and plugins -> From ASCII/float file or Matlab array.

In the pop-upward window that appears, enter information about the data set up. Select "Matlab variable", and enter the proper noun of the variable where your matrix is stored. Enter the Data Sampling rate (it should be commented in at the height of the txt file – usually 250 Hz past default in the OpenBCI GUI). The other fields can be left at default, and EEGLAB will automatically fill in the information from the data gear up.

2 - data_eeglab
Figure 6. Import EEG information and channel locations.

Congratulations! The EGE data and Channel Locations are at present imported into EEGLAB, and y'all tin perform a variety of data analysis on the information and visualize information technology.

Plot your data into EEGLAB using the EEGLAB GUI: Plot -> Channel data (roll). By default, EEGLAB has a five seconds window length (x centrality). If y'all desire to change information technology, y'all must select Settings -> fourth dimension range to display in the figure window and type the new window length (s).

plotdata3.png
Figure vii. Plot EEG data and changing window length(s).

Besides, you lot tin too change the scale of the plot by playing a little chip with the "+" and "-"in the lesser of the plot. I would suggest a calibration of 50 or 100. Thus, you will accept meliorate perspective and visualization of EEG data. This should be the result:

eegdata.png
Effigy 8. EEG information visualization with a scale gene of 100.

If you wanna become one step farther, you can import events into your data past using the EEGLAB GUI: File -> Import issue info -> From Matlab array or ASCII file. Make sure to write in Input field "latency type duration", and the post-obit parameters showed in Figure 8.

3 - events_eeglab
Figure 9. Import Events File

At this point, yous can plot EEG data with the events marked in different colours by following the same steps as earlier when we plot only EEG data.

eegdataandevents.png
Figure 10. EEG data with different events ploted.

There is also the opportunity to turn down continous EEG data then every bit to "clean" your data by selecting with the cursor the length of the data that you want to remove from the signal. Although I will explain in another post how to do it significantly, feel free to play with it!

rejectdata
Figure 11. EEG data ploted with potential rejections.

References

  • EEGLAB Tutorial: http://sccn.ucsd.edu/wiki/EEGLAB_TUTORIAL_OUTLINE
  • EEGLAB Wiki: http://sccn.ucsd.edu/wiki/EEGLAB

How To Load Emotiv Data In Eeglab,

Source: https://openbci.com/community/eeglab-tutorial-import-data/

Posted by: crowprieture.blogspot.com

0 Response to "How To Load Emotiv Data In Eeglab"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel