BUFFALO, N.Y. -- A former Niagara County Corrections officer injured in a July explosion at his Wheatfield home will remain in custody because of the risk he poses to the community, a federal court judge decided Wednesday.

Michael O'Neill, 45, is currently in rehab at a Buffalo hospital after having his leg amputated.

"Luckily, he is detained," said Assistant U.S. Attorney John Alsup. "He is no longer at large in the community with or without some of the physical disabilities he's going to have going forward, but luckily for the community, he only hurt himself."

O'Neill was charged with possession of an unregistered destructive device after investigators found what appeared to be seven improvised explosive devices in an area where they believe explosives were being made. One was labeled "powder with nails."

O'Neill's attorney, Joe LaTona, said O'Neill was planning to blow up tree stumps, and shrapnel would help make a cleaner cut.

LaTona argued the government hasn't shown O'Neill had a destructive device, and there's no indication it was going to be used against people or property. He said there wasn't clear and convincing evidence to detain O'Neill, who can't even walk on his own.

"I was disappointed with the ruling and we will seek its review," LaTona said.

Alsup said that based on the evidence, it's unlikely the explosives were going to be used for tree stumps, and he said there were some inflammatory materials found in the same vicinity that the IEDs were being made.

"The fact that there were some items that we described in court as consistent with, white supremacists, to include the Ku Klux Klan, and the Nazi imagery, some of the verbiage which was particularly on the Nazi picture, also the Confederate battle flag, means that law enforcement has more work to go," said U.S. Attorney William Hochul.

As the investigation continues, Alsup said O'Neill will get the medical care he needs and will be in custody of the U.S. Marshals until he's moved to a detention facility.

A preliminary hearing in the case is scheduled for Aug. 18.