During a routine geological survey on Surata IV, Commander William Riker is accidentally struck by a sharp thorn growing on a vine plant. The away team immediately beams back to the U.S.S. Enterprise, where Doctor Katherine Pulaski finds out that the thorn has released a deadly virus into Riker's body. Within a matter of hours, the virus will reach Riker's brain, killing him.
To try to save Riker's life, Pulaski puts him into a machine that will artificially stimulate his brain neurons, keeping them active and resisting the virus. This causes Riker to dream of his past adventures aboard the Enterprise.
Riker's first dreams are of reasonably neutral occasions, such as his first meeting with Lieutenant Commander Data (see "Encounter at Farpoint"). He soon moves on to more passionate and even erotic dreams, such as meeting the cheerful young Edo women on Rubicon III (see "Justice"), the matriarch Beata on Angel One (see "Angel One"), or the computer-generated holodeck woman Minuet (see "11001001").
However, while pleasing to Riker's mind, the passionate dreams only worsen Riker's condition, as the virus feeds on the positive endorphins his brain is creating. Pulaski and Counselor Deanna Troi therefore agree to try to make the machine evoke negative dreams instead. Thus Riker dreams of Lieutenant Tasha Yar's death (see "Skin of Evil"), or the apparent death of Deanna Troi's child (see "The Child").
This has the desired effect, as the negative endorphins drive the virus away, but the endorphins are not strong enough. As a last resort, Pulaski uses the machine to evoke dreams of raw, primitive feelings of fear and survival. Thus Riker dreams of fighting the tar creature Armus (see "Skin of Evil"), the fake Admiral Gregory Quinn (see "Conspiracy"), or the Klingon officer Klag on board the warship Pagh (see "A Matter of Honor").
Seeing that the raw emotions work best, Pulaski intensifies the dreams to come at a more rapid pace. This finally kills the virus and Riker recovers.