function [tonic_time, clonic_time] = thresholdBiceps(ratio, max_HF, max_LF, Fs)

% TONIC PHASE DURATION
tonic_time = 0;
L = length(ratio);
threshold = 1;

for i = 1:L-Fs
    % Tonic phase is starting
    if ratio(i) > threshold
        tonic_time = tonic_time + 1;
        if sum(ratio(i:i+Fs)) == 0
            break
        end
    end
end

% CLONIC PHASE DURATION
clonic_time = 0;
indexMax = find(ratio == max(ratio), 1);

for j = indexMax:(L - 10*Fs) % In the end of tonic phase, the ratio turns to 0 for a long time
    if max_HF(j) == max_LF(j)   % Change of phases from tonic to clonic
        if ratio(j : (j + 10*Fs)) == 0
            break;
        else
            clonic_time = clonic_time + 1;
        end
    end
end

tonic_time = tonic_time / Fs;
clonic_time = clonic_time / Fs;

end

