It’s the rare person who counts his blessings upon learning he’s “face to face with dying.” But Oliver Sacks did just that.

In January, Sacks, the neurologist and author of such books as “Awakenings” (1973) and “Musicophilia” (2007) was diagnosed with terminal cancer. During the months before his death in August, Sacks wrote a series of heart-rending yet ultimately uplifting essays. In them, he shared his thoughts about how he wished to live out his days and about his feelings on dying. Now collected in a beautiful little volume, “Gratitude” is a lasting gift to readers.

What was Sacks most thankful for? “I have loved and been loved,” he wrote. “I have been given much and I have given something in return. . . . Above all, I have been a sentient being, a thinking animal, on this beautiful planet, and that in itself has been an enormous privilege and adventure.”

After learning his bleak prognosis, he wrote: “I feel a sudden clear focus and perspective. There is no time for anything inessential. I must focus on myself, my work, and my friends.” By the wayside went time spent on news, politics and arguments about global warming. Such things, he wrote, “are no longer my business; they belong to the future.”

Sacks was an immoderate enthusiast and risk taker with a brilliant, far-ranging mind. His embrace of the wonders of life comes through in his case studies, which he chronicled in one extraordinary, eye-opening book after another, such as “The Man Who Mistook His Wife for a Hat” (1985) and “An Anthropologist on Mars” (1995). He wrote more personally of his sometimes reckless passions for chemistry, long-distance swimming, weightlifting and motorcycling in his memoirs “Uncle Tungsten” (2001) and “On the Move,” which was published in April.

“Gratitude” by Oliver Sacks. (Knopf)

In these final essays, Sacks again addresses his Orthodox Jewish upbringing and his sexuality, which he discussed in “On the Move.” His mother’s ferocious reaction to his homosexuality when he was 18 contributed to his break from formal religion and his native England, where he felt he could not live openly. It was not until he was 75 that he happily, gratefully found love with writer and photographer Bill Hayes. Hayes’s photographs of Sacks in his last two years — swimming in Iceland, writing with intense concentration — complement “Gratitude.”

Sacks was an adventurer and a scientist. In times of stress, he found comfort in the elements of the periodic table. Dying, he again surrounded himself, “as I did when I was a boy, with metals and minerals, little emblems of eternity.” On his writing table he kept element 82 (lead), a souvenir of his 82nd birthday, along with bismuth, element 83, in anticipation of his 83rd — although he didn’t think he’d live to see it. He was right: He died at 82.

His innate scientific curiosity was aroused even by his own illness. Yet unlike other writers who have reported from the front lines of mortality, Sacks did not focus on his illness, his medical ordeal or spirituality, but on “what is meant by living a good and worthwhile life — achieving a sense of peace within oneself.”

Sacks not only achieved that peace but managed to convey it beautifully in these essays. He found positive ways to think about everything, including his growing frailty: Perhaps, he suggests in the book’s final pages, he was in the Sabbath of his life, “when one can feel that one’s work is done, and one may, in good conscience, rest.” His tender book leaves readers with a similar sense of tranquility and, indeed, gratitude.

McAlpin reviews books regularly for The Washington Post, NPR and the Los Angeles Times.

gRATITUDE

By Oliver Sacks

Knopf. 49 pages; $17