Electromyography is used to: