function plot_snapshot(filename,chans)
close all;

% convert to microvolts
% 0.195 uV per bit
CONVERT_RAW_TO_UV = 0.195;

switch nargin
    case 1
        chans = [1];
end

% In summer 2017 the format of channel data in HDF5 files was
% changed from a 1D vector to 2D array for efficiency. This change
% broke backward-compatibility.
LEGACY_FORMAT = false;

% read data
d_uint16 = h5read(filename,'/channel_data');
if LEGACY_FORMAT==true
    M = 1024;
    N = length(D)/M;
    d_uint16=reshape(D,M,N);
end
data=double(d_uint16);
sample_index = h5read(filename,'/sample_index');

% high-pass filter
Fstop = 200;
Fpass = 300;
Astop = 65;
Apass = 0.5;
Fs = 3e4;
Hd = designfilt('highpassfir','StopbandFrequency',Fstop, ...
  'PassbandFrequency',Fpass,'StopbandAttenuation',Astop, ...
  'PassbandRipple',Apass,'SampleRate',Fs,'DesignMethod','equiripple');
fvtool(Hd)

for i=1:length(chans)
    figure;
    ch = chans(i);
    % 0 <= raw data <= 2^16
    raw_data = data(ch,:);
    % time in msec
    time = [1:length(raw_data)]/30;

    % plot raw data
    subplot(2,1,1);
    plot(time,raw_data*CONVERT_RAW_TO_UV);
    ylabel('uV');
    title(sprintf('Channel %d raw',ch));
    xlabel('time (msec)');
    
    % filter and plot channel data
    zero_mean = data(ch,:)-mean(data(ch,:));
    filter_data = filter(Hd,zero_mean);
    subplot(2,1,2);
    plot(time,filter_data);
    ylabel('uV');
    title(sprintf('Channel %d filtered',ch));
    xlabel('time (msec)');
end

