It's a question that's occurred to many, if not all, pregnant women before going through with a vaginal delivery — how does something the size of a cantaloupe fit through an opening the size of a lemon?

That lemon, of course, is the birth canal, which is known to expand in size to accommodate a baby's head. And anyone who has seen a newborn fresh from a vaginal delivery knows the baby’s head shifts into something best described as a cone, before returning to its normal shape.

We’ve never seen how that actually occurs in real time — during labor — until now.

A woman gives birth inside an MRI machine so doctors could capture images of how her baby's head changes shape during delivery. Courtesy of Dr. Olivier Ami

Doctors at the University Hospital Center, in Clermont-Ferrand, France, captured MRI images in 3D of seven babies as they were making their way through the birth canal. That meant seven brave women had to give birth inside an MRI machine.

The images show exactly how parts of the infants' skulls overlap so the heads can be delivered vaginally. During this process, the brain is also compressed.

Doctors were surprised how much the brain was impacted. "When we showed the fetal head changing shape, we discovered that we had underestimated a lot of the brain compression during birth," Dr. Olivier Ami, who lead the new study, said.

It may sound medieval — and actually, it is. Babies have been born this way successfully since the beginning of humankind. And the vast majority of time, infants can endure this type of trauma without any issue.

Dr. Olivier Ami, left, and his team review MRI images of a baby during labor. Their hope is to identify babies who will have trouble during vaginal births before labor begins. Courtesy of Dr. Olivier Ami

But rarely, problems do occur. And that's exactly what the French obstetrics team focused on. "Sometimes there are brain hemorrhages, and we don’t know where (they) are coming from," Ami said.

"When that happens, the baby can have long-term brain development issues, like cerebral palsy," explained Dr. Hany Aly, chair of the department of neonatology at Cleveland Clinic Children's.

The question is which babies' heads will have trouble molding as they leave the uterus and enter the birth canal?

"We have no clues before delivery," Aly said. "We don’t know who will have this problem. We don’t know how to avoid it."

Doctors routinely monitor fetal heartbeats for signs of distress during a woman's labor, and perform emergency cesarean sections if necessary.

But the French research team's goal is to develop software imaging that would predict which babies are more susceptible to these complications before labor ever begins. Then doctors could schedule a C-section ahead of time, avoiding the problem entirely.

"This study is trying to target a very small number of babies — one in a thousand or less who might have a problem," Aly said.

Physicians stress that vaginal deliveries are overwhelmingly safe, and confer multiple health benefits, like exposing the babies to healthy bacteria that boost their immune systems.

There's no indication when researchers will be able to develop the software to predict which babies will have trouble during the labor process.

"We hope in the very near future, we will be able to counsel the women correctly, inform them, and choose the best delivery mode," Ami told NBC News.

"We would like to have more information to give women."

FOLLOW NBC HEALTH ON TWITTER & FACEBOOK