function dHRF = anc_hrf_f(t, dt, HRF, n, e_, Ts, Tf, Eo, Go, C_Bo, Tg, Fi, K, Tmtt, Alpha, Beta, b, Tw)

tindex=round(t/dt+1);

fa = HRF(1,1);  % Relative cerebral blood flow in the arteriole
v = HRF(2,1);   % Relative cerebral blood volume
s = HRF(3,1);   % Relative amount deoxy-hemoglobin in balloon/windkessel compart
a = HRF(4,1);   % Relative pressure to volume relation constant
q = HRF(5,1);   % Vasoactive signal
E = HRF(6,1);   % Oxygen extraction fraction (OEF)
C_B = HRF(7,1); % Mean capillary O2 concentration
g = HRF(8,1);   % Rate of tissue/plasma
     
fw = v.^(Alpha+Beta)./a;        % Relative cerebral flow in the vein
dv = (fa - fw)/Tmtt;

dHRF = zeros(8,1);
dHRF(1,1) = s;
dHRF(2,1) = (fa - fw)/Tmtt;
dHRF(3,1) = (e_*(n(tindex)-1) - s/Ts - (fa - 1)/Tf) ;
dHRF(4,1) = (- a + exp (-b*dv))/Tw;
dHRF(5,1) = (E/Eo .* fa - fw.*q./v)./Tmtt;
dHRF(6,1) = (fa/Fi) * (- E + (1 - g)*(1 - (1 - Eo/(1-Go))^(1/fa)));
dHRF(7,1) = (fa/Fi) * (- C_B - E/(log(1 - E/(1-g))) + g);
dHRF(8,1) = (((C_B - g)/(C_Bo - Go) - 1) - K*(n(tindex)-1))/Tg;


end