TUCSON, Ariz. — An appeals court has overturned the child abuse and kidnapping conviction of an Arizona woman who kept her three daughters imprisoned in their home for several months, locked in their rooms and denied access to a bathroom.

The Arizona Court of Appeals on August 25 ordered a new trial for Sophia Richter, who was sentenced to 20 years in prison last year. She was tried with her husband, Fernando Richter, who was sentenced to 58 years for child abuse, kidnapping and aggravated assault.

But the court of appeals says the trial judge in Tucson erred in not letting Sophia Richter introduce as a defense that she was compelled to commit the crimes by her husband’s threats and use of force.

The girls were 12, 13 and 17 when the two youngest escaped from their room in November 2013 and asked a neighbor for help. The Associated Press generally does not name minors who are victims of crimes.

Tucson police officers testified that the house smelled so bad of urine and feces they had to open all the windows to conduct their investigation.

The Richters face a separate criminal trial in Pinal County, where the family lived before moving to Tucson and where police say the majority of the crimes happened. They are facing 24 counts of child abuse and kidnapping. A trial date hasn’t been set yet.

The girls testified during the Tucson trial that they were forced to wake up at 2 a.m. every day to march in place, sometimes for so long that their legs ached. They told jurors they were fed rancid food and forced to overeat or face punishment.

The Richters pleaded not guilty in both cases.

Sophia Richter’s attorney did not respond to a request for comment Friday afternoon. Fernando Richter’s attorney said he hadn’t read the appeals ruling and that it would be inappropriate to comment on it.