The Matrix was a realm used by a species of non-corporeal lifeforms to trap the consciousness of corporeal beings for their nourishment. These lifeforms entered the cerebral cortex of a person who was at their most vulnerable, in a state near death, and blocked attempts of resuscitation. The alien entity needed the person to enter the Matrix voluntarily, so they caused hallucinations of loved ones for the victim in an attempt to convince them to enter the Matrix, claiming it to be the afterlife, a "place of wonder" that could assume any desired form for them.
In 2373, one of these lifeforms attempted to entice Captain Kathryn Janeway into the Matrix, posing as her deceased father. She saw through its ruse and refused to enter. The alien dislodged from Janeway's brain. Later on, Janeway and Chakotay speculated that these aliens might explain all near-death experiences, though Janeway hoped the species was only native to the Delta Quadrant. (VOY: "Coda")