What is the book with a boy named Josh who gets in trouble and is sent to a school for gifted children. There is an experiment where kid's brains are taken out of their bodies and hooked to a computer?

I think the book you're talking about is Shadows by John Saul. The information reads: "They call it the Academy. A secluded, cliff-top mansion overlooking the rugged Pacific coast. A school for children gifted -- or cursed -- with extraordinary minds. Children soon to come under the influence of an intelligence even more brilliant than their own -- and unspeakably evil. For within this mind a dark plan is taking form. A plan so horrifying, no one will believe it. No one but the children. And for them it is already too late. Too late, unless one young student can resist the seductive invitation that will lead... into the Shadows." Hope that's what you were looking for.