A Novel Design Method of Uniformity Energy Distribution Lens for Miniscopes

Objective: Calcium imaging is an essential tool for obtaining neuroactivities to understand the complex function of the brain. The one-photon miniscope, the most widely used endoscope in neuroscience, is employed to record neuronal calcium activities in vivo. However, the current half ball lens overlooks the energy distribution in the brain field, resulting in non-uniform fluorescence imaging and the omission of important signals, leading to misunderstanding in brain science. The main flaw in the existing lens is the lack of controlled energy distribution, where the center fluorescence is much stronger than the edge area, causing the fluorescence noisy background to overlap with numerous neuron signals. To address this issue, we propose a novel approach to simplify the optical path by setting a medial target. By combining the Ray Mapping Method and Energy Feedback Method, we design and optimize the lens based on the energy mapping mesh. Simulation results demonstrate a 2.1-fold enhancement in energy distribution uniformity in the brain field compared to the original half-ball lens, with edge neurons receiving 6.95 times more energy. This novel design is theoretically proved to be an innovative improvement of the one-photon miniscope method, being a potential breakthrough of this mainstream method lasting more than ten years.

of the uneven and noisy background and proposing physical solutions.This lack of understanding and solutions can lead to the capture of incorrect neuron signals with high probability during signal extraction, resulting in misconceptions in brain science.Furthermore, weak neuron activities may be submerged within the noise, making them difficult to extract using current post-processing methods and leading to a low population of extracted neurons.
The main technical barrier causing these problems lies in the design deficiency of the half ball lens in the excitation optic path in miniscope.The half ball lens was primarily designed to collect LED energy rather than to distribute energy evenly.As a result, it creates a sharp peak illumination at the center of the fluorescence field that rapidly diminishes towards the edges.The non-uniform energy distribution causes the strong fluorescence brightness in the center to overlap with the weak fluorescence in the surrounding areas, generating a noisy background.Consequently, the surrounding neuron signals become too weak to be accurately identified.
Freeform optics is widely used in illumination design [16].It can be formulated from a mapping between given light source (normally LED) and a prescribed irradiance distributions on a target [17].One or more freeform surfaces can be calculated from the mapping so that it can redirect the light rays emitted from light source to the required illumination pattern.Ray mapping method [18], [19], [20] and Monge-Ampère Equation Method [21], [22], [23] are the method to solve the equations established between light source and described target.The lens surface will be the perfect with no energy loss and accurate energy distribution.In these methods, however, the light source should be treated as an ideal one [19], or the distance between light source and lens is far enough so that the light source can be approximated as a point source.For most of the cases, the light source cannot match the "five time rule" [19], which means that the point source approximation is accurate when the distance from the lens surface to the light source is greater than five times the largest dimension of the source.Therefore the algorithms for extended light source(ELS) like optimization-based design method, feedback design [24], [25], [26], or SMS3D method [27], [28] are the options to optimize the lens surface.
But in the miniscope excitation optic path, LED light rays pass through much more components than normal illumination system, which contains half ball lens, excitation filter, dichroic mirror, Gradient-index (GRIN) lens.It is too difficult to calculate the freeform lens with a unprescribed target.The LED, moreover, because of the tiny size of miniscope, has to be treated  as an ELS.To overcome aforementioned flaws, we propose a miniscope freeform illumination lens design method based on the mapping between LED energy and the dichroic mirror, and then optimize the lens with combined feedback method based on the illumination distribution on the GRIN lens focal plane.
Metalenses, known for their thin and compact nature, have emerged as a promising technique for compact miniscopes.While currently the manufacturing process typically involves nanoscale lithography techniques which can be complex and expensive.The approach discussed in this article is also applicable to the illumination design of metalenses, and this technique may become the best solution in the tiny minsicope body in the near future.

A. Miniscope Excitation Optic Path
Miniscope consists two parts: the excitation light path (LED excitation light into brain) and the emission light path (fluorescence image out of brain).Both lights traverse a GRIN lens that is implanted in the animals' brain.The excitation light path comprises LED, excitation lens, excitation filter and dichroic mirror; and the emission light path includes emission filter, achromatic lens and CMOS.All these components round up in a small miniscope body which weight only 2.6 g [29], as illustrated in Fig. 1.
In this miniscope, achieving an equal light distribution on the focal plane of the GRIN lens is crucial for reducing the noisy background during calcium imaging.The more uniform the light distribution is on the plane, the less noise will be present in the resulting images.To address this, we focus on the dichroic mirror and consider its surface as a Medial target.We divide the excitation lens into two parts to enable more efficient light radiation onto the GRIN lens.The maximum diameter of the excitation lens is 3mm, the LED which size of 1 * 1mm is regarded as an ELS.The basis for ELS illumination designs is the recognition that the radiation received at the target in the configuration with lens.ELS is determined entirely by the edge rays, which are defined as rays passing through an edge of the source or the lens.
For the upper hemisphere of the excitation lens, as shown in Fig. 2(a), the edge rays of LED marked I 1 and I 2 refracting through the excitation lens radiate on the dichroic mirror at US and DS, and reflected rays of US and DS all radiate on the edge of GRIN lens, which means most of the LED energy will be transferred into brain.On the other hand, most of energy will be transferred out of GRIN lens surface if the center of LED rays (SC) radiates on the half bottom of the dichroic mirror (below DC).As the magnitude of θ (angle between I 0 ray and optical axis) increase, the SC should increase to the top half of dichroic mirror at the meantime.For the bottom hemisphere of the excitation lens, as shown in Fig. 2(b), as the magnitude of θ decrease, the SC' should increase to the top half of dichroic mirror as well.But the distance between SC' and DC is smaller than the upper hemisphere SC and DC.Comparing the angle of incidence on the dichroic mirror, α is bigger than β as illustrated in Fig. 2. Based on this, we can set a bigger mesh for upper hemisphere during mapping.
From the tailored edge ray analysis, the probable prescribed illumination pattern on the dichroic mirror can be described with θ and d.And because of axial symmetry of GRIN lens, the illumination pattern on dichroic mirror can be also treated as an axial symmetry half circle, which can simplify the energy mapping setting and freeform surface calculation.
Where κ is a coordinate factor.

B. Energy Mapping
Calculating the freeform surface with given light source and prescribed illumination is an inverse procedure comparing with imaging optics.We designed the initialized excitation lens surface with Ray mapping method, and regarded the LED as a point light source.
As shown in Fig. 3(a) LED (approximated as a point source) is placed at the origin of the Cartesian coordinate system.A light ray from the light source pass through the inner and outer surface of the lens, then hit on the target plane at point Q(x, y, z).The Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.incident ray from light source can be described as − −−− → I(θ, γ) in a spherical coordinate, where θ and γ are the azimuthal angle and the polar angle.Therefore, the energy in a light source infinitesimal should be equal with the energy infinitesimal on the target, which can be shown in (2).
In our case, the required illumination is split into upper and bottom hemisphere marked S 1 and S 2 , and the light source can be also split into Ω 1 and Ω 2 , as shown in Fig. 3(b).Based on the analysis of Fig. 2, the LED center ray will always radiate on the upper side of DC, therefore the S 1 and S 2 are all on the upper side of z axis showed in Fig. 3(b).Energy of Ω 1 is supposed to be delivered to S 1 , so as to Ω 2 .Both of the light source energy and the required illumination are divided into mapping mesh, and the points of the meshes are matched so that energy mapping relationship established, shown in Fig. 3(c).

C. Freeform Surface Calculation and Optimization With Energy Feedback
The initiated lens surface can be established by the mapping relationship.The diameter of the excitation lens is only 3mm, so the lens should be in compact model with a flat inner surface.The outer surface is freeform with the feature of energy distribution.In previous description, the light source is assumed as a point located at the original of coordinate system, as shown in Fig. 4(a).Light ray come out from light source refract at the inner surface, and then pass through outer freeform surface hitting on the target plane which is -45°tilted dichroic mirror from axis X.From the energy mapping, with each incident angle θ, hitting point on the target plane is known by (1), which means the normal vector − → N i at each freeform surface point can be confirmed by the normal Where n is the refractor index of the excitation lens.
Freeform surface point can be calculated by the tangent plane iteration one after another, Fig. 4(b).For example, an initial point P 0 is defined as the start position of the freeform surface.Then the normal vector of P 0 can be calculated by Snell's law, in which − → I i can be obtained by the geometric optics refraction law from − → I i .Here, − → O i is the normal vector of emergent ray which can be calculated from P i and the matched target point.Therefore the next freeform point is the intersection of tangent plane at B-spline (NURBS) curve can be lofted with all the point, and then other upper hemisphere curves can be calculated by the first curve.The lower hemisphere is under the same calculation.At last, with the inner surface, combing all the surface, the excitation lens solid model is built.To make the surface smooth, the first curve is calculated on OZ direction.
Normally, to design an ELS illumination optics, the lens surface can be optimized with an energy feedback method (EFM).We simplify the excitation path making the lens design easily.In the simplification, the GRIN lens is not considered into the design, but it is added into the simulation.Therefore, rectification functions are combined into EFM to correct the deviation caused by the ELS and GRIN lens.
When we imported the new designed lens into Tracepro software, we then simulated and obtained the illumination distribution on the 1mm diameter plane which located 50µm beneath the 0.25 pitch GRIN lens, as shown in Fig. 5(a).In the simulation, half of the GRIN lens is wrapped in the brain gray matter to simulate the real environment [30].All the simulation parameters are shared in Table I.Considering that the 0.25 pitch GRIN lens concentrates light, we can expect that, if the lens concentrate light on the upper side of the GRIN lens, the illumination  distribution, because of the GRIN lens deviation, should be corrected to equal.Therefore, we let k i be the deviation correction function of the required energy distribution, and added it into the energy mapping, which is shown in (5).
Where f (y) is the mesh shape function in Fig. 3(c) S 1 and S 2 , which are ellipses in our design.

D. Simulation Result of the New Designed Lens
The deviation correction function is also called the "EFM function".Based on the analyze of Fig. 2, to concentrate energy on the center of the GRIN lens up surface, we set the k i as a parabolic equation.Consequently, to design a required excitation lens for the miniscope is to find the appropriate parameters aiming to concentrate light in the center of dichroic mirror.The EFM function is shown in (6), we then manually adjust the EFM parameters.After each adjustment, we constructed a new lens and imported it into the simulation software, as depicted in Fig. 5(b).
Where t is the grid number.p are the parameters.After several times feedback, a new freeform lens shows a good simulation result Fig. 5(c).It shows the energy distribution on the dichroic mirror, which should be expected to concentrate light in the center of the dichroic mirror (analysis in Fig. 2).The comparison between original half ball lens with the new designed lens illustrates that the energy distribution of new designed lens is more reasonable.The final parameters of k i is shown in Table II.
When we check the energy distribution on the top of the tissue, we find that the energy collection ratio of the new lens is 2.92%, which is twice higher than 1.42% of the half ball lens.And the illumination distributions are shown in Fig. 6(a).
To quantify the energy distribution equality, we use the (8) to illustrate the uniformity.
Where D Eup80%of max is the diameter area of the energy over 80% maximum and D allf ield is the whole field diameter.
The energy uniformity of the new lens is 38%, which is 2.1 times higher than 17% of the half ball lens Fig. 6.
The field of view of the miniscope is approximately 500μm in diameter.With the original half-ball lens, the illumination at the edge is 0.24 mW/mm 2 , while with the newly designed lens, the edge illumination increases to 1.67 mW/mm 2 .With the new designed lens, the edge neurons get 6.95 times more than original half ball lens, which means more neurons will be excited.
The fixing error is easy to be generated in the tiny body, so we also discussed the energy ratio and uniformity change with the LED fixing error on both X and Y direction.On X direction as shown in Fig. 6(d), the energy collection ratio and the uniformity decrease when the LED moves further away, and Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.the results are accepted within 0.4mm error.On Y direction as shown in Fig. 6(e), the energy collection ratio and the uniformity are accepted within 0.3mm fixing error.
The simulation results demonstrate that the new lens not only collects more energy compared to the half-ball lens but also contributes to a more equal energy distribution in the brain.This has several advantages.Firstly, the lower LED energy requirement reduces the power pressure on the thin coaxial cable and minimizes heat generation associated with energy consumption.Secondly, the increased uniformity enhances excitation of the calcium fluorescence imaging field, resulting in reduced background noise and improved clarity of calcium imaging.This, in turn, increases the accuracy of neuron activity extraction during post-processing.Additionally, the new lens provides more energy to the edge neurons compared to the original half-ball lens, enabling clearer recording of neuron activities.

III. CONCLUTION
The non-uniform energy distribution and the strong background noise overlapped a lot surrounding neurons activities in calcium imaging experiments in neuroscience causing high possibility misunderstanding in the brain science, and because of the missing of signals, neuroscience researchers could not gain enough information to decode the neuro circuit they were working on, which become an invisible deficiency in calcium imaging recording.Despite several algorithms like Min1Pipe tried to uncover the overlapped neurons activities by post-imaging process, one of the most effective approaches to address this issue is to redesign the half-ball lens used in the excitation optic path of the miniscope.
Here, we considered the complicated optical configuration in the miniscope, re-designed a new lens targeting the problem of non-uniform energy distribution.We first set the dichroic mirror as a medial target in order to simplify the whole system, and split the lens into two main parts matching two targeting area so as to collect more energy into GRIN lens.Then based on the assumed point light source, the light source energy and the targeting area were divided into matched mesh, and the initiated lens was established with Ray Mapping Method.Next, the initiated lens was optimized using EFM by adding a deviation correction function to minimize the deviation caused by ELS and GRIN lens.
The simulation result in software Tracepro verified that the energy uniformity of illumination on the GRIN lens focal plane is 2.1 times higher than the original half ball lens.Additionally, the new lens design reduces the energy cost by half.The lower LED energy requirement alleviates power pressure on the thin coaxial cable and mitigates heat generation associated with energy consumption.The increased uniformity of illumination enhances the excitation of the calcium fluorescence imaging field, allowing for the recording of a greater number of neurons.Furthermore, the improved uniformity in the central field reduces background noise and enhances the clarity of calcium imaging, thereby enhancing the accuracy of extracting neuron activities during post-processing.
The tolerance analysis simulations on both X and Y directon show that the illumination on the focal plane did not deteriorate too much when the position of the source changed within 0.3mm.Based on the previous research, the surface tolerance can be up to 2 μm, if the fluctuation of errors on surface has a low frequency.And the ultra-precision multi-axes diamond machining systems make the manufacture possible [19].
This novel design method of the excitation lens proved to be an innovative improvement of the one-photon endoscopes, and it can be used into any one-photon calcium imaging endoscopes.For freeform lens design method, this is also an example of illumination optic design method application in some complicated configurations.Here, we only conducted theoretical derivation, hoping the proposed novel design method being technically innovative to peers in the rapidly developing brain science field, but in the future, we will carry out further physical testing based on this theory.

Fig. 1 .
Fig. 1.Sketch of miniscope and the components in the miniscope.(a) Miniscope is a kind of endoscope which is fixed on mice skull to record the calcium imaging through a GRIN lens.(b) Components and the structure of the miniscope.

Fig. 2 .
Fig. 2. Sketch of miniscope excitation lens division principle.(a) Edge rays of LED on upper hemisphere excitation lens (b) edge rays of LED on bottom hemisphere excitation lens.

Fig. 3 .
Fig. 3. Energy mapping between LED and medial target.(a) Energy mapping sketch from light source to target plane.(b) Energy division of upper and bottom hemisphere.(c) Division mesh between light source and target plane.Up, the upper hemisphere, and down, the bottom hemisphere.

Fig. 4 .
Fig. 4. Sketch of iterating the freeform surface.(a) Sketch of the simplified illumination system.(b) Plane-iteration to generate freeform surface points.
P i and the next incident ray −−→ I i+1 , as shown in (4).The iteration continued until all the surface points solved out, as shown in Fig. 4(b).⎧ ⎨ ⎩ N ix (x − P ix ) + N iy (y − P iy ) = 0 x − P I ix sin θ j = y − P I iy cos θ j (4)

Fig. 5 .
Fig. 5. ELS simulation in Tracepro software to correct the deviation.(a) Simulation optical path in Tracepro software (b) illumination distribution on dichroic mirror.Left, the distribution of original half ball lens.Right, the distribution of new designed lens.(c) The energy distribution of the center diameter in the whole field in EFM adjustment.

Fig. 6 .
Fig. 6.Intensity comparison between half ball lens and new designed lens.(a) Simulation result on the top of issue.Left, the distribution of original half ball lens.Right, the distribution of new designed lens.(b) The 3-D model of the new designed lens.(c) The distribution comparison between original half ball lens and new designed lens.(d) Energy collection ratio and uniformity change with the LED fixing error on X-axis direction.(e) Energy collection ratio and uniformity change with the LED fixing error on Y-axis direction.

TABLE I PARAMETERS
FOR SIMULATION

TABLE II VALUE
OF PARAMETERS