matlabplot3deeglabbrain-computer-interface

Plot any segment of any raw data matrix, with time at the x-axis and the voltage (the actual data) at the y-axis, using plot command


Dimensions of the EEG matrices indicate number of channels by number of sampling points by number of segments, i.e. in the EEG data holding segments of 10s duration, we have 8 channels, 5121 sampling points and 30 segments.

Properties:

sample_rate                1x1         8             
double ssvep0Hz            8x5121x30   9832320      
double ssvep10_7143Hz      8x5121x30   9832320     
double ssvep12_5Hz         8x5121x30   9832320     
double ssvep15Hz           8x5121x30   9832320    
double ssvep9_375Hz        8x5121x30   9832320    
double time                1x5121      40968      
double

I am not able to plot as it is 3d data and i dont know how to play with channels segments and sampling points.


Solution

  • If I understand correctly, you want to plot a segment (3rd index) of the measured voltages stored in the ssvep* variables against time stored in the time variable. Have you tried the following to plot the 5th segment of the ssvep0Hz variable:

    %% Generate some data
    sampleRate = 5.120; % sample rate in kHz
    nSamples = 10*(1000*sampleRate); % time_seconds*sampleRate_Hz)
    
    ssvep0Hz = rand(8,nSamples,30)+repmat((1:8)',1,nSamples);
    time=(1:nSamples)/(sampleRate*1000);
    
    %% specify a segment and extract series
    segmentNumber=5; % Specify segmentNumber
    extractedSegment = ssvep0Hz(:,:,segmentNumber); % use colon operator `:` to extract all elements in the first two dimension and `segmentNumber to extract a specific index in the third dimension
    
    %% Plot the data and format 
    plot(time, extractedSegment);
    
    % add axis label and legends
    xlabel('Time (s)');
    ylabel('Data');
    legend;
    

    Here is the plot from above code

    Plot of 8 channels of data extracted from 8x5120x30 time series