At the time of death, brain activity was detected in the TPJ region of the brain - a recent study found. The TPJ region already has a known association with dreaming, hallucinations, and altered states of consciousness.
brain death near-death brain activity