James McAvoy has revealed that he "nearly died" after a medical procedure to biopsy a shadow on his lung went wrong, causing his lungs to collapse.

During an appearance on Dax Shepard's "Armchair Expert" podcast, the 47-year-old actor described the terrifying ordeal. He explained that doctors had detected a shadow on his lung and opted for a biopsy to rule out cancer. "But that was botched, and I nearly died," McAvoy stated. "I was at home two days later and my lungs just collapsed in bed one night, and I was on my own as well, so it was crazy."

Following the incident, McAvoy was hospitalized for several weeks as medical professionals attempted to clear his lungs. "They tried everything to clean out," he recalled. "Nothing was working. So, they were like, 'We're going to need to cut you open big-style. Go in with like soapy, like dish soap basically, and just like clean you out, scoop it all out.'"

The health scare occurred before McAvoy began an intense physical transformation for his role as the Beast in the 2019 film "Glass." He spent four to five months working to regain his strength and build muscle. McAvoy explained that he needed a trainer who could help him achieve a physique reminiscent of mythological figures, as he was portraying the Beast for most of "Glass," a sequel to "Split" (2016) and part of the "Unbreakable" trilogy.

"The guy that worked with me was amazing," he said of his trainer. "He didn't move in with me, but he was just with me a lot and kind of regulated what I ate and trained me just right." For the initial four weeks, his trainer focused on rehabilitation, as McAvoy was unable to run, cycle, or jog. After that, the focus shifted to rapidly gaining weight.

McAvoy also recently shared an experience from the set of the HBO miniseries "Band of Brothers," where he claimed he was bullied by some castmates on his first day. He recalled that a group of actors pointed and laughed at him for several minutes, though he noted that other cast members, including Dexter Fletcher and Robin Laing, were supportive and included him.

Despite the difficult moments, McAvoy rated his overall experience on "Band of Brothers" as a nine out of 10, calling that particular day a "two."