The season 4 episode "Head Game" only featured Frasier for the first few minutes, and the rest of the episode is entirely centered around Niles. This role should have been written for Frasier, but Kelsey Grammer wasn't available as he was being treated for his addiction problems, so it was re-written for Niles instead. This is also the reason why the plot involves Niles filling in for Frasier on his radio show, because the show is integral to the plot.
[video]-----------------------------------[/video]