changed EstimateDimFromSpectra.m to single loop and more readable variable names, while still taking into account all of the strange special cases