clear all;
close all;

dirname = 'C:\Users\USER\Documents\mingfaifong\opticalstim ctrl cnqx apv\';
dirData = dir([dirname 'spkfiles\']);      %# Get the data for the current directory
dirIndex = [dirData.isdir];  %# Find the index for directories
fidlist = {dirData(~dirIndex).name}';


for ii = 1:length(fidlist)
    clearvars -except dirname fidlist ii
    fname = fidlist{ii}(1:end-4);
    dat = loadspk([dirname 'spkfiles\' fidlist{ii}]);
    time = dat.time;
    channel = dat.channel;
    unit = dat.unit;
    threshold = dat.threshold;
    meta = dat.meta;
    save([dirname 'matfiles\' fname '_nowaveform.mat'],...
        'time','channel','unit','threshold','meta','fname');
end