Stimulating the brain to treat pain and substance use disorder