Image copyright Getty Images Image caption James Holmes has pleaded not guilty by reason of insanity

A court-appointed psychiatrist has testified the gunman who carried out a 2012 attack on a Colorado cinema was mentally ill but "legally sane" when it happened.

James Holmes is on trial for killing 12 people and wounding 70 others.

Dr William Reid also testified that Mr Holmes sometimes cries before going to sleep because he regrets the shooting.

Mr Holmes has pleaded not guilty by reason of insanity.

But Dr Reid said on Friday Mr Holmes could not be considered insane under Colorado law.

He conducted nine interviews with Mr Holmes at a mental health hospital last summer. Mr Holmes showed some signs of "humour" and "wit" during the interviews, Dr Reid said.

Prosecutors maintain that Mr Holmes was sane at the time of the deadly shooting and are seeking the death penalty.

In the interviews, Mr Holmes talked with Dr Reid about going to church and visiting a Mexican orphanage as an undergraduate student.

Image copyright AP Image caption A portion of Mr Holmes' notebook included captions like "Insights into the Mind of Madness"

A judge denied a request for a mistrial, after Dr Reid said that Mr Holmes' mental illness "did not prevent him from forming intent and knowing the consequences of what he was doing".

When asked whether Mr Holmes had "the capacity to know right from wrong", whether he had the capacity to form the intent to act and whether he met the legal definition of sanity at the time of the shooting, Dr Reid answered "yes" to all.

State mental health hospitals officials had Dr Reid evaluate Mr Holmes after an earlier review was deemed flawed. Both Dr Reid and the original evaluator, Dr Jeffrey Metzner, determined Mr Holmes was legally sane at the time of the shooting.

Defence lawyers are expected to call other psychiatrists who will testify that Mr Holmes was insane.

Mr Holmes suffered a "physical and mental breakdown" in November 2012, five months after his arrest from the attack, Dr Reid said. He was then treated at a hospital and started taking anti-psychotic medications.

Prosecutors showed jurors a notebook in which Mr Holmes described his own mind as "broken" and sketched out what he might do - a mass or serial murder; attacking a theatre or airport using guns, bombs or biological warfare.