Changes meant to help schools overhaul their special education programs have instead left principals scrambling for a budget fix.

Middle and high school principals are learning this week that the Department of Education is planning to take back thousands of dollars earmarked to help their schools serve students with special needs — over a budget technicality.

“Students with disabilities are the ones who lose out in this — and schools’ ability to provide what [students] need,” said a principal whose school faces a cut.

The issue stems from a new funding formula adopted this year as part of the Department of Education’s efforts to bring students with disabilities out of self-contained classes whenever possible.

Previously, schools received funding based on the number of their students assigned to different kinds of special education classes. Students in self-contained special education classes brought one amount, while students who were pulled out of general education classes for extra help brought another. But as the department has moved to a more flexible model, where students can switch among types of settings based on their needs, the funding model had to change.

The new model allots funds based on the percentage of time students spend in each kind of special education class. Students who spend more than 60 percent of their time in Integrated Co-Teaching classes — which mix special education and general education students and have two teachers, one with special education certification — each bring their school $7,100. Students who spend less time in the classes, which are expensive to run, bring their schools fewer dollars.

Schools programmed students this year with the funding formula in mind. So many middle and high school principals were surprised this week to learn that their calculations were off and they would have to relinquish the very funds they had used to create the integrated classes this year.

Principals said they calculated that students with four Integrated Co-Teaching classes and two other classes, a common arrangement, would land solidly over the 60 percent threshold. More than half a dozen principals in four boroughs each told GothamSchools that they made the same calculation.

But they left physical education classes out of the equation. The Department of Education includes P.E. in its calculation, meaning that students with the same schedule land just short of the cutoff. Out of a schedule of seven classes, four integrated classes constitute only 57 percent of a student’s time.

Principals said they are just finding out this week about the department’s math — and the $2,000 per miscalculated student that schools might have to give back.

Some schools could lose well over $100,000 from their budgets in the middle of the year.

“No one advised us this is how this is going to play out,” said a high school principal, who added that school administrators learned about the issue on Monday during a phone call with officials from the school’s network. Other principals also reported being surprised by the potential budget crunch this week, when the Department of Education held a budget meeting for network officials.

Department officials said the budget materials that principals received this year stated clearly that only lunch should be excluded from the time calculations. They said the issue is arising now because, as part of a “data clean-up,” the department is asking schools to certify that information about students’ schedules is correct in two different places by Jan. 14.

The information in the two systems — the department’s attendance system and its new Special Education Student Information System — doesn’t always match up, principals said. They said they worry that the discrepancies could cause their schools to lose funding even for students who do hit the 60 percent requirement.

“Your school will not receive funding for student services that are not properly coded,” this week’s Department of Education bulletin cautioned principals.

Because any adjustments would come in the middle of the year, principals could not cut teachers, even though that’s what the special education funds were used to pay for. Instead, they would have to slash everything else.

“It could be a real disaster,” said one person who works in a city school.

Department of Education officials said principals could appeal the take-backs.

“We understand that some principals may have concerns about their school’s budget and we will make sure to address those on a case by case basis and ultimately do what is right and fair for the students,” said Erin Hughes, a spokeswoman.

But some principals said they thought the department should simply round up, at least for this year. They said so many schools are likely to be affected that the adjustments will amount to, in effect, a systemwide budget cut, without a tidy number to make headlines. (Like all city agencies, the Department of Education was ordered in September to reduce its spending for the year.)

They also said reaching the 60 percent threshold in the future would also be a challenge, because adding additional integrated classes is both expensive and impractical. Many students who need help from a special education teacher in their academic classes can succeed in other subjects without them, principals said. And they said it doesn’t make sense to assign a special education teacher to physical education classes unless there are students whose disability is physical, a relative rarity.

Several principals also noted that the schools that face the largest cuts are the ones that strive to enroll students with disabilities and also include them in integrated classes — exactly what the Department of Education wants schools to do.