Adaptive optimization for axial multi-foci generation in multiphoton microscopy