Error in convert raw to lfp

Thank you for the example file.
I could reproduce the error and start investigating the problem.

There are some things I don't understand with what the NPMK library returns: the length of the signals read from the file does not match the inputs given to the reading function..

Here is how to reproduce this weird behavior:

DataFile = 'C:\...\G38-1.ns6';
rec = openNSx(DataFile, 'noread', 'nozeropad');
nSamples = rec.MetaTags.DataPoints;    % 70943612

rec = openNSx('read', DataFile , 'channels', 1, 'sample', 't:1:70943612', 'p:short', 'uV');
nSamplesRead = size(rec.Data,2);  % 70943714

The first size is used to initialize a matrix: https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/process/functions/process_convert_raw_to_lfp.m#L143

length(downsample(1:70943612, round(30000/1000)))   %  2364788

The second size is the dimension of the signals read from the .ns6 file, and downsampled for real: https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/process/functions/process_convert_raw_to_lfp.m#L350

length(downsample(1:70943714, round(30000/1000)))  %  2364791

In these last two computations, you can recognize the dimensions mismatch that cause the error you reported:

I opened an issue on the NPMK github repository to understand this issue better:
https://github.com/BlackrockNeurotech/NPMK/issues/37

@mpompolas Any suggestion?