1 Damage to this nerve can cause ED. 2  Electromyography is a test that doctors use to detect nerve function and measure the electrical activity generated by muscles. 3  Therefore this test can determine if damage to the pudendal nerve is the cause of ED.