function [ output ] = topoplot_SNR( EEGDataset, freqToPlot ,numRaw,numColumn, weightMatrix,figureON)
%% plot the SNR distribution according freqToPlot
% ex: topoplot_SNR( xxDataset, [8:0.2:9]hz);
% return:
%
data = squeeze(mean(EEGDataset.data,3));
if(isempty(weightMatrix))
    out = zeros(size(data,1),length(freqToPlot));
    out2 = zeros(size(data,1),size(data,2));
else
    out = zeros(size(weightMatrix{1},2),length(freqToPlot));
    out2 = zeros(size(data,1),size(data,2));
end
%% apply FFT
for f = 1:length(freqToPlot)
    if(isempty(weightMatrix))
        [out(:,f),out2] = mySNR2( data,freqToPlot,freqToPlot(f),5);
    else
        [out(:,f),out2] = mySNR2( (data'*weightMatrix{f})',freqToPlot,freqToPlot(f),5);
    end
end
%% apply CCA
[qq,qqq,afterCCA] = my_FFT_or_CCA(data([getSbjInfo('normal')],:)',5,8:0.2:11.8,4,'CCA');
for f = 1:size(afterCCA,3)
    [q,www(f,:)] = mySNR2( squeeze(afterCCA(1,:,f)),freqToPlot,freqToPlot(f),5);
end

%%
out = out-mean(out(:));
output = mean(out(:,6));%occipital channels, 9hz
maxValue = max(out(:));
minValue = min(out(:));
if(figureON)
     figure('name',EEGDataset.filename,'numbertitle','off');
    for i=1:length(freqToPlot)
        subplot(numRaw,numColumn,mfSSVEP_ring_plot(freqToPlot(i)));
        topoplot(out(:,i),EEGDataset.chanlocs,...
            'style','map',...
            'maplimits',[minValue maxValue],...
            'drawaxis','off');
        title([num2str(freqToPlot(i)) 'Hz']);
    end
    tightfig;
    figure('name','meanSNR');
    topoplot(mean(out,2),EEGDataset.chanlocs,'electrodes','ptsnumbers');
    colorbar;
    title('mean');
    
    figure;
    topoplot(out(:,6),EEGDataset.chanlocs,'electrodes','ptslabels','maplimits',[minValue maxValue]);
    
    figure('name','fft');
    plot((0:size(data,2)-1)/5,10*log(mean(out2(120:126,:),1)));
    %     name = sprintf('%s',EEGDataset.datfile);
    %     save(name,out2);
end


end

