% Jon Newman
% Ga Tech

% 23 Apr 2010

% Plots PSCs from a data file that you choose

tankID = 'C:\TempData\20100420\20100420-35';
[fid file] = queryfid(tankID);

load(fid);

h = figure();
for i = 1:size(data.psc.snips,2)
    hold all
    if ~isempty(data.psc.snips{i})
        plot(1000*(1:size(data.psc.snips{i}',1))/data.sampfreq,data.psc.snips{i}')
    end
end

xlim([0 1000*(size(data.psc.snips{i}',1))/data.sampfreq])
title(strcat(['PSC Snips: ' file]),'Interpreter','none')
xlabel 'Time (ms)'
ylabel 'I_{pip} (pA)'

findfigs
beep;
reply = input('Save Figure? [y/n]: ','s');
if isempty(reply)
    reply = 'y';
end

if reply == 'y'
    figdir = strcat([fid(1:end-4) '_FIG']);
    figfid = strcat([file(1:end-4) '_PSCSnips_FIG']);
    if ~exist(figdir,'dir')
        mkdir(figdir);
    end
    saveas(h, strcat([figdir '\' figfid '.fig']))
    saveas(h, strcat([figdir '\' figfid '.jpg']))
end