SAN ANTONIO — After the explosion, Cpl. Sebastian Gallegos awoke to see the October sun glinting through the water, an image so lovely he thought he was dreaming. Then something caught his eye, yanking him back to grim awareness: an arm, bobbing near the surface, a black hair tie wrapped around its wrist.

The elastic tie was a memento of his wife, a dime-store amulet that he wore on every patrol in Afghanistan. Now, from the depths of his mental fog, he watched it float by like driftwood on a lazy current, attached to an arm that was no longer quite attached to him.

He had been blown up, and was drowning at the bottom of an irrigation ditch.

Two years later, the corporal finds himself tethered to a different kind of limb, a $110,000 robotic device with an electronic motor and sensors able to read signals from his brain. He is in the office of his occupational therapist, lifting and lowering a sponge while monitoring a computer screen as it tracks nerve signals in his shoulder.

Close hand, raise elbow, he says to himself. The mechanical arm rises, but the claw-like hand opens, dropping the sponge. Try again, the therapist instructs. Same result. Again. Tiny gears whir, and his brow wrinkles with the mental effort. The elbow rises, and this time the hand remains closed. He breathes.