Six years ago, Dr. Elizabeth Comen, a breast cancer specialist at Memorial Sloan Kettering Hospital in Manhattan, held the hand of a patient who was hours from death.

As Dr. Comen leaned in for a final goodbye, she pressed her cheek to her patient’s damp face. “Then she said it,” Dr. Comen recalled.

“‘I’m so sorry for sweating on you.’”

In her two decades as a physician, Dr. Comen has found that women are constantly apologizing to her: for sweating, for asking follow-up questions, for failing to detect their own cancers sooner.

“Women apologize for being sick or seeking care or advocating for themselves,” she said during an interview in her office: “‘I’m so sorry, but I’m in pain. I’m so sorry, this looks disgusting.’”

These experiences in the exam room are part of what drove Dr. Comen to write “All in Her Head: The Truth and Lies Early Medicine Taught Us About Women’s Bodies and Why It Matters Today.” In it, she traces the roots of women’s tendency to apologize for their ailing or unruly bodies to centuries of diminishment by the medical establishment. It’s a legacy that continues to shape the lives of women patients, she argues.

Today, women are more likely to be misdiagnosed than men are and take longer to be diagnosed with heart disease and some cancers; they may be less likely to be offered pain medication; their symptoms are more likely to be written off as anxiety — or, as the book title suggests, as being all in their head.

“The anxious female, the hysterical female, has been a ghost looming and woven through all of medical history,” Dr. Comen said. “It’s a default diagnosis.”

Collectively, she argues in the book, these injustices help to explain why many women report feeling invisible, frustrated or ashamed in doctors’ offices. Shame may be the symptom, but Dr. Comen believes that a deeply misogynistic medical system is the disease.

A mother of three in her mid-40s, Dr. Comen is quick with a camera-ready smile, which has helped to make her a regular in media coverage of breast cancer. She occasionally tears up when discussing her patients.

She once wept on the job in medical school, and a male resident responded by telling her to “pull herself together.”

“I felt like I had to excuse my response,” she said, sitting behind her desk. “And now I cry with patients all the time.”

Her approach has been shaped by decades of experience, as well as by what she learned about the female body’s place in medicine while majoring in the history of science as an undergraduate at Harvard.

“The sense that women’s bodies were not just different but broken is obvious not just in the way doctors spoke of the female anatomy but in the medical vocabulary itself: the female external genitalia was termed ‘pudenda,’ a Latin word that means ‘things to be ashamed of,’” she writes.

In “All in Her Head,” Dr. Comen offers a sweeping look at the ways in which she says modern medicine has disregarded women. For centuries, she writes, early medical authorities believed that women were merely “small men” — though lacking external genitals and comparable mental capacity, ruled by noxious humors and hormones.

For too long, doctors dismissed “what could be legitimate physiological problems as irrelevant, as hormonal, and therefore not important,” said Wendy Kline, a professor of the history of medicine at Purdue University.

And this was the case for white women of means, Dr. Comen writes in the book. If you were a woman of color, or you were poor, you were viewed by medical authorities as even less of an authority on your own body, and thus less worthy of care and compassion.

“For Black women, when we go into a clinical setting, we have to think about racial and gender discrimination,” said Keisha Ray, an associate professor of humanities and bioethics at UTHealth Houston, who studies the effects of institutional racism on Black people’s health. “It tends to be more exaggerated, the lack of compassion and the lack of care that you receive.”

Take heart disease, for example. In the late 19th century, Dr. William Osler, one of the founding fathers of modern medicine, declared that women presenting with what we now know to be symptoms of heart attacks or arrhythmias — including shortness of breath and palpitations — were almost certainly suffering from “pseudo angina,” or false angina, “a collection of neurosis-induced symptoms masquerading as genuine disease,” Dr. Comen writes.

It’s only in the past 25 years that cardiology studies have included women in significant numbers. Today, some heart attack symptoms that are more common in women, such as jaw and back pain, are still described as “atypical” simply because doctors don’t see them as often in men, and are less likely to be taken seriously, even though 44 percent of women will develop heart disease at some point in their life and one in five women will die from it.

“We have used the male model for diagnosis, for treatment, as the gold standard,” said Dr. Jennifer Mieres, a cardiologist with Northwell Health and co-author of the book “Heart Smarter for Women.” This has “led to continued misrepresentation, misdiagnosis, under-recognition of heart attack in women.”

In each chapter of “All in Her Head,” Dr. Comen interviews physicians who are working to improve the system, starting with taking female patients’ complaints seriously — not just chalking up physical symptoms, from chest pain to fatigue to gastrointestinal discomfort, to anxiety until all other causes area ruled out, for example.

Dr. Comen also shares practical tools to better partner with an imperfect system.

First, she writes, it’s essential for all patients to trust their knowledge of their own bodies and advocate for themselves. Before an appointment, ask yourself: What truly concerns you about your body?

“Not what you think you should be worried about,” Dr. Comen writes. “Not what you think your doctor will be able to most comfortably and easily address.”

Next, if you feel anxious about your health or that you’re not being heard, enlist a friend or family member to accompany you to appointments. This person can serve as an advocate and an extra set of eyes and ears.

Finally, if you don’t like your doctor, find a new one. This can be easier said than done, she acknowledged, but a trusting and respectful relationship with your health care provider is every patient’s right.

Audio produced by Sarah Diamond.