%This file port data from sqd file to matlab
%It generates 160 channel output files to avoid a memory problem 
%Nayef Ahmar
%CSSL
%04.22.04

clear all
close all
filename = './sqdfile/R0292.ModBand.1.30.04.Run2.sqd';%Sqd file to be ported
%filename = './sqdfile/R0292.ModBand.1.30.04.Run2_filtered.sqd';%Sqd file to be ported
%filename = './sqdfile/filtered.sqd';%Sqd file to be ported

[data,info] = sqdread(filename,'Channels',[0:0],'Samples',[1 1]);%extract info

sf = info.SampleRate;%sampling frequency in KHZ
num_samples = info.SamplesAvailable;%total number of samples

%count = 100;%number of output files generated due to memory problem
for i = 130,%0:159,
    data = sqdread(filename,'Channels',[i:i],'Samples',[1 num_samples]);
    eval(['save ./data_in/data',num2str(i+1),'.mat data sf']);
    %eval(['save ./data_out/data_flms',num2str(i+1),'.mat D sf']);
end
