Since dreams are not predetermined, the brain responds to the situation by either thinking a good thought or a bad thought, and the dream framework follows from there. If bad thoughts in a dream are more prominent than good thoughts, the dream may proceed to be a nightmare.There is a view, possibly featured in the story A Christmas Carol, that eating cheese before sleep can cause nightmares, but there is little scientific evidence for this.Severe nightmares are also likely to occur when person has a fever, these nightmares are often referred to as fever dreams. Treatment
Sigmund Freud and Carl Jung seemed to have shared a belief that people frequently distressed by nightmares could be re-experiencing some stressful event from the past. Both perspectives on dreams suggest that therapy can provide relief from the dilemma of the nightmarish experience. Halliday (1987) grouped treatment techniques into four classes. Direct nightmare interventions that combine compatible techniques from one or more of these classes may enhance overall treatment effectiveness:
Analytic and cathartic techniques
Storyline alteration procedures
Face-and-conquer approaches
Desensitization and related behavioral techniques

Post-traumatic stress disorder
Recurring post-traumatic stress disorder (PTSD) nightmares in which traumas are re-experienced respond well to a technique called imagery rehearsal. This involves dreamers coming up with alternative, mastery outcomes to the nightmares, mentally rehearsing those outcomes while awake, and then reminding themselves at bedtime that they wish these alternate outcomes should the nightmares reoccur. Research has found that this technique not only reduces the occurrence of nightmares and insomnia, but also improves other daytime PTSD symptoms.
A nightmare, also known as a bad dream, is an unpleasant dream that can cause a strong emotional response from the mind, typically fear but also despair, anxiety or great sadness. However, psychological nomenclature differentiates between nightmares and bad dreams; specifically, people remain asleep during bad dreams, whereas nightmares can awaken individuals. The dream may contain situations of discomfort, psychological or physical terror, or panic. After a nightmare, a person will often awaken in a state of distress and may be unable to return to sleep for a short period of time. Recurrent nightmares may require medical help, as they can interfere with sleeping patterns and cause insomnia. Nightmares can have physical causes such as sleeping in an uncomfortable position or having a fever, or psychological causes such as stress or anxiety. Eating before going to sleep, which triggers an increase in the bodys metabolism and brain activity, can be a potential stimulus for nightmares.The prevalence of nightmares in children (5–12 years old) is between 20 and 30%, and for adults is between 8 and 30%. In common language, the meaning of nightmare has extended as a metaphor to many bad things, such as a bad situation or a scary monster or person. Etymology
The word nightmare is derived from the Old English mare, a mythological demon or goblin who torments others with frightening dreams. The term has no connection with the Modern English word for a female horse. The word nightmare is cognate with the Dutch term nachtmerrie and German Nachtmahr (dated).