% 09-10-06 AC Added filter to remove motion artifact and high frequency
%             noise
% 09-10-06 AC Added code to remove resting state from the start and end of
%             the files
function [data,motion,start_index] = load_data(subject_id)

data_dir = '.\data\';
data_filename = [data_dir subject_id 'data.daq'];
index_filename = [data_dir subject_id 'index.mat'];
data = daqread(data_filename);

[b,a] = butter(1,[10 400]/500);
data = filtfilt(b,a,data);

load(index_filename);

% clip the resting data from the start and end of the files
Nstart_index = length(start_index);
data = data(start_index(2):start_index(Nstart_index-1),:);
data = data - repmat(mean(data,1),size(data,1),1);
start_index = start_index(2:(Nstart_index-1)) - start_index(2) + 1;
motion = motion(2:(Nstart_index-1));
