function plot_raw_grid(current_path,permutations_of_IPIs,azaz_record,epoch_dividers,number_of_trials,indivmode_raw,width_,APs_in_the_train,plain_rawmatrix,...
            parameter_colors,conjoined_filename,synapse_in_question,age_and_types,raw_axis,hy,samples_per_ms,raw_include_SD,epochal_colormaps,fit_array,analyze_fitted_curves)
        
%         number_of_trials=100 %entering this manually gets around the problem of different trial counts for the raw and extracted due to how the two respond to skipping trials in create_storage_matrices
floor_of_plot=0;
for k=1:length(current_path)
    floor_of_plot=floor_of_plot+((permutations_of_IPIs(k)-current_path(k))/(prod(permutations_of_IPIs(1:k))));
end
if ~isempty(current_path),matches=matchmaker(azaz_record,current_path),else matches=[1:size(azaz_record,1)]',end
%wu=matches
if ~isempty(epoch_dividers),trials_that_were_during_this_epoch=[1:epoch_dividers(1)-.5];else trials_that_were_during_this_epoch=1:number_of_trials;end
% for iii=trials_that_were_during_this_epoch(1):trials_that_were_during_this_epoch(end)
% if find(trials_that_were_during_this_epoch==[32 34]'),trials_that_were_during_this_epoch(find(trials_that_were_during_this_epoch==[32 34]'))=[];end
for epoch=1:length(epoch_dividers)+1
    if indivmode_raw, eval(['clrmp=colormap(' epochal_colormaps{epoch} '(length(trials_that_were_during_this_epoch)));']), end
    figure(23)
    if isempty(current_path)            %handling the response after the *first* pulse (for which history all trials are a 'match')
        subplot('position',[0 .5-(.5*inv(hy(1))) width_ inv(hy(1))]),
        if epoch==1
            set(gcf,'PaperOrientation','landscape'),set(gcf,'PaperPosition',[0.5 0.5 10 7.5])
            title(strcat(conjoined_filename,'__',synapse_in_question,'__',age_and_types),'fontweight','bold'),hold on
        end
    else
        subplot('position',[length(current_path)*width_ floor_of_plot width_ 1/prod(permutations_of_IPIs(1:length(current_path)))])
    end
    set(gca,'yticklabel',[],'xticklabel',[])
    hold on,text(0,-20,'-20pA','fontsize',20,'fontweight','bold'),text(0,-10,'-10pA','fontsize',20,'fontweight','bold'),text(100,5,'10ms','fontsize',20,'fontweight','bold'),text(200,5,'20ms','fontsize',20,'fontweight','bold')
%     epi=epoch
    matches_this_epoch=matches(find(matches>trials_that_were_during_this_epoch(1)-.5&matches<trials_that_were_during_this_epoch(end)+.5))
    if isempty(matches_this_epoch),break,end   %don't waste time going through if no match
%         aa=matches_this_epoch
%         cc=trials_that_were_during_this_epoch
    raw_start_point=2000;
    max_length_raw=1000
    relevant_raw_rows=[raw_start_point:(raw_start_point+max_length_raw-1)];
    for bzz=1:length(current_path)
        cc=current_path(bzz)
        (current_path(bzz)-1)*hy(3,bzz)
        hy(2,bzz)
        relevant_raw_rows=relevant_raw_rows+((((current_path(bzz)-1)*hy(3,bzz))+hy(2,bzz))*samples_per_ms);
%          zev=[relevant_raw_rows(1) relevant_raw_rows(end)]
    end
    if relevant_raw_rows(end)>size(plain_rawmatrix,1)   %need to check this is kosher (feb 20, 2005)
        relevant_raw_rows=relevant_raw_rows(1):size(plain_rawmatrix,1);
    end
    aaa=size(plain_rawmatrix)
    bbb=size(relevant_raw_rows)
    ccc=matches_this_epoch
    hot_regions=plain_rawmatrix([relevant_raw_rows],[matches_this_epoch]);  %need to make the 3000 a variable
    points_of_light=hot_regions';
    stacksiz=size(points_of_light,1)+1,for i=1:size(points_of_light,1), if (min(points_of_light(stacksiz-i,40:end)) > 5), points_of_light(stacksiz-i,:)=[]; disp('STACKSQUASH'),end, end %trying to eliminate failures from the average waveforms
    if indivmode_raw
        for jj=1:length(matches_this_epoch)
            cllrr=clrmp(matches_this_epoch(jj),:);
            if analyze_fitted_curves
                which_AP_fit=length(current_path)*9;
%                 fit_vals_assigned=fit_array(which_AP_fit+[1:6],matches_this_epoch(jj));
%                 fit_vals_assigned(5)=0; %to remove y-offset
%                 fit_vals_assigned(6)=20; %to remove latency
%                 template=lsqfit_template_generator([fit_vals_assigned],[1:(10*raw_axis(2))]);...
%                     template=[repmat(nan,1,50) template];plot(template,'color',cllrr,'linewidth',1.5)
            end
            data_to_plot=plain_rawmatrix(relevant_raw_rows,matches_this_epoch(jj));
%             y_offset_to_subtract=fit_array(which_AP_fit+5,matches_this_epoch(jj));
% 			data_to_plot=data_to_plot-y_offset_to_subtract;
            latency_to_subtract=fit_array(which_AP_fit+6,matches_this_epoch(jj));
            data_to_plot(1:round(latency_to_subtract))=[];data_to_plot=[zeros(50,1); data_to_plot];
            plot(plain_rawmatrix(relevant_raw_rows,matches_this_epoch(jj)),'color',cllrr,'linewidth',1.5),hold on
        end
    else
        plot(mean(points_of_light),'color',parameter_colors{epoch},'linewidth',2.5),hold on
        if raw_include_SD
            plot([1:length(points_of_light)],mean(points_of_light)-std(points_of_light),'color',parameter_colors{epoch},'linewidth',1.5),hold on%parameter_colors{(mod(epoch+1,length(parameter_colors)))},'linewidth',1.5),hold on
            plot([1:length(points_of_light)],mean(points_of_light)+std(points_of_light),'color',parameter_colors{epoch},'linewidth',1.5),hold on%parameter_colors{(mod(epoch+1,length(parameter_colors)))},'linewidth',1.5),hold on
        end
    end
    if epoch==1
        if length(current_path)==length(permutations_of_IPIs)%if currently plotting the response after the last pulse in the train
            set(gca,'ylim',[raw_axis(3) raw_axis(4)],'xlim',[0 300])
        else
            set(gca,'ylim',[raw_axis(3) raw_axis(4)],'xlim',[0 300]) 
        end
    end
	if length(epoch_dividers)>epoch,trials_that_were_during_this_epoch=[epoch_dividers(epoch)+.5 :epoch_dividers(epoch+1)-.5]
	elseif length(epoch_dividers)==epoch,trials_that_were_during_this_epoch=[epoch_dividers(epoch)+.5:number_of_trials], mem=number_of_trials,disp('babbyshka')
    end
end