Plot summary
The Doctor (Robert Picardo) asks Captain Kathryn Janeway (Kate Mulgrew) to alter his program to allow him to captain the ship if an emergency occurs. Janeway refuses the request. Despite this, the Doctor alters his own sub-routines, allowing him to daydream instead. Among other numerous ego-fulfilling fantasies, the daydreams include one where he becomes the "Emergency Command Hologram" and defeats an attacking alien vessel using a fictional photonic cannon. When the Doctor finds that his daydreams are occurring when he doesn't want them to, a side effect of his faulty self-programming, the crew disables the new routines.
Meanwhile, undetected by Voyager, the crew of an observation ship of the piratical Hierarchy species has been monitoring Voyager ' s passage through an innoucuous nebula. As they have done with other ships Hierarchy determines whether there is any value in the ships, and if so, attacks them. Unable to scan Voyager by normal means, Hierarchy crewman Phlox instead uses a "microscopic tunneling scan". As it happens, this latches onto the Doctor's program, specifically his fantasies. Phlox soon realizes his mistake, but the attack on Voyager for its anti-matter reserve, based on his wildly erroneous report, has already been scheduled. The Hierarchy will severely punish him, so Phlox somehow needs it to fail.
Phlox hacks into and reactivates the Doctor's daydreaming program, which allows them to communicate. Phlox explains the bizarre situation to the Doctor, who in turn reports to Janeway. As the very real Hierarchy ships approach, Janeway temporarily turns the Doctor into the Emergency Command Hologram; the double deception is now complete. The Doctor (less confident in reality than in his daydreams), is nonetheless able to bluff with his "photonic cannon" and the Hierarchy quickly retreats; both the Doctor's and Phlox's purposes have been served. Janeway commends the Doctor for his performance and arranges a team to evaluate the prospects of putting him charge of the ship under emergency situations.
Credits
Adapted from Wikipedia contributors, Tinker Tenor Doctor Spy. Paragraphs and formatting adjusted; illustrations, reference markers, block quotations and non-story material omitted.