function preds = checkQuality(opttheta,signal,numClasses,imageDim, filterDim,numFilters,poolDim)

[Wc, Wd, bc, bd] = cnnParamsToStack_1D(opttheta, imageDim, filterDim, numFilters, poolDim, numClasses);

hs = (imageDim-filterDim+1)/poolDim;
wdLen = size(Wd,2);

kInd = 1:hs:wdLen+hs;
for i = 1:numFilters
    Wdf(:,:,i) = Wd(:,kInd(i):(kInd(i+1)-1));
end

poolFilter = ones(1, poolDim);
poolDimSquared = poolDim;
%poolIndex = 1 : poolDim : (convolvedDim - max(0, poolDim - 1));
%S(:,1) = (signal(:,1)-mean(signal(:,1)))/std(signal(:,1));
%S(:,2) = (signal(:,2)-mean(signal(:,2)))/std(signal(:,2));
%signal = S;

for i = 1:numFilters
    
    convop = rot90(squeeze(Wc(:,i)),2);
    convSig = conv(signal', convop,'valid');
    convAct= sigmoid(convSig+bc(i)*ones(size(convSig)));
    convFeat(i,:) = convAct;
    %     pooledFeat = poolFeat(convAct, poolDim)
    
    %     convolvedFeature = conv(convAct, poolFilter', 'valid');
    %     poolFeat_odd = convolvedFeature(1:poolDim:end) / poolDimSquared;
    %     poolFeat_even = convolvedFeature(2:poolDim:end) / poolDimSquared;
    %
    %     poolFeat = zeros(1, length(convolvedFeature)/2);
    %     poolFeat(1:2:end) = poolFeat_odd(1:2:end);
    %     poolFeat(2:2:end) = poolFeat_even(1:2:end);
    
    
end

for i = 1:numClasses
Wop = rot90(squeeze(Wdf(i,:,:))',2);
weightConv = conv2(convFeat, Wop,'valid');
weightConvb(i,:) = weightConv + bd(i)*ones(size(weightConv));
end

activationsSoftmax = bsxfun(@minus, weightConvb, max(weightConvb));
activationsSoftmax = exp(activationsSoftmax);
probs = bsxfun(@rdivide, activationsSoftmax, sum(activationsSoftmax));
[~,preds] = max(probs,[],1);
end
