Page 1 of 1

Problem getting SampleRate with MatlabSignalProcessing module

Posted: 26 Oct 2016, 09:24
by lsegura003
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.

Re: Problem getting SampleRate with MatlabSignalProcessing module

Posted: 27 Oct 2016, 09:27
by lsegura003
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.

Re: Problem getting SampleRate with MatlabSignalProcessing module

Posted: 27 Oct 2016, 17:16
by pbrunner
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

Re: Problem getting SampleRate with MatlabSignalProcessing module

Posted: 28 Oct 2016, 09:03
by lsegura003
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.