I'm intensely suspicious of and also fascinated by all this kind of stuff. I'd love there to be something more than just electrical/chemical connections in the brain because I'd love to think there was some way that death isn't the end of my uniqueness, but ... well. Everything we see/hear/feel is the result of our brains translating the impulses received from nerves/sensors. We expect to receive impulses that originate from external stimuli so I think there's a tendency for the brain to translate whatever it receives into the closest comparable pattern that it knows and to base that on being received from one of its existing sensors.
As a child, I used to find it difficult to wake up sometimes and be aware that things were going on around me without being able to move or open my eyes. As an adult I've experienced sleep paralysis on a few rare occasions. A few times being just loud noises that appeared to happen just as I was falling asleep, that I was sure had been inside the house. Now I understand that in fact I had already fallen asleep and dreamed the noises. One time, I was convinced someone had sat on the edge of the bed as I felt the mattress dip and my body bend in reaction and even the bedclothes tighten round me. And I struggled very hard to move and eventually wrenched myself awake and into motion. It took me a few moments for the panic to subside and to understand that it was sleep paralysis and all internally triggered. Possibly a cramp in my side due to an overly saggy mattress, or just my brain creating false impressions from random synapses firing. It happened again the next night and it was a bit easier to wake up and I was less panicked because I knew what it was.
My personal theory regarding ghosts is linked to the fact that so many of them occur in older houses which are prone to damp and corrosion and thus likely to have local variations in electrical and magnetic fields. I think that some people's brain chemistry is more susceptible to such external influences and the way the brain translates this is influenced by the person's beliefs and assumptions. If the stimulus resembles a visual signal then, if the person is receptive to the idea of ghosts, the stronger the signal, the more likely it is to be interpreted as a visible presence. Everything that we see and sense after all, comes down to the way our brains are used to translating such impulses. It's all subjective, so that someone who has R/G colourblindness will not perceive the external world in the same way that I do.
I have a long-time friend who has been seeing and sensing ghosts her whole life. I believe that she's both sensitive to magnetic/electrical fields and is also now so used to this interpretation of what's going on in her brain that any slight fluctuation becomes another example of spiritual interactions. I don't have any such beliefs and when something doesn't fit into my factual interpretation of the world around me, I keep digging at it until I have an explanation that works for me. I'm either not as sensitive to local EM field fluctuations, or I interpret them as random bodily twitches/sensations without needing a deeper explanation.
But I do find the whole subject fascinating!