
function data=readdata_diffs3(path,name,sel,filtdata,prefs)
%syntax: data=readdata_diffs3(filename, which data)

load(strcat(prefs.proj_dir,'seg_data_',strrep(name,'.wav','')));
n_s=size(seg_data.reg_arr,1);

if isempty(sel)
    data=zeros(13,n_s);
    return
end


data=zeros(13,n_s);
for n=1:n_s
    [wave.wf,wave.fs]=wavread(strcat(path,name),[seg_data.reg_arr(n,1) seg_data.reg_arr(n,2)]);
    wave.spec=abs(specgram(wave.wf));

    threshold=prefs.threshold;
    cd(prefs.func_dir)
    wave.spec=butt_filt(wave,prefs.cutoff,12);
    pthresh_med=(2*median(wave.spec(:)));
    [wave.spec, threshold]=filt_spec(wave,filtdata);
    
    if pthresh_med>threshold
        threshold=pthresh_med;
        wave.spec=wave.spec.*(wave.spec>=pthresh_med);
    else
        wave.spec=wave.spec.*(wave.spec>=threshold);
    end
    
    wave1=wave;
    wave2=wave;
    wave1.spec=wave.spec(:,1:round(size(wave.spec,2)/2));
    wave2.spec=wave.spec(:,round(size(wave.spec,2)/2)+1:size(wave.spec,2));

    if max(wave1.spec(:))==0
        wave1.spec=wave2.spec;
    elseif max(wave2.spec(:))==0
        wave2.spec=wave1.spec;
    end    
    
    feature1 = featurext_wk(wave1,sel,seg_data.timeint,prefs);
    feature2 = featurext_wk(wave2,sel,seg_data.timeint,prefs);

    data(:,n)=(feature1-feature2)';
end    