Hi,
I am trying to determine if an error I'm getting in spm_fMRI_design is coming from a possible round-off error in spm_orth. This bug is extremely rare as it only occurs in certain cases of parametric modulators and only in the situation in which the modulator for every event is identical such that the two vectors for an event are linearly dependent. For example, consider the following matrix "u" inside spm_get_ons:
1 40
1 40
1 40
1 40
1 40
1 40
1 40
spm_orth on this matrix returns a vector of 1's and a vector of 7.10e-15. Mathematically this should be a vector of 1's and a vector of 0's of course and for most practical purposes 7.10e-15 is essentially 0. But, the problem that occurs is that if you run spm_orth on this matrix again you get a vector of 1's and a vector of 0's. This throws and error in matlab in spm_fMRI_design because of the following:
for i = 1:length(Fc)
X(:,Fc(i).i) = spm_orth(X(:,Fc(i).i));
end
Matlab expects the return of spm_orth(X(:,Fc(i).i)) to have the same number of dimensions as X(:,Fc(i).i) which is doesn't since spm_orth drops vectors that contain only 0's. What should have happened is that spm_orth should have dropped the vector containing 7.10e-15 originally. Instead of the following code in spm_orth
if any(D)
x = [x D];
end
maybe this code should be used:
epsilon = 1e-10;
if ~isempty( find(D) > epsilon )
x = [x D];
end
The reason this bug is rare is that it only occurs for certain numbers and for certain lengths of vectors. For example, the following vector of length 6
1 40
1 40
1 40
1 40
1 40
1 40
does not cause this error while the one of length 7 does. Likewise, if you replace 40 with 50 in the 7-dimensional vector it also does not cause the error. Please let me know if this actually is a bug, or if not, please let me know what I'm doing wrong. Thanks.
Ryan Haynes
|