Problem getting SampleRate with MatlabSignalProcessing module

Known Issues and Problems with BCI2000
Post Reply
lsegura003
Posts: 19
Joined: 07 Sep 2016, 20:03

Problem getting SampleRate with MatlabSignalProcessing module

Post by lsegura003 » 26 Oct 2016, 09:24

Hello,


in the initialize.m function for this module i use the next code:

global bci_Parameters bci_States;

global h_im h CH_N CH_MAP tamBloq;


SampleRate= int8(str2double( bci_Parameters.SamplingRate));
tamBloq= int8(str2double( bci_Parameters.SampleBlockSize));
%Error 1
if(1==1)
error( 'SampleRate %s',int2str(SampleRate))
end
%Error 2
if(1==1)
error( 'Tambloq %s',int2str(tamBloq))
end


I have to mention that i did not use both errors together, i commented one to see what the other one showed and inverse ( i do not know an easier way to show values in BCI2000 log actually). While error2 shows 32 (the value i have in the configuration)m error1 always prints 0 (it should print 256).

Aren´t they both supposed to be bci_Parameters values? What could be causing this?

Thanks.

lsegura003
Posts: 19
Joined: 07 Sep 2016, 20:03

Re: Problem getting SampleRate with MatlabSignalProcessing module

Post by lsegura003 » 27 Oct 2016, 09:27

Sorry i did not mention it before, but i am using a compiled version of BCI2000 of the actual trunk source code. Perhaps it is related to the compilation not being done correctly? I do not think it is an error from the .m code i am using, it must come from BCI2000.

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Problem getting SampleRate with MatlabSignalProcessing module

Post by pbrunner » 27 Oct 2016, 17:16

lsegura003,

The issue in your code is that the str2double function expects a number in the bci_Parameters.SamplingRate variable, e.g., '120', but in reality this variable has the unit 'Hz' attached, i.e., '120Hz'. To overcome this issue use, 'sscanf(bci_Parameters.SamplingRate,'%i')' in your code. Also please note that the int8 function will cap your value at 127.

Regards, Peter

lsegura003
Posts: 19
Joined: 07 Sep 2016, 20:03

Re: Problem getting SampleRate with MatlabSignalProcessing module

Post by lsegura003 » 28 Oct 2016, 09:03

Ouch, you get me again!


I did it this way finally:

str=strjoin(bci_Parameters.SamplingRate);
B = regexp(str,'\d*','Match');
SampleRate= B{1}; %First number


Thanks man.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest