Improve the importing method used for blackrock data

Within the current version BS, you use the following code to import data for blackrock (.NSx)

rec = openNSx('read', sFile.filename, 'channels', iChannels , 'sample', strSamples, strPrecision, 'uV');

But, the 'uV' format will introduce some lose of accuracy caused by dataformat transforming. It can be solved with a very simple way that used by fieldtrip (modified version. Fieldtrip has a bug to handle data transforming, I have send issue to them,

orig = openNSx(filename, 'channels',find(chan_sel),...
      'duration', [(begsample-1)*hdr.orig.skipfactor+1, endsample*hdr.orig.skipfactor],...
      'skipfactor', hdr.orig.skipfactor);
%calculating slope (a) and ordinate (b) of the calibration
b=double(v_min .* d_max - v_max .* d_min) ./ double(d_max - d_min);
%apply v = a*d + b to each row of the matrix
dat=bsxfun(@plus,bsxfun(@times, double(orig.Data), a'),b');

Isn't this something you should submit to the NPMK library instead?

1 Like

Yes. Thank you for your suggestion.