Electromyography is a diagnostic technique used to measure the electrical activity of muscles through electrodes placed on the skin or inserted into the muscle tissue. It provides insight into muscle function and can help assess the integrity of the motor cortex and connections to voluntary movements, as well as the coordination of those movements through structures like the cerebellum.