Every person imprisoned in any correctional institution or otherwise restrained of his or her liberty, other than persons imprisoned or restrained pursuant to a final judgment entered in a criminal proceeding, may prosecute a writ of habeas corpus, according to the provisions of this chapter, to obtain relief from the imprisonment or restraint, if it shall prove to be unlawful.
R.I. Gen. Laws § 10-9-1