function y = SI2con_precontrast_SRFLASH(par,xdata,T1_weight,TR, FA, nm1)

%function ssd = SI2con_precontrast(par)

% global xdata
% global ydata
%global E1_weight;

M0 = par(1);
T10 = par(2)/T1_weight;

seqs = size(xdata,2);
%TR = repmat(TR,[seqs 1]);
TI = xdata;
% FA = repmat(FA,[1 seqs]);

E = exp(-TR/T10);
a = cos(FA/180*pi) .* E;

E10 = exp(-TI/T10);
%y = M0 * (1-E10);

y = double(M0 * ( (1-E10).*(a.^nm1) + (1-E).*(1-a.^nm1)./(1-a)));

%y = M0 * sin(xdata) * (1-E10) ./ (1-E10*cos(xdata));
%ssd = mean2((y-ydata).^2)/1;
