function [stop_response] = RunNeuronStopAnalysis(data_behavior,events,plxdata,filename,plot_fig)

  plot_onset = -1;
  plot_offset = 1.5;
  bin = 60;   %bin = 60 msec for stat analysis
  slide = 1;  %sliding procedure shift = 1-msec
  
  %index to plot and save the figure for individual neurons
  if isempty(plot_fig)
     plot_fig = 1;
  end
  
  %--------------  BEHAVIORAL DATA  ---------------------------
  %Measure the SSRT for individual session
  [behavior_stoptask] = detectSSRT(data_behavior,events);
 
  %TRIAL TYPES-----------------------------------------
  %go trials without stop signal
  GO_trials = find(6 = data_behavior.TP & data_behavior.TP = 1  18 = data_behavior.TP & data_behavior.TP = 13);
  GO_trials = GO_trials(isnan(events.change_signal(GO_trials)));
  GO_trials_success = GO_trials(~isnan(events.reward(GO_trials))); %with rewarded trials only and mvt onset well-detected
  GO_trials_success = GO_trials_success(~isnan(events.mvt_onset(GO_trials_success)));

  %go trials with stop signal
  GO_stoptrials = find(6 = data_behavior.TP & data_behavior.TP = 1  18 = data_behavior.TP & data_behavior.TP = 13);
  GO_stoptrials = GO_stoptrials(~isnan(events.change_signal(GO_stoptrials)));
  GO_stoptrials_success = GO_stoptrials(~isnan(events.reward(GO_stoptrials))); %with rewarded trials only
  
  %fake SSRT for GO trials
  SSD_distrib = [2001450];
  SSD_events = [];
  
  for loop = 11000
  
    SSD_values = shuffle(SSD_distrib);

    for iii = 1length(GO_trials_success)
      
        trial = GO_trials_success(iii);
        fake_event = events.go_signal(trial) + SSD_values(trial);
      
        if (fake_event + behavior_stoptask.SSRT)events.centreout(trial)  %only latency-matching trials
            fake_SSD(iii) = fake_event;
        else
            fake_SSD(iii) = NaN;
        end
    end
  
    SSD_events = [SSD_events fake_SSD(~isnan(fake_SSD))];
  
  end
  
  %--------------  NEURONAL DATA  ---------------------------
  timestamps = plxdata.sig001a.ts .1000;  % Neural activity
  [sdf_stop_trials] = sdf_neurons(timestamps,events.change_signal(GO_stoptrials_success),plot_onset,plot_offset);
  [sdf_GO_trials] = sdf_neurons(timestamps,SSD_events,plot_onset,plot_offset);
  
  %-----------------STAT with a slidind window procedure-----------------------------------
  
  [m n] = size(sdf_stop_trials.delta);
  Wind_on = [1sliden-bin];
  Wind_off = [binsliden-1];
  
  for k = 1length(Wind_on)
      delta_stop(,k) = sum(sdf_stop_trials.delta(,Wind_on(k)Wind_off(k)),2);
      delta_GO(,k) = sum(sdf_GO_trials.delta(,Wind_on(k)Wind_off(k)),2);
  end

  for k = 1length(delta_stop)
      
     val = [delta_stop(,k); delta_GO(,k)];
     val2 = [ones(length(delta_stop(,k)),1); zeros(length(delta_GO(,k)),1)];
     val = [val val2];
     
     if sum(val(,1))3
            AUC_ROC(k)=colAUC(val(,1),val(,2), 'algorithm', 'Wilcoxon', 'plot', false, 'abs', false);  
     else
            AUC_ROC(k) = NaN;
     end
  end

  %-----------------Time scale--------------------------------
  Xbinned = [plot_onset0.001plot_onset+((length(AUC_ROC)-1)1000)];
  Xbinned = Xbinned + (bin2)1000;
  %-----------------Detect change in AUC values----------------
  alpha = 0.05; 
  contig = 5; 
  cntl_inds = find(-1Xbinned & Xbinned0); %control period (1 sec pre-event)
  test_start = find(0Xbinned & Xbinned0.1); %test period
  test_start = test_start(1);
  
  [s,cntl_mean,sig_thr] = PeriEventChange_SDF(AUC_ROC,cntl_inds,test_start,alpha,contig);

  %--------------------Plotting---------------------------------
  if plot_fig == 1
  
        figure
        subplot(3,1,1)
        hold on
        plot([behavior_stoptask.SSRT1000 behavior_stoptask.SSRT1000],[0 max(sdf_GO_trials.mean_sdf)],'k')
        plot(sdf_GO_trials.bins, sdf_GO_trials.mean_sdf,'k')
        plot(sdf_stop_trials.bins, sdf_stop_trials.mean_sdf,'r')
        xlabel('Time relative to Stop-signal')
        ylabel('spks')
  
        subplot(3,1,2)
        hold on
        plot(Xbinned,AUC_ROC)
        xlim([plot_onset plot_offset])
        ylim([0 1])
        plot([plot_onset plot_offset],[cntl_mean cntl_mean],'k-');
        plot([plot_onset plot_offset],[cntl_mean+sig_thr cntl_mean+sig_thr],'k');
        plot([plot_onset plot_offset],[cntl_mean-sig_thr cntl_mean-sig_thr],'k');
        plot([behavior_stoptask.SSRT1000 behavior_stoptask.SSRT1000],[0 1],'k')
        if ~isempty(s.on_ind)
                plot([Xbinned(s.on_ind) Xbinned(s.on_ind)],[0 1],'r')
        end
        xlabel('Time relative to Stop-signal')
        ylabel('AUC')
  
     meta_name = ['stop_neun' filename '.png'];
        print( '-dpng','-r600', meta_name);
        close
  end
  
  %--------------------Saving---------------------------------
  stop_response.SSRT = behavior_stoptask.SSRT;
  stop_response.sdf_bins = sdf_GO_trials.bins;
  stop_response.sdf_GO_trials = sdf_GO_trials.mean_sdf;
  stop_response.sdf_stop_trials = sdf_stop_trials.mean_sdf;
  stop_response.AUC_bins = Xbinned;
  stop_response.AUC = AUC_ROC;
  if ~isempty(s.on_ind)
        stop_response.cancel_time = round(Xbinned(s.on_ind)1000);
        stop_response.cancel_sgn = s.sgn;
  else
        stop_response.cancel_time = NaN;
        stop_response.cancel_sgn = NaN;
  end
end