(CNN) A toy-like cardboard contraption that sells for less than $20 online has helped save the life of a baby who was so sick that doctors told her parents to take her home to die.

Google Cardboard looks like a set of big square goggles. Stick your iPhone inside and with the right app, you can see images in three-dimensional virtual reality.

Doctors at Nicklaus Children's Hospital in Miami used the device to map out an operation they say they couldn't have envisioned otherwise.

On Wednesday, four weeks after her surgery, baby Teegan was taken off a ventilator and is breathing on her own. Doctors expect her to go home within the next two weeks and make a full recovery.

"It was mind-blowing," says Cassidy Lexcen, the baby's mother. "To see this little cardboard box and a phone, and to think this is what saved our daughter's life."

Here's how it was done:

Missing one lung and half a heart

Teegan Lexcen was born in August with a heart and lung defect so unusual that doctors had never seen it before. She has only one lung, and almost all of the left half of her heart is missing.

Her parents, Cassidy and Chad Lexcen, say their doctors in Minnesota told them there was nothing they could do. Soon after she was born, they sent her home with a hospice nurse and medications to make her as comfortable as possible.

Teegan Lexcen

When Teegan was still alive two months later, her parents wondered whether the doctors had been right. They started searching for a second opinion.

The Lexcens found out that a friend of a friend of a friend was a nurse in a cardiac intensive care unit in Boston. They made contact, and doctors asked them to send images of Teegan's heart taken at the Minnesota hospital.

Elated, the Lexcens sent the images to Boston. Two weeks passed and they didn't hear anything. Cassidy sent an email, politely reminding them that time was of the essence. She received an apologetic note back, saying there had been a communications glitch, and someone would get back to her soon.

The Lexcens knew that soon might not be soon enough. Teegan has a twin sister, Riley, who was growing steadily, while Teegan stayed tiny. It was a constant reminder of how poorly her heart was working.

"I felt like we were racing against the clock," Cassidy said.

It was around that time that Chad's sister found an article entitled "The 20 Most Innovative Pediatric Surgeons Alive Today."

No. 3 was Dr. Redmond Burke, the chief of cardiovascular surgery at Nicklaus Children's Hospital in Miami.

Chad's sister reached out and heard back immediately. Please send images immediately, a nurse told her. We'll see what we can do.

A broken 3-D printer comes to the rescue

Three times a week, 30 cardiac doctors and nurses sit in a room at Nicklaus Children's Hospital and discuss the treatment road maps for their patients and for children who might become their patients.

"The arc of people's lives get determined in these conferences," Burke said.

On a Wednesday morning in November, they looked at pictures of Teegan's heart.

Like the doctors in Minnesota, the doctors in Miami had never seen a child who was missing a lung and nearly half a heart. They threw out ideas about possible surgeries to help her. No one had a definitive plan. Some were skeptical that they could do anything.

Burke asked Dr. Juan Carlos Muniz, a pediatric cardiologist who specializes in imaging, to make a 3-D model of Teegan's heart. It had helped in complicated cases before.

A few hours later, Muniz reported bad news: Their 3-D printer was broken. "Technology always goes on the fritz at the worst possible time," he lamented.

Photos: Teegan, left, and Riley Lexcen were born in August. Hide Caption 1 of 7 Photos: Teegan was born with only one lung and half of a heart. Hide Caption 2 of 7 Photos: But then a new team of surgeons at Nicklaus Children's Hospital in Miami created a 3-D virtual reality image of Teegan's heart using a Google Cardboard app. "We said, 'Wait a second. We can figure this out, " said Dr. Anthony Rossi. Hide Caption 3 of 7 Photos: Doctors in Minnesota thought there was no operation available to save Teegan (left) and sent her home to die. Hide Caption 4 of 7 Photos: Teegan ahead of her heart surgery operation. Hide Caption 5 of 7 Photos: Teegan in the cardiac intensive care unit after her operation. Hide Caption 6 of 7 Photos: Teegan recovering at Nicklaus Children's Hospital in Miami. Hide Caption 7 of 7

But it turned out to be the best possible time, because it forced Muniz to come up with an option that worked better.

He'd been chatting with Dr. David Ezon, a pediatric cardiologist at the University of Pittsburgh Medical Center, about using virtual reality -- mainly used for playing video games -- for children's hearts.

After that discussion, Muniz bought a Google Cardboard device and had been playing with it in his office. With the broken printer, now was the time to use it for real, he decided.

Using an app called Sketchfab , Muniz downloaded images of Teegan's heart onto his iPhone and showed them to Burke.

They were similar, yet different from 3-D images they'd been using on computer screens. With the goggles, it was possible to move around and see the heart from every angle -- to almost be inside the heart checking out its structure.

Burke looked through the Google Cardboard, and visualized what he could do to fix Teegan's heart.

Making the difference between life and death

On December 10, 4-month-old Teegan lay on an operating table in Miami.

The first challenge was how to get to her heart. Normally, the heart is in the center of the chest, and to access it doctors make what's called a midline incision, cutting from the top to the bottom of the breastbone.

But Teegan's heart wasn't normal. It was far to the left side of her chest. Before using Google Cardboard, Burke feared he would have to make what's called a clamshell incision, which is a midline incision plus another cut going from the center of her chest all the way to the left side.

"It's massive trauma to a baby -- it's just horrendous," Burke said.

He was worried Teegan wouldn't survive it. "She was dwindling away. She'd been slowly dying for three months," he said.

That's where Google Cardboard proved advantageous over 3-D printing. The printer would have given Burke just her heart -- but to access her heart surgically, he needed to be able to visualize it in context with her ribcage and other structures.

With the use of the virtual image, Burke figured out a way to do just the normal midline incision and spare her the dreaded clamshell cut.

Once he was inside her chest, he says, Google Cardboard helped him out again.

A normal heart has two ventricles . The right one supplies blood to the lungs, and the left one supplies blood to the rest of the body.

But Teegan has only a right ventricle. It had been doing the work of both, but it couldn't do it for much longer. "The right ventricle is the wimpier, weaker ventricle, and if ventricles could talk, it would say 'I can't do this. I'm not designed for this job,'" Burke said.

The usual surgeries on children with only one ventricle wouldn't work on Teegan because of her unique defects and anatomy. Using the virtual image, Burke invented a new surgery, shoring up and rerouting her one ventricle so it could do the work of both ventricles long term.

Figuring all this out was something he had to do before he actually opened her up -- every minute wasted in the operating room trying to map out a plan puts a baby at higher risk for heart and brain damage.

The night before Teegan's surgery, Burke lay in bed imagining her heart based on the Google Cardboard image, mapping out the precise steps he would take in the operating room.

When he opened her up the next day, her heart was exactly the same as the image. He proceeded with no surprises. "Sometimes that's what makes the difference between life and death," he said.