A federal judge on Thursday threw out a copyright lawsuit against M. Night Shyamalan and Apple, which had accused him of stealing elements from a 2013 independent film for his Apple TV Plus series “Servant.”

Judge John F. Walter ruled that the TV show is not similar enough to the film, “The Truth About Emanuel,” to merit a lawsuit.

“In sum, the alleged similarities between the works pale in comparison to the differences in the plot, themes, dialogue, mood, setting, pace, characters, and sequence of events, and the Court concludes that the works at issue are not substantially similar as a matter of law,” Walter wrote.

Francesca Gregorini, the writer and director of “The Truth About Emanuel,” filed the suit in January, accusing Shyamalan of lifting her story and “bastardizing” it through a male gaze.

Both works are about a grieving mother who cares for a doll as if it were a real child, and her relationship with a female baby-sitter.

But Walter ruled that sharing a premise is not a violation of copyright law.

“Beyond this unprotectable shared premise, the works’ storylines diverge drastically and quickly,” the judge wrote.

For instance, in “Servant,” the doll comes back to life. The judge also cited stark contrasts in theme and mood, saying that “Servant” proves to be much darker, verging on horror, while “The Truth About Emanuel” is “hopeful and positive,” exploring themes of redemption and healing.

The judge ruled that the plaintiff had overstated the similarities between the characters, the setting, and other aspects.

Walter dismissed the suit with prejudice, meaning that Gregorini cannot amend and refile it.

Update, 3:26 p.m.: Gregorini has issued a statement vowing to appeal.

“Today’s ruling is disappointing, but not surprising. The balance of power in the entertainment industry has always favored powerful men and institutions. Their ultimate goal is to silence anyone whose work they steal and repurpose without credit.

“’The Truth About Emanuel’ is a very personal labor of love. It took me years to write, finance, and direct. To have all that work stolen is not only hurtful, it disregards all the hard work needed to bring Emanuel to the screen. Unfortunately, this is the status quo in the entertainment industry. Powerful, mostly male, forces work to take what they want from other creators and repurpose it as their own. Throughout this process, I’ve heard from countless other filmmakers whose work has been stolen without permission. And this is M. Night Shylaman’s third time being accused of unlawfully taking others’ work. Where there is smoke, there is fire.

“My case is an attempt to hold those powerful forces accountable and protect the work of so many talented voices who are not as rich and powerful as M. Night Shyamalan. I hoped for a different outcome. I will not allow this to silence me. I intend to appeal this ruling and continue to make my case that ‘Servant’ and ‘The Truth About Emanuel’ share similarities that were undoubtedly and knowingly plagiarized.”