How can i plot raw eeg data

4 次查看(过去 30 天)
Venkatesh chowdary
Venkatesh chowdary 2019-4-27
评论: dpb 2019-4-27
I am trying to plot the raw eeg data but i am getting the following error
??? Error using ==> calllib
Library was not found
Error in ==> modReadRaw at 31
dllVersion = calllib('Thinkgear', 'TG_GetDriverVersion');
The code which i have been using is
function raw = modReadRAW
clear all
close all
data = zeros(1,10240); %preallocate buffer
portnum1 = 3; %COM Port #
comPortName1 = sprintf('\\\\.\\COM%d', portnum1);
% Baud rate for use with TG_Connect() and TG_SetBaudrate().
TG_BAUD_57600 = 57600;
% Data format for use with TG_Connect() and TG_SetDataFormat().
TG_STREAM_PACKETS = 0;
% Data type that can be requested from TG_GetValue().
TG_DATA_RAW = 4;
%load thinkgear dll
loadlibrary('Thinkgear.dll');
fprintf('Thinkgear.dll loaded\n');
%get dll version
dllVersion = calllib('Thinkgear', 'TG_GetDriverVersion');
fprintf('ThinkGear DLL version: %d\n', dllVersion );
%%
% Get a connection ID handle to ThinkGear
connectionId1 = calllib('Thinkgear', 'TG_GetNewConnectionId');
if ( connectionId1 < 0 )
error( sprintf( 'ERROR: TG_GetNewConnectionId() returned %d.\n', connectionId1 ) );
end;
% Set/open stream (raw bytes) log file for connection
errCode = calllib('Thinkgear', 'TG_SetStreamLog', connectionId1, 'streamLog.txt' );
if( errCode < 0 )
error( sprintf( 'ERROR: TG_SetStreamLog() returned %d.\n', errCode ) );
end;
% Set/open data (ThinkGear values) log file for connection
errCode = calllib('Thinkgear', 'TG_SetDataLog', connectionId1, 'dataLog.txt' );
if( errCode < 0 )
error('ERROR: TG_SetDataLog() returned %d.\n', errCode );
end;
% Attempt to connect the connection ID handle to serial port "COM3"
errCode = calllib('Thinkgear', 'TG_Connect', connectionId1,comPortName1,TG_BAUD_57600,TG_STREAM_PACKETS );
if ( errCode < 0 )
error( 'ERROR: TG_Connect() returned %d.\n', errCode );
end
fprintf( 'Connected. Reading Packets...\n' );
%%
%record data
j = 0;
i = 0;
while (i < 10240) %loop for 20 seconds
if (calllib('Thinkgear','TG_ReadPackets',connectionId1,1) == 1) %if a packet was read...
if (calllib('Thinkgear','TG_GetValueStatus',connectionId1,TG_DATA_RAW) ~= 0) %if RAW has been updated
j = j + 1;
i = i + 1;
data(j) = calllib('Thinkgear','TG_GetValue',connectionId1,TG_DATA_RAW);
total(i) = calllib('Thinkgear','TG_GetValue',connectionId1,TG_DATA_RAW);
end
end
if (j == 256)
modPlotRAW(data); %plot the data, update every .5 seconds (256 points)
j = 0;
end
end
raw = total; %return value of data
%disconnect
calllib('Thinkgear', 'TG_FreeConnection', connectionId1 );

回答(1 个)

dpb
dpb 2019-4-27
You have to load the library first...see the example code in the documenation for checking...use your wanted library name, path of course...
if ~libisloaded('shrlibsample')
addpath(fullfile(matlabroot,'extern','examples','shrlib'))
loadlibrary('shrlibsample')
end
  2 个评论
Venkatesh chowdary
Venkatesh chowdary 2019-4-27
Sorry i am new to this can you be little more specific about how i can solve my problem
dpb
dpb 2019-4-27
Load your wanted library...you'll need to know where, specifically, it was installed...we can't tell you that.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by