function loadspkChunk(fid_prefix, chunksize)

    %Initialize variables
    channel = [];
    time = [];
    threshold = [];
    waveform = [];
    unit = [];
    h = 1;
    tmp.channel = [];
    tmp.time = [];
    tmp.threshold = [];
    tmp.waveform = [];
    tmp.unit = [];

    if nargin < 2
        chunksize = 1;
    end
    
    fpath = ['C:\Users\USER\Documents\mingfaifong\marcTest' fid_prefix '\spkfiles\'];
    spath = ['C:\Users\USER\Documents\mingfaifong\marcTest' fid_prefix '\matfiles\']; mkdir(spath);
    fpath_info = dir(fpath);      %get info about contents of directory
    isfile = ~[fpath_info.isdir]; %get index for files only
    fidlist = {fpath_info(isfile).name}; %create list of files
    
    for i = 1:length(fidlist)
        clearvars -except i fidlist T0 fpath chunksize j channel time threshold waveform spath fid_prefix tmp h
        
        % get name of spike file
        fid = fidlist{i};

        % finding fid name based on location of underscores
        uscloc = strfind(fid,'_');
        if length(uscloc)==1
            fidsave = fid;
        else
            fidsave = fid(1:uscloc(2)-1);
        end
        
        %Load file and find the last spk time
        s = loadspk([fpath fid]);
        lastspk = max(s.time);
        
        %Determine starttime of recording file
        T = [];
        starttime = s.meta.date;
        rest = starttime;
        while ~isempty(rest)
            [token rest] = strtok(rest,'-');
            T = [T str2double(token)];
        end

        %set T0 as time of first file
        if i == 1
            T0 = T;
        end
        
        %Shift time to be in total recording time
        starttime = etime(T,T0);
        s.time = s.time + starttime;
        
        for j = 1:ceil(lastspk/3600)
            
            mask = s.time < h*3600 & s.time > (h-1)*3600;
            if j == ceil(lastspk/3600)
                tmp.channel = s.channel(mask);
                tmp.time = s.time(mask);
                tmp.threshold = s.threshold(mask);
                tmp.waveform = s.waveform(mask);
                tmp.unit = s.unit(mask);
            else
                channel = [tmp.channel s.channel(mask)];
                time = [tmp.time s.time(mask)];
                threshold = [tmp.threshold s.threshold(mask)];
                waveform = [tmp.waveform s.waveform(mask)];
                unit = [tmp.unit s.unit(mask)];
                tmp.channel = [];
                tmp.time = [];
                tmp.threshold = [];
                tmp.waveform = [];
                tmp.unit = [];
                save([spath fidsave '_' num2str(chunksize*(h-1)) 'to' num2str(ceil(max(time)/3600)) 'hr' '.mat'],'channel','time','threshold','waveform', 'unit');
                h = h+1;
            end
            
        end
    end
end