Transformers: Prime/Recap/S1/E13 Sick Mind

Ratchet reports that his scans have located the Decepticon warship while experimenting with different frequencies. Arcee thinks they should strike now, but Ratchet says he's also detected an Autobot emergency beacon, and Optimus Prime decides they should check that out first. He and Ratchet arrive at a centuries-old crashed Autobot ship and venture inside. Though they expect there may be survivors, they find the crew already dead. Ratchet's scans reveal that the crew didn't die in the crash, but had succumbed to Cybonic plague. As the ship shifts, a deceased Autobot hanging from the ceiling drips plague-imbued Energon onto Optimus.

Later, at the Autobot base, Optimus lays stricken with the plague while the others discuss the situation. The plague was developed as part of the Decepticons' Biological Warfare Program, specifically by Megatron himself, and Ratchet thinks they might be able to find information in the Decepticon databases.

Arcee and Bumblebee Ground Bridge onto the Decepticon ship and, narrowly hiding from Knock Out, enter the ship's laboratory. Inside, Arcee scours the database, but fails to find a cure for the plague. While she's doing so, Bumblebee stumbles on something just as important — the comatose body of Megatron! Arcee is ready to finish Megatron off then and there, but Ratchet has a better idea — enter Megatron's brain and retrieve the plague cure. Ratchet knows of a procedure to create a cortical psychic patch. Though such procedures have been banned by the Autobots for years, it will get them into Megatron's brain, and Bumblebee is willing to try it.

On the ship's bridge, Starscream complains that the ship's electromagnetic shielding has not been fixed, and directs the Vehicons to hurry up and do so before the Autobots detect them. Afterwards, Starscream has a private word with Knock Out, suggesting that the Decepticons deserve a leader who is conscious, and the pair come to an understanding whereby Knock Out will be Starscream's new second-in-command as soon as Megatron is dispatched.

Meanwhile, in the sick bay, Arcee plugs Bumblebee into Megatron, and Bumblebee finds himself in a simulation of Kaon, the Decepticons' capital back on Cybertron. Ratchet creates a communications downlink so they can monitor what Bumblebee is doing. Bumblebee wanders though Kaon until he finds what appears to be Optimus, but it is just a figment of Megaton's imagination. Megatron appears and slays the false Optimus, who dissolves into smoke. Another Optimus appears, and as Megatron fires his fusion cannon, Bumblebee jumps in the path of the blast, only to find it passes right through him to slay the imaginary Optimus. Megatron, however, has seen Bumblebee and attempts to strike him, but his blows pass clean through the Autobot scout. While Megatron is trying to work out what's going on, Optimus, Bulkhead and another Bumblebee appear, all figments of his imagination. Megatron destroys them, but begins to realize that he's in his own subconscious.

Arcee becomes anxious when Starscream, Knock Out and Soundwave enter the lab, though the two Autobots are hidden well enough that the Decepticons don't see them. Starscream is determined to put on a show for Soundwave, to convince his fellow Decepticon that Megatron is beyond saving. He and Knock Out attempt to persuade Soundwave that putting Megatron out of his misery is the best course of action. Arcee and Ratchet overhear their conversation, and Ratchet says terminating Megatron will permanently separate Bumblebee's mind and body.

In the dream world, Megatron ponders what has happened to him, and finds out from Bumblebee about the Space Bridge explosion. Short on time, Bumblebee relays the news about Optimus’ Cybonic plague infection. Megatron is amused that, after all this time, Optimus will be felled by a virus, but Bumblebee plays on his desire to finish Optimus himself.

Starscream is about to pull the plug on Megatron when Soundwave points out the psychic patch cable. Starscream begins following it as Arcee observes from her hiding place.

Megatron briefly shows Bumblebee the formula for the virus cure, but will only share it if Bumblebee can release him from his mental prison. Unknown to Megatron, Ratchet can still see everything Bumblebee sees. Having obtained the formula, Ratchet tells Arcee to cut the link. Megatron's dream world begins to disintegrate and the Decepticon leader launches himself at the disappearing Bumblebee.

Bumblebee comes around as Starscream finds the two hidden Autobots, and, as they escape through the Ground Bridge, Arcee blasts one of the cables attached to Megatron. Starscream is actually pleased that Megatron has flatlined as a result, but at Soundwave's insistence has Knock Out reconnect the cable.

A newly-cured Optimus stands up and the Autobots celebrate, but Optimus insists that the celebration should be for Ratchet and Bumblebee. On the Decepticon ship, Knock Out observes that Megatron is no longer exhibiting any brainwave activity — there's no one home. Unbeknownst to anyone, Megatron now resides in Bumblebee's head...

Tropes
"If this is my subconscious...WHAT ARE YOU DOING INSIDE MY HEAD?! No! TAKE ME WITH YOU!"
 * Adventures in Coma Land: Megatron realizes he is trapped in a dream, and realizes that there's only one way out...
 * Journey to the Center of the Mind
 * Large Ham: Megatron. Check out these gems:

"Megatron: I'm out. Or should I say "in?""
 * Lotus Eater Machine: Megatron dreams of perpetual fights with Optimus that he always wins. Bumblebee convinces him that it was ultimately empty.
 * The End - or Is It?: Invoked as the Autobots and their human friends celebrate the victory. All of a sudden, Bumblebee momentarily freezes up, his eyes realign and the camera zooms into his head.

"Arcee: Spiking hard... his sick mind is still at work."
 * The Fourth Wall Will Not Protect You: Look at this face - brr.
 * The Only One Allowed to Defeat You: Bumblebee exploits Megatron's desire to destroy Optimus to get the cure out of him.
 * Title Drop: