By the time of Voyager the ship is apparently able to constantly record the brainwave patterns of all crew members at all times as a background task. I surmise that this must be an evolution of the technology installed in doors to read people's intent to go through them which first came about some time before the Original Series.