Section 330(3)(a) in The Code of Criminal Procedure, 1973
(a)if on the basis of medical opinion or opinion of a specialist, the Magistrate or Court, as the case may be, decide to order discharge of the accused, as provided under Section 328 or Section 329, such release may be ordered, if sufficient security is given that the accused shall be prevented from doing injury to himself or to any other person;