function Raster(fid_prefix)

close all;
clearvars -except fid_prefix

fpath = ['C:\Users\USER\Documents\mingfaifong\' fid_prefix '\'];
spath = ['C:\Users\USER\Documents\mingfaifong\' fid_prefix '\figures\'];  mkdir(spath);
fid = [fid_prefix '_nowaveform.mat'];
load([fpath fid]);

%fpath = ['C:\Users\USER\Documents\mingfaifong_tmp\2011.04.22 Two-day Chronic AMPAR Blockade (Turbo)\' fid_prefix '\SSfiles\'];
%spath = ['C:\Users\USER\Documents\mingfaifong_tmp\2011.04.22 Two-day Chronic AMPAR Blockade (Turbo)\' fid_prefix '\figures\'];

cleantime = spktimes(logical(cleanspk));
cleanchannel = channels(logical(cleanspk));
badtime = spktimes(~logical(cleanspk));
badchannel = channels(~logical(cleanspk));

totaltime = max(cleantime)-min(cleantime);

%% Hour-long Rasterplots

totaltime = max(spktimes);
nfiles = ceil(totaltime/3600); %each figure is a hour of data
% group1 = find(channels==1 | channels==4 | channels==7 | channels==10 | channels==13 | channels==16 | channels==19 | channels==22 | channels==25 | channels==28 | channels==31 | channels==34 | channels==37 | channels==40 | channels==43 | channels==46 | channels==49 | channels==52 | channels==55 | channels==58 | channels==61);
% group2 = find(channels==2 | channels==5 | channels==8 | channels==11 | channels==14 | channels==17 | channels==20 | channels==23 | channels==26 | channels==29 | channels==32 | channels==35 | channels==38 | channels==41 | channels==44 | channels==47 | channels==50 | channels==53 | channels==56 | channels==59 | channels==62);
% group3 = find(channels==3 | channels==6 | channels==9 | channels==12 | channels==15 | channels==18 | channels==21 | channels==24 | channels==27 | channels==30 | channels==33 | channels==36 | channels==39 | channels==42 | channels==45 | channels==48 | channels==51 | channels==54 | channels==57 | channels==60 | channels==63);

for i = 1:nfiles

	ind = find(spktimes>(i-1)*60*60 & spktimes<i*60*60);
	spktimesi = spktimes(ind);
	channelsi = channels(ind);
    group1 = find(channelsi==1 | channelsi==4 | channelsi==7 | channelsi==10 | channelsi==13 | channelsi==16 | channelsi==19 | channelsi==22 | channelsi==25 | channelsi==28 | channelsi==31 | channelsi==34 | channelsi==37 | channelsi==40 | channelsi==43 | channelsi==46 | channelsi==49 | channelsi==52 | channelsi==55 | channelsi==58 | channelsi==61);
    group2 = find(channelsi==2 | channelsi==5 | channelsi==8 | channelsi==11 | channelsi==14 | channelsi==17 | channelsi==20 | channelsi==23 | channelsi==26 | channelsi==29 | channelsi==32 | channelsi==35 | channelsi==38 | channelsi==41 | channelsi==44 | channelsi==47 | channelsi==50 | channelsi==53 | channelsi==56 | channelsi==59 | channelsi==62);
    group3 = find(channelsi==3 | channelsi==6 | channelsi==9 | channelsi==12 | channelsi==15 | channelsi==18 | channelsi==21 | channelsi==24 | channelsi==27 | channelsi==30 | channelsi==33 | channelsi==36 | channelsi==39 | channelsi==42 | channelsi==45 | channelsi==48 | channelsi==51 | channelsi==54 | channelsi==57 | channelsi==60 | channelsi==63);
    spktimes1 = spktimesi(group1)/60; spktimes2 = spktimesi(group2)/60; spktimes3 = spktimesi(group3)/60;
	channels1 = channelsi(group1); channels2 = channelsi(group2); channels3 = channelsi(group3);

	close all;
    figure('Position',[-1228 -277 1229 951]);
	
    subplot(3,1,1); hold on;
	plot(spktimes1,channels1+0.25*randn(size(channels1)),'.','Color',[0 51 153]/255,'MarkerSize',1.5);
	plot(spktimes2,channels2+0.25*randn(size(channels2)),'.','Color',[51 153 0]/255,'MarkerSize',1.5);
	plot(spktimes3,channels3+0.25*randn(size(channels3)),'.','Color',[204 0 0]/255,'MarkerSize',1.5);
	axis([(i-1)*60 (i-1)*60+20 0 64]);
    set(gca,'XTick',[(i-1)*60:2:(i-1)*60+20]);
    box on;
    ylabel('Channel','FontSize',14);

    subplot(3,1,2); hold on;
	plot(spktimes1,channels1+0.25*randn(size(channels1)),'.','Color',[0 51 153]/255,'MarkerSize',1.5);
	plot(spktimes2,channels2+0.25*randn(size(channels2)),'.','Color',[51 153 0]/255,'MarkerSize',1.5);
	plot(spktimes3,channels3+0.25*randn(size(channels3)),'.','Color',[204 0 0]/255,'MarkerSize',1.5);
	axis([(i-1)*60+20 (i-1)*60+40 0 64]);
    set(gca,'XTick',[(i-1)*60+20:2:(i-1)*60+40]);
    ylabel('Channel','FontSize',14);

    box on;
    subplot(3,1,3); hold on;
	plot(spktimes1,channels1+0.25*randn(size(channels1)),'.','Color',[0 51 153]/255,'MarkerSize',1.5);
	plot(spktimes2,channels2+0.25*randn(size(channels2)),'.','Color',[51 153 0]/255,'MarkerSize',1.5);
	plot(spktimes3,channels3+0.25*randn(size(channels3)),'.','Color',[204 0 0]/255,'MarkerSize',1.5);
	axis([(i-1)*60+40 (i-1)*60+60 0 64]);
    set(gca,'XTick',[(i-1)*60+40:2:(i-1)*60+60]);
    ylabel('Channel','FontSize',14);
    xlabel('Time (minutes)','FontSize',14);
    box on;
    
    fid_savename = [fid_prefix '_raster_' num2str(i-1) 'to' num2str(i) 'hr'];
    print('-depsc',[spath fid_savename '.eps']);
    saveas(gcf,[spath fid_savename '.fig'],'fig');
    clearvars -except i nfiles spktimes channels cleanspk fid_prefix spath

end

clear all; close all;