If you've come here, you're probably looking for the spincounting toolbox.
Otherwise, have a look at my other code.