First complete version of spatialDecompose.m

However, not tested yet (not even run once)