Rewrote residual computation to do efficient pseudoinverse calculation if the number of ROIs is small enough.