Yes the medical term for it is hypagogia
http://en.wikipedia.org/wiki/Hypnagogia
I started getting this after meditation so I certainly believe there is a spiritual cause. If we believe that the spiritual is in everything than there's no reason to separate hallucination from spiritual phenonema.