The Vanishing Mind Video: Watch the video, part of the series “The Vanishing Mind,” which examines the worldwide struggle to find answers about Alzheimer’s disease. Read more»

There are constant reminders of the outside world at the California Men’s Colony. The prison, nestled in the seaside mountains outside of San Luis Obispo, is routinely enveloped by a thick fog that rolls in from the ocean at dawn. Seagulls and other birds fly overhead, stop occasionally to perch on the razor wire encircling the yard, and fly away at a whim. The birds are a reminder of the world outside, which many people in this prison will never again experience.

Years ago, Joaquin Cruz killed a man who sold him fake cocaine, a crime that earned him a life sentence. Now he is so confused, his brain showing rapidly advancing signs of dementia, that he thinks he sees his brother when he sees his reflection in the toilet water. He can no longer perform routine tasks like showering or eating. Leon Baham, who is showing early signs of dementia but is reluctant to admit it, concedes he has days where he finds himself out in the yard, wondering how he got there. Another inmate is so confused that he needs to be reminded almost daily that he is incarcerated.

Prison life, strictly regimented and fraught with predatory behavior, is tough for even the hardest of criminals to maneuver. But for those with fading faculties, it can be a confusing place, where disorientation can be mistaken for insubordination.

Inmates serving life sentences with possibility of parole here have been trained to give the type of care typical of professional nurses for inmates suffering from dementia, head injuries and other mental disabilities. Dubbed “Gold Coats” because of the yellow coats they wear to set them apart from the standard prison blues, the men are paid $50 a month to help guide fellow inmates through the world. While they are not technically considered caretakers — they can’t clip fingernails, but they can file them — they are a crucial element to the survival of inmates who can no longer live on their own. They help them shower, eat, get medical care, and keep on track with their daily routines. They even help change adult diapers.

While the job has its perks — Gold Coats have a greater degree of mobility than other inmates — it also has its risks. Part of the job entails protecting the men from predators, which makes them snitches in some inmates’ eyes, setting them up for retaliation.

Todd Heisler/The New York Times

There are few programs like this in the United States, including one in Louisiana. Dementia is increasing rapidly in prison and the cost of hiring professionals to care for inmates is prohibitive for many states. New York is the only state that has created a special dementia unit with professional caregivers, but the cost is upwards of $90,000 a year for each inmate.

I visited the California prison twice last year with the multimedia producer Nancy Donaldson and science writer Pam Belluck, staying for about four days. The prison officials and inmates were incredibly open, allowing us to be there for some of the most intimate moments. The Gold Coats are eager to share their experiences and talk of the bonds they have created.

One afternoon in the yard, Philip Burdick gently filed Mr. Cruz’s nails. Another Gold Coat, James Evers, arrived with a boom box and played a Creedence Clearwater Revival song, one of Mr. Cruz’s favorites. The man who usually seems lost in another world clapped along. After seeing how they dote on their fellow inmates, it’s jarring to hear what landed the men in prison.

Walter Gregory — who’s losing his short-term memory and so looked forward to our visit that he got a haircut — recalls the day he mutilated his girlfriend in the 1970s as if it were yesterday. Interviews can be cut short by rolling lockdowns. There are occasional yard scuffles or inmate transfers that put everything at a standstill.

Yet every Gold Coat says the commitment to fellow inmates is a relationship is built on trust. “For us, this is not a job, you know?” said Samuel Baxter, who is fatally shot a co-worker six times and is looking at life in prison. “This is a part of our lifestyle.”

Todd Heisler is a staff photographer for The New York Times. He has written for Lens about space, Kodacrhome, Chris Hondros and chairs. Follow @nytimesphoto and @heislerphoto on Twitter.