function [dFF_event_mean,rippbandpower] = GetRate(eventTimes,dFoverF,lfpData,windowSize,threshold_,time_window)
    %windowSize = 0.5; % Size of the sliding window
    %threshold = 0; % Frequency threshold
    % Calculate event frequencies using sliding window approach
    fs_dff = 100;
    N_dFF = length(dFoverF);
    eventFrequencies = zeros(1, numel(eventTimes));
    for i = 1:numel(eventTimes)
        startTime = eventTimes(i) - windowSize/2 ;
        endTime = eventTimes(i) + windowSize/2;
        eventFrequencies(i) = sum(eventTimes >= startTime & eventTimes <= endTime);
    end
    [eventTimesUnique,idx] = uniquetol(eventTimes,windowSize,'DataScale',1);
    [eventTimesUnique_r,idx_r] = uniquetol(eventTimes,windowSize,'highest','DataScale',1);
    eventFrequencies_ = eventFrequencies(idx);
    % Find time point(s) where frequency exceeds threshold
    aboveThresholdIndices = (eventFrequencies_ == threshold_);
    eventTimesUnique  = 0.5*(eventTimesUnique + eventTimesUnique_r);
    timeId = eventTimesUnique(aboveThresholdIndices);
    
    dFF_event_mean = [];
    for i = 1:length(timeId)
        idx = round((timeId(i))*fs_dff);
        if (idx-time_window*fs_dff >0) && (idx+time_window*fs_dff<N_dFF)
            a = dFoverF(idx-time_window*fs_dff:idx+time_window*fs_dff);
            dFF_event_mean = [dFF_event_mean a];
        end
    end



   [spectrogrammt,tm,fm] = MTSpectrogram(lfpData,'window',1);
    bands = SpectrogramBands(spectrogrammt,fm);
    Ripp_power = zscore(bands.ripples);
    fs_rp = (1/mean(diff(tm)));
    N_rp = size(Ripp_power,1);
    Nt = round(2*time_window*fs_rp) + 1;
    Ripple_event_mean = zeros([Nt,1]);
    count_ = 0;
    for i = 1:length(timeId)
        t_idx = round((timeId(i)));
        if (t_idx-time_window) >0 && ((t_idx+time_window)*fs_rp)<N_rp
            a = Ripp_power(round((t_idx-time_window)*fs_rp):round((t_idx+time_window)*fs_rp));
            Ripple_event_mean = Ripple_event_mean + a;
            count_ = count_ + 1;
        end
    end
    Ripple_event_mean = Ripple_event_mean/count_;
    figure;
    plot(-1*time_window:1/fs_rp:time_window,Ripple_event_mean);
    rippbandpower = Ripple_event_mean;


