(a) In no civil case can an inmate be removed from the penitentiary to give personal attendance at court, but testimony may be taken by deposition, as in other cases, the party seeking the testimony being required to make affidavit that the inmate is a material witness in the cause.
(b) The defendant in a state prosecution may, in like manner, take the testimony of a inmate in the defendant's behalf, notice being given to the district attorney general of the time of taking the deposition.