Doctors-in-training face long, stressful hours, sleepless nights and a high risk of depression and suicidal thoughts, but often are too stoic and time-starved to seek help. A study suggests online self-help behavior therapy could be a solution.

Suicidal thoughts were much less common in new doctors who had four half-hour online sessions before starting their first year of training, compared with those who got no therapy.

The research involved about 200 medical interns — residents in their first post-graduate year, which is often one of the most intense periods of doctor training. It often involves 80-hour weeks and overnight hospital shifts dealing with multiple medical crises.

An earlier study of 740 interns found that suicidal thoughts increased almost four-fold during the first three months of residency, said Dr. Constance Guille of the Medical University of South Carolina in Charleston. Her research group led both studies.

Sarah Dalechek, a first-year psychiatry resident at that university, said her program requires two month-long rotations of 16-hour overnight shifts in an emergency room. She said she became very depressed but had little time to seek help.

“It’s very stressful because you’re sleep-deprived, you’re not eating right … you’re working back-to-back shifts and you’re trying to catch up on sleep but you can’t,” Dalechek said. She was not involved in the study.

Dalechek said she looked into seeing a therapist but would have preferred a web-based program since it’s confidential and requires no appointment. Luckily, her depression subsided when that rotation ended.

Guille said offering web-based therapy routinely to medical residents could be beneficial, if her research results are confirmed in a broader study.

The results were published Wednesday in the journal JAMA Psychiatry.

The study involved interns at Yale University and the University of Southern California. It used a free online program developed at the National Institute for Mental Health Research at the Australian National University in Canberra. Interns who got the sessions were 40 percent less likely to have suicidal thoughts during that first year compared to those who received four weekly emails with information about depressions and where to seek help.

The online program included sessions about how to put feelings of stress or despair into perspective. For example, a poor test grade or bad performance evaluation might lead to feelings of “I’m not good enough,” but the lessons encourage more positive thinking about “how many exams have you passed, to put this failure in a more accurate light,” Guille said.

The training also encourages seeking out activities or thoughts that bring pleasure, especially when feeling down.

Previous research has shown benefits from similar web-based therapy in other settings.

Guille said medical students and residents tend to be high-achieving perfectionists, but that they need to learn “you can’t always be perfect in medicine, you have to figure out how to deal with failure.”