The human system will often process or relive events in dreams. The mind and nervous system will often not differentiate between events that occur in the waking world vs. events that occur in the dream world, so a threat that is perceived while dreaming can produce a very real physiological response.