NEW YORK (CBSNewYork) — There has been a potential breakthrough for people suffering from severe depression, PTSD, and other severe mental problems.

It’s a faster and more accurate way to get patients on the right medications.

READ MORE: Remembering Officer Rivera: Wake Held For 22-Year-Old Killed In Line Of Duty In Harlem

As CBS2’s Dr. Max Gomez reported, it could even help prevent thousands of suicides in military veterans.

Treating severe depression or PTSD is a trial and error process — give a patient a medication that can take a couple of months to take effect. If that doesn’t work, try another for a couple of months, and so on.

During all of that time the patient is in pain and at risk for violence or suicide, but there might be a better way.

“Very difficult, anger, outbursts, didn’t know it at the time, but I was having nightmares. I’d wake my wife up hitting her,” Col. Kelly Thrasher, U.S. Army Reserves, said.

It’s a sad and unfortunately common story among our returning veterans.

After serving in Desert Storm in the early 90s and three tours of duty in Iraq and Afghanistan, Col. Thrasher was suffering with anxiety, PTSD, and severe depression.

“I thought about, would it be better if I just wasn’t here? I went down some really dark spaces where, okay I’m causing all this pain. I don’t know what to do. Is life better living or is life better if you’re not there,” he said.

READ MORE: Teenage Girl In Critical Condition After Exiting MTA Bus, Getting Hit By Truck In Brooklyn

Thrasher credited his wife and family for getting him help through the VA, but even that had its limits.

“Ok, gonna give you a plethora of drugs, hopefully that will settle you down, but make you a zombie,” Col. Thrasher said.

Then, Thrasher heard of a pioneering program from a company called Mynd Analytics that used a simple, painless, non-invasive EEG. It’s a test that’s been around for decades, measuring brain waves generated by electrical signals in nerve cells. What’s new is the way computers can analyze those brain waves.

“We’re using a large database of how people have responded to different medications and what their brainwaves look like and we’re detecting certain patterns. Certain of their electrical waves that might be associated with a particularly bad outcome with a certain type of treatment,” Dr. Dan Iosifescu, Mount Sinai Hospital said.

In fact, a recent large study in veterans found that the EEG analysis helped reduce suicidal thinking in veterans by getting them on the right medication more quickly.

Col. Thrasher had the test results within a day, and got on the right meds.

“Definitely saved my marriage, probably saved my life to tell you the truth,” he said.

This EEG test called PEER does not replace a doctor’s clinical judgement. It streamlines the process of finding the right treatment — personalized medicine.

MORE NEWS: Long Island Hoping For Best But Bracing For Worst As Nor'easter Approaches: 'Get Prepared Now'

It’s not just for vets or depression. It could help with anxiety, eating disorders, any number of mental health issues.