A man who spent seven years in prison for rape before a DNA test exonerated him may sue the city and several police officers who put him behind bars, an appeals court ruled.

Officers and investigators can be sued for their actions leading up to William Gregory's trial and conviction, the U.S. 6th Circuit Court of Appeals in Cincinnati ruled Tuesday.

The court also questioned whether Louisville's police department used an unconstitutional practice of having witnesses identify suspects in one-on-one settings instead of in a lineup.

Gregory, 58, of Louisville, was released from prison in 2000 after DNA tests showed that hairs found at the rape scene could not have come from him. He sued the city and police department, but a federal judge in 2004 threw out most of the lawsuit.

Gregory said he hopes now to resolve the suit.

"I'm so excited, I don't know what to do with myself," he said. "The system is still flawed, but this restores some of my faith in the judicial system."

His attorney, Deborah Cornwall of the Innocence Project, a nonprofit organization that pushes for DNA exoneration, said the ruling shows Gregory's arrest and conviction were not a case of sloppy police work or a witness being wrong.

"It was the result of active misconduct," she said.

Bill Patterson, a spokesman for the Jefferson County attorney's office, declined to comment on specifics of the ruling because the case is pending.

"We'll be looking at it to determine what influence it will have over how we prepare for the next step in the case," Patterson said.

Louisville police kept preprinted waivers, allowing police to show a suspect to a victim or witness without putting the person in a lineup featuring multiple people.

Gregory claimed police used the waivers to avoid putting someone in a lineup because one-on-one identifications, by their nature, suggest a suspect. That violates the rights of a defendant, he said.

The appeals court said the use of one-on-one identifications is not illegal in all situations. But the court said a jury should decide whether the city had a practice of conducting the "show-up" identifications without regard to the constitutional implications of doing so.

Gregory also sued the city and individual police officers involved in his arrest and prosecution, claiming there was a lack of probable cause to arrest him. He charged that investigators withheld exculpatory evidence from him before trial.

The city argued that the officers and investigators who arrested Gregory were immune from being sued because everything they did was related to their later testimony during his 1993 criminal trial. Courts have generally granted immunity to witnesses who testify during a trial for things that happen inside the courtroom.

The three-judge appeals panel said the immunity does not apply to pretrial actions.