
50 Cal.Rptr.3d 677 (2006)
144 Cal.App.4th 678
The PEOPLE, Plaintiff and Appellant,
v.
Vincent Edward CALLAHAN, Defendant and Respondent.
No. A112067.
Court of Appeal of California, First District, Division One.
November 6, 2006.
As Modified November 9, 2006.
*678 Bill Lockyer, Attorney General of the State of California, Robert R. Anderson, Mary Jo Graves, Chief Assistant Attorneys General, Gerald A. Engler, Senior Assistant Attorney General, Eric D. Share, Supervising Deputy Attorney General, Amy Haddix, Deputy Attorney General, Attorneys for Plaintiff and Appellant.
Eleanor M. Kraft, Esq., Attorney for Defendant and Respondent.
MARCHIANO, P.J.
The People appeal from an order awarding defendant Vincent Edward Callahan pretrial custody credits under Penal Code sections 2900.5 (actual custody credit) and 4019 (conduct credit).[1]
This case involves the computation of credits from two parallel proceedings in our justice system. While confined at Napa State Hospital (NSH) on a 1997 insanity commitment under section 1026, defendant was charged with battery upon a hospital guard in 2004. He was found incompetent to stand trial (§ 1368) during those criminal proceedings. Based on the incompetency finding, the trial court imposed an incompetency commitment of a maximum of three years (§ 1370, subd. (c)(1)). The court awarded credit for time served for pretrial confinement related to the criminal charge. The People contend that defendant is entitled to no custody credit because his liberty was already restrained by the insanity commitment regardless of pretrial confinement on the new criminal charge. The People also contend defendant is not entitled to conduct credit for time spent in the nonpenal confines of a state hospital. We agree and reverse.

I. FACTS
Defendant was arrested in February 1995 for unlawful transportation of marijuana *679 (Health & Saf.Code, § 11360), and unlawful transportation of a controlled substance (Health & Saf.Code, § 11377). While incarcerated he was further charged with three counts of assault on a peace officer (§ 241, subd. (b)), and one count of battery on a peace officer (§ 243.1). On March 14, 1997, he was found not guilty by reason of insanity (NGI) and committed to Patton State Hospital pursuant to section 1026. He was transferred to NSH on October 29, 1997, for treatment, where he remains at the present time.
On September 13, 2004, the District Attorney of Napa County filed a criminal complaint charging defendant with felony "battery by `gassing'" upon the person of a peace officer while confined in a local detention facility (§ 243.9, subd. (a)).[2] The record suggests that defendant spat in the face of a peace officer working as a guard at NSH, and said "Welcome to the world of Hep B and Hep C"an apparent reference to hepatitis.
On September 28, 2004, the trial court arraigned defendant on the complaint, set bail at $50,000, and ordered him "returned to the custody of the Sheriff ... [t]o remain housed at NSH."[3]
On October 7, the trial court suspended criminal proceedings under section 1368 and ordered a psychological evaluation to determine whether defendant was competent to stand trial. On October 19, Dr. Richard Geisler submitted a report concluding that defendant was incompetent to stand trial.
On October 28, the trial court found defendant incompetent to stand trial and ordered that he remain housed at NSH. On November 3, the Napa County Health and Human Services Agency's Conditional Release Program (CONREP) submitted a placement report recommending as follows: "[Defendant] is a mentally ill man ... [who] was committed to [NSH] pursuant to [section] 1026 at the time [of the charged offense]...." Defendant "has a long history of severe mental illness, drug abuse/alcoholism, and violence.... [T]he Napa County CONREP program respectfully recommends that [defendant] remain committed to [NSH] ... for competency treatment until such time as he becomes competent or can safely and effectively be treated at a less restrictive facility."
On November 16, the court committed defendant to NSH for a period not to exceed three years, or until his mental competency has been restored. (§ 1370, subd. (c)(1).) The court reserved jurisdiction over the issue of custody credit.
From November 17 to July 27, 2005, defendant remained at NSH under the incompetency commitment, "being held under [section] 1368." On July 27, 2005, the court found that defendant had been restored to competency and reinstated the criminal proceedings.[4] Defendant had been "returned [to court] from the state hospital" and apparently had been briefly held in the jail. Defense counsel requested that defendant be returned to NSH "where he's been for the last seven or eight years." Neither the court nor the *680 People had any objection, and the minute order stated that the "[c]ourt has no objection to the Defendant being housed at [NSH]."
On August 5, defendant was held to answer on the complaint, and the district attorney filed an information that same day. The court set bail at $50,000 and ordered that "[d]efendant is returned to custody to be held at NSH."[5]
On August 17, the trial court again suspended proceedings under section 1368 and ordered a psychological evaluation of defendant's competency to stand trial. Apparently, defendant had not been returned to NSH on August 5, but had remained at the jail between August 5 and August 17. At the August 17 hearing, the People objected to defendant being returned to NSH, but the court again stated it had no objection to NSH housing. On August 25, Dr. Geisler again evaluated defendant's competency, apparently at the jail.
On August 31, the trial court again found defendant incompetent and again referred the matter to CONREP for a placement report. Defendant was apparently still housed at the jail, over defense objection. The court returned defendant to the custody of the sheriff, but declined to order him transferred to NSH.
On September 12, the trial court again committed defendant to NSH for a period not to exceed three years or until his mental competency had been restored. The court awarded defendant 398 days of credit for time served: 350 days of actual custody credit (§ 2900.5), and 48 days of conduct credit (§ 4019).
The 350 days of actual custody credit is broken down as follows: (A) 50 days for the pretrial confinement prior to the November 16, 2004 finding of incompetency (presumably the time between the September arraignment and November 16, 2004); (B) 253 days while he was held on the incompetency commitment from November 17, 2004, to July 27, 2005; and (C) 47 days for the period of pretrial confinement after his competency was restored, i.e., from July 28, 2005, to September 12, 2005.
In awarding the custody credit, the court reasoned that once bail was set in the criminal case, defendant was in custody or in pretrial detention on the criminal case, "wherever he's housed." Even though defendant spent most of the pretrial confinement in NSH, the court believed he was "in jail as far as I'm concerned."
The court's calculation of 48 days of conduct credit derives from the 97 days of actual custody when defendant was competent. The court did not award conduct credit on the 253 days defendant spent in NSH while incompetent.

II. DISCUSSION
The People contend that defendant is not entitled to actual custody credit for pretrial confinement on the new criminal charge because he remained confined under the unrelated insanity commitment. The People also contend that defendant is not entitled to conduct credit. We agree with both arguments for the following reasons.

Actual Custody Credit (§ 2900.5)
Section 2900.5 provides that a defendant be given credit against his sentence for time spent in pretrial custody. (§ 2900.5, subd. (a).) The legislative purpose *681 of the statute is "to eliminate the unequal treatment suffered by indigent defendants who, because of their inability to post bail, served a longer overall confinement than their wealthier counterparts. [Citations.]" (In re Rojas (1979) 23 Cal.3d 152, 155-156, 151 Cal.Rptr. 649, 588 P.2d 789 (Rojas).)
The statute implements principles of equal protection. "Denial of credit for precommitment confinement results in discrimination on the basis of wealth in violation of state and federal equal protection guaranties because indigent defendants who are unable to obtain release on bail will serve precommitment jail time and so will be confined longer than wealthier defendants who are released on bail.... [Citations.]" (In re Banks (1979) 88 Cal. App.3d 864, 867, 152 Cal.Rptr. Ill (Banks).)
Because of statutory requirements and constitutional concerns, section 2900.5 applies to more scenarios than the typical one, i.e., credit for jail custody against sentences on criminal convictions. (See Rojas, supra, 23 Cal.3d at p. 156, 151 Cal.Rptr. 649, 588 P.2d 789.) For instance, a defendant who is found incompetent to stand trial, but recovers his competency and is convicted, is entitled to credit against his sentence for pretrial custody in a state hospital after the finding of incompetency. (People v. Cowsar (1974) 40 Cal. App.3d 578, 579, 115 Cal.Rptr. 160.) A criminal defendant who is found incompetent to stand trial and who does not recover his competency, and who suffers a three-year incompetency commitment, is entitled to actual custody credit for pretrial confinement prior to the incompetency commitment. (Banks, supra, 88 Cal. App.3d at pp. 867-869, 152 Cal.Rptr. Ill; § 1370, subd. (a)(3)(C).)
And a defendant who is committed to a state hospital under a section 1026 insanity commitment is entitled to credit against the maximum term of that commitment "for the actual time [ ] spent in [pretrial] confinement, including the time [ ] spent [at a state hospital] during the suspension of criminal proceedings" due to incompetency to stand trial. (People v. Smith (1981) 120 Cal.App.3d 817, 822, 175 Cal. Rptr. 54 (Smith); § 1026, subd. (e)(3).)
But those cases involve pretrial confinement attributable solely to the conduct which led to the ultimate criminal conviction, incompetency commitment, or insanity commitment. The case before us is different because defendant's pretrial confinement was pursuant to the 1997 NGI commitment under section 1026. Pretrial custody on the new criminal charge of battery on the hospital guard is, in essence, another formalistic layer of custody which, if stripped away by the ability to make bail, would not have resulted in defendant's liberty. He would have remained confined on the 1026 commitment and thus is not entitled to the actual custody credit awarded by the trial court.
Section 2900.5, subdivision (b), provides that "credit shall be given only where the custody to be credited is attributable to proceedings related to the same conduct for which the defendant has been convicted."
This language has triggered a veritable feast of discussion in the reported cases, which we need not review at any length because we can look to our Supreme Court for guidance. The Supreme Court has distilled a rule of strict causation: "a prisoner is not entitled to credit for presentence confinement unless he shows that the conduct which led to his conviction was the sole reason for his loss of liberty during the presentence period." (People v. Bruner (1995) 9 Cal.4th 1178, 1191, 40 Cal.Rptr.2d 534, 892 P.2d 1277 *682 (Bruner), italics added; see In re Joyner (1989) 48 Cal.3d 487, 493-495, 256 Cal. Rptr. 785, 769 P.2d 967 (Joyner); Rojas, supra, 23 Cal.3d at p. 156, 151 Cal.Rptr. 649, 588 P.2d 789.)
Or, stated another way, "where a period of presentence custody stems from multiple, unrelated incidents of misconduct, such custody may not be credited against a subsequent formal term of incarceration if the prisoner has not shown that the conduct which underlies the term to be credited was also a `but for' cause of the earlier restraint." (Bruner, supra, 9 Cal.4th at pp. 1193-1194, 40 Cal.Rptr.2d 534, 892 P.2d 1277.) The essence of the rule is this: "Section 2900.5 does not authorize credit where the pending proceeding has no effect whatever upon a defendant's liberty." (Rojas, supra, 23 Cal.3d at p. 156, 151 Cal.Rptr. 649, 588 P.2d 789.)
In the present case, the award of actual custody credit does not pass the strict causation test. Regardless of the pretrial confinement on the new criminal charge of battery, defendant would have continued to suffer deprivation of his liberty because of the ongoing insanity commitment. He would not have been freed "but for" his inability to post bail on the criminal charge. Thus the principles of equal protection which underlie the cases discussed above do not dictate an award of actual custody credit.
Defendant argues, in essence, that the strict causation rule of Bruner, Joyner, and Rojas does not apply because the prior deprivation of defendant's liberty independent of the new criminal charge was not a criminal sentence, but a civil insanity commitment. This is a distinction without a difference. The question is not the type of liberty deprivation, but the fact of the liberty deprivation itself. Logically, the key question is whether defendant would have been free if he had sufficient funds to make bail on the new criminal charge. If he would have remained in custody in any case, regardless of the characterization of that custody as criminal or civil, he is simply not entitled to actual custody credit. The trial court's conclusion that defendant was essentially "in jail" on the new criminal charge, regardless of whether he was housed in NSH or the jail itself, overlooks the applicable strict causation rule.[6]

Conduct Credit (§ 4019)
Section 4019 allows an award of conduct credit for good behavior in pretrial custody in a city or county jail, industrial farm, or road camp. But conduct credit is not awarded for time spent in nonpenal institutions such as state hospitals. (People v. Buckhalter (2001) 26 Cal.4th 20, 30, 108 Cal.Rptr.2d 625, 25 P.3d 1103, fn. 6 (Buckhalter); Waterman, supra, 42 Cal.3d at p. 571, 229 Cal.Rptr. 796, 724 P.2d 482; People v. Sage (1980) 26 Cal.3d 498, 502-503, 165 Cal.Rptr. 280, 611 P.2d 874.)
Specifically, conduct credit cannot be awarded for pretrial confinement on a finding of incompetency to stand trial, because sentence credits for good behavior are "particularly inconsistent" with the therapeutic goals of treating a defendant so that his competency can be restored. (Waterman, supra, 42 Cal.3d at p. 570, 229 Cal.Rptr. 796, 724 P.2d 482.) "The purpose *683 of confinement is to restore the mental ability to stand trial.... [T]hat goal would be hindered if mere institutional good behavior and participation automatically reduced the therapy period. [Citation.]" (Ibid.) In short, the therapeutic purpose of incompetency confinement in a state hospital has little if anything to do with the statutory conduct credit incentive available to a competent criminal defendant held in jail prior to trial. The therapy must not be artificially shortened by a factor unrelated to psychiatric concerns. (See Smith, supra, 120 Cal.App.3d at pp. 822-824,175 Cal.Rptr. 54.)
Thus the trial court in the present case correctly refused to award conduct credit for the 253 days defendant spent in NSH while incompetent. The question is whether the trial court erred by awarding conduct credit for the 97 days defendant was held in NSH while competent. We hold the court improperly awarded the credit for the following reasons.
The People argue the trial court awarded the conduct credit because the court believed that defendant was essentially in the constructive custody of the jail while undergoing competency treatment at NSH. The court did indicate that it believed defendant was in jail even though housed at NSH. However, we see no basis for the court's conclusion. A state prisoner temporarily held in a local jail to make court appearances remains in the constructive custody of the state prison authorities. (Buckhalter, supra, 26 Cal.4th at pp. 33-34, 108 Cal.Rptr.2d 625, 25 P.3d 1103.) By parity of reasoning, defendant remained in the custody of NSH whether housed there or in the jail after the filing of the new criminal charge. The original deprivation of liberty, i.e., the insanity commitment, forms the foundation for defendant's custody status.
We come to the essential point: apart from a very short period of time spent in the jail, defendant was housed at NSH pursuant to his insanity commitment while awaiting trial on the criminal charge. He was not being confined for punishment, but for treatment. For the reasons discussed above, the therapeutic purposes of defendant's confinement on his insanity commitment are inconsistent with an award of credits based on good behavior. The rationale for conduct credit is not pertinent to the context of psychiatric treatment. Defendant's confinement was nonpenal and treatment-oriented. Section 4019 simply does not apply.[7]

III. DISPOSITION
The order awarding defendant 398 days of credit for time served is reversed. The court accordingly is ordered to correct its records.
STEIN and SWAGER, JJ., concur.
NOTES
[1]  Subsequent statutory citations are to the Penal Code unless otherwise indicated.
[2]  "Gassing" is defined as "intentionally placing or throwing, or causing to be placed or thrown, upon the person of another, any human excrement or other bodily fluids or bodily substances or any mixture containing human excrement or other bodily fluids or bodily substances that results in actual contact with a person's skin or membranes." (§ 243.9, subd. (b).)
[3]  Subsequent dates are in 2004 unless we indicate otherwise.
[4]  Subsequent dates are in 2005 unless we indicate otherwise.
[5]  This quote is from the court's August 5 minute order. The reporter's transcript of August 5 shows that the court stated it had no objection to NSH housing if the jail and NSH had no objection.
[6]  Defendant's reliance on People v. Waterman (1986) 42 Cal.3d 565, 229 Cal.Rptr. 796, 724 P.2d 482 (Waterman) is misplaced. Defendant relies on a passage from Waterman that simply states the rule that a defendant found incompetent, but whose competency is restored is entiled to actual custody credit against his sentence for the time spent in hospital confinement. (Id. at p. 568, 229 Cal. Rptr. 796, 724 P.2d 482.) That is not the issue here.
[7]  We note that there is authority that finds no equal protection violation in depriving a defendant conduct credit against an insanity commitment even for pretrial jail custody when the defendant was competent. (People v. Campos-Castillo (1986) 176 Cal.App.3d 926, 928-931, 222 Cal.Rptr. 440; Smith, supra, 120 Cal.App.3d at pp. 825-826, 175 Cal. Rptr. 54.) Because of our resolution of the issues before us, we need not discuss these cases further.
