Not much has changed since Nellie Bly. Several are still locked up with no jury trial - just a rubber stamp by a magistrate to whatever the prosecutor asks for - the modern day equivalent being a cut and paste between Word documents.
Nelly Bly was an investigative reporter who was committed to an asylum by a judge, more at linked page. In the US, for decades, jails hold many more mentally ill people than psychiatric facilities do.