Moved some base.py code to numenta_detector because it is more specific to our detector