function [Betas, RMS, erdf] = mars_GLM_estim(X, Y, V)
%
%
%
if ~spm_sp('isspc',X), Xs = spm_sp('set',X); else Xs = X; clear X, end 
[nScan nBeta] = spm_sp('size',Xs);
[nScan nVar]  = size(Y);

[trRV trRVRV] = spm_SpUtil('trRV',Xs,V);

Betas     = spm_sp('x-', Xs, Y);                 %-Parameter estimates
res       = spm_sp('r', Xs, Y);                  %-Residuals
RMS       = sqrt(sum(res.^2)./trRV);             %-Res variance estimation

erdf      = trRV^2/trRVRV;




