A federal appeals court on Thursday upheld a Kentucky law that requires doctors to have a pregnant woman undergo an ultrasound, view its images, and listen to the fetal heartbeat before having an abortion.

The judges, from the 6th Circuit, ruled 2-1 that the law did not violate a doctor's First Amendment rights to free speech, writing that the information gleaned from an ultrasound was "pertinent" to a woman's decision-making.

"The information conveyed by an ultrasound image, its description, and the audible beating fetal heart gives a patient greater knowledge of the unborn life inside her," wrote Judge John Bush, a nominee of President Trump. "This also inherently provides the patient with more knowledge about the effect of an abortion procedure: it shows her what, or whom, she is consenting to terminate."

Bush leaned on the Supreme Court decision Planned Parenthood v. Casey to bolster his position, saying the law allowed states to regulate abortion. The ruling set a standard that state laws could not pose an "undue burden" on a woman's access to abortion.

Judge Bernice Bouie Donald, a nominee of President Barack Obama, dissented in the decision, saying the regulation compels speech.

The Kentucky law allows women to look away from the ultrasound screen and to ask the doctor to turn off the sounds. Doctors who don't comply with the law can be fined and referred to Kentucky's medical licensing board.

The Supreme Court previously declined to take up cases challenging ultrasound laws, and they have been struck down in lower courts.

Judge David Hale, also an Obama nominee, previously had struck down the Kentucky law to rule in favor of the plaintiff, the EMW Women's Surgical Center in Louisville. Hale agreed with the plaintiffs that the law violated free speech protections and also cited concerns over causing psychological harm. The court blocked the law from going into effect.

The American Civil Liberties Union had challenged the law on behalf of the clinic, which is Kentucky’s only abortion provider. The decision to appeal the ruling came from the administration of Republican Gov. Matt Bevin, who had signed the bill into law.

This year Kentucky passed a six-week abortion bill into law and another bill that would prohibit women from seeking an abortion on the basis of the fetus' race, sex, or disability. Both laws have been blocked while they are being challenged in court.