Optically controlled magnetic resonance imaging compatible active needle