function [ handle ] = vis_filtering_data( InputData, CRBMConfig, CRBMTitle,handle )
%UNTITLED3 Summary of this function goes here
%   Detailed explanation goes here


%handle = 100;

figure(handle);
%%%%% vis the filtering dist
          %take all valid examples (indexed by InputData.batchdataindex)
          numcases = length(InputData.batchdataindex);
          
          %Calculate contributions from directed visible-to-hidden connections
          bjstar = zeros(CRBMConfig.numhid,numcases);
          for hh = 1:CRBMConfig.order
              bjstar = bjstar + CRBMConfig.model.B(:,:,hh)*InputData.batchdata(InputData.batchdataindex-hh,:)';
          end
          
          %Calculate "posterior" probability -- hidden state being on
          %Note that it isn't a true posterior
          bottomup = CRBMConfig.model.w * (InputData.batchdata(InputData.batchdataindex,:)./ CRBMConfig.gsd)';
          
          eta =  bottomup + ...                  %bottom-up connections
              repmat(CRBMConfig.model.bj, 1, numcases) + ...        %static biases on unit
              bjstar;                              %dynamic biases
          
          filteringdist = 1./(1 + exp(-eta'));   %logistic
          
          
          figure(handle);imagesc(filteringdist'); colormap gray;
          title(['Hidden Unit Activations - ',  CRBMTitle]); ylabel('hidden units'); xlabel('frames / samples')
          
          

end

