A stochastic vision-based model inspired by zebrafish collective behaviour in heterogeneous environments

Collective motion is one of the most ubiquitous behaviours displayed by social organisms and has led to the development of numerous models. Recent advances in the understanding of sensory system and information processing by animals impels one to revise classical assumptions made in decisional algorithms. In this context, we present a model describing the three-dimensional visual sensory system of fish that adjust their trajectory according to their perception field. Furthermore, we introduce a stochastic process based on a probability distribution function to move in targeted directions rather than on a summation of influential vectors as is classically assumed by most models. In parallel, we present experimental results of zebrafish (alone or in group of 10) swimming in both homogeneous and heterogeneous environments. We use these experimental data to set the parameter values of our model and show that this perception-based approach can simulate the collective motion of species showing cohesive behaviour in heterogeneous environments. Finally, we discuss the advances of this multilayer model and its possible outcomes in biological, physical and robotic sciences.

Different types of model exist to describe fish schooling.In self-propelled particles (SPP) models (synchronous [23,24] or asynchronous [25,26]) firstly used for computer animation [27], interactions between fish are mostly composed by a collision avoidance component, a alignement component and a cohesion component [28,29].Similarly, in social forces (SF) models fish are considered as Newtonian particles subjected to social and physical forces that respectively ensure the cohesion of the group and reflect the interaction (drag for example) with the environment [30,31].Both SPP and SF models have inspired several studies in statistical physics that aim to characterize features of a large number of interacting agents at the collective level [32][33][34][35][36]. Finally, kinematic models describe the evolution of the trajec-tory of fish by a stochastic differential equation [37][38][39][40].This modelling approach has successfully described the movement of fish in closed environment and is a continuous time formulation of a particular case of random walks (RW).Random walks describe stochastic trajectories build by successive random steps that can be drawn from a uniform distribution (unbiased random walk) or a non-uniform distribution (biased random walked).These probabilistic models have a wide range of application, from simulating the brownian motion of particles to the exploratory patterns of many species including humans [41,42].

B. Information perception
In all mentioned models of schooling, the agents move according to their conspecifics (position, speed, orientation or a combinaison).Multiple hypothesis have been proposed to calculate the subset of individuals that influence the motion of a focal fish: the metric perception includes all individuals situated within a defined distance; the topological perception includes the n th proximal neighbors; the perception based on Voronoi tessellation includes the fish connected to the focal fish by the Delaunay triangulation.However, while these hypothesis produce coherent movement of simulated agents, they are not sufficiently constrained by known biology.Therefore, recent works are now based on visual perception [43][44][45].In these models, the focal fish does not interact with its neighbors according to their Cartesian coordinates but according to their representation in its visual field.
Thus, theoretical and experimental studies highlighted that the visual sensory system of fish is determinant for information transfer during collective motion.Indeed, the comparison of interaction mechanisms showed that a vision-based model outperforms others mechanisms (metric, topologic, Voronoi) in explaining experimental data [45].In parallel, the increasing knowledge on the visual system of fish allow to develop model based on sensory systems more coherent with the biological reality.The characterization of the vision of cyprinids reveals that they have a wide visual coverage in the horizontal and vertical planes and an acute vision in the front-dorsal region [46].To make a step towards more realistic sensory systems, we introduce in this paper a new mechanism based on a the perception of 3D stimuli in the visual field.We simulate fish-agents that perceive stimuli (congeners, environment) according to the solid angle -an analogous of the planar angle but in 3D-that they intercept in their visual field.

C. Information processing
Once the focal fish has perceived potential stimuli, this information has to be processed and translated into a movement of the individual.In SPP and SF models considering only the influence of congeners, a vector of interaction is computed with all neighbors situated in a delimited range (metric models) or according to their proximity rank (topological models).Then, the focal fish moves along the resulting force computed by a weighted summation process of the different interaction forces applied on the focal fish.While it results in coordinated motion of agents, these models can also produce biological incoherent behaviour of the simulated individuals: the influence of some congeners can be omitted/overestimated or the resulting vector can point towards a direction where no stimulus is present (Fig. 1).In addition, such process have difficulties in reproducing experimentally observed choices between two concurrent stimuli.For example, zebrafish larvae randomly chose to orient towards one of two equidistant source of light and do not follow the bisector [47].Here, we present a novel algorithm to account for information processing by the individual.Rather than summing influential vectors, we propose to sum probability distribution functions to orient towards the different stimuli.As shown in the model section, such mixture distribution can spontaneously produces transitions from choice to consensus and better describes different biological observations.

D. A multilevel approach
It would be interesting to develop a multilevel modeling approach that takes into account models for perception and information processing by the individuals.Beyond existing SPP and RW models, it requires extending the description of the agents by biologically relevant properties.We propose a new hybrid class of models, at the crossroads of both RW and SPP models, that include a probabilistic component (inspired by RW) in the be-FIG.1: Potential biological incoherence or problematic situations in the different models assuming a summation of interaction vectors between the blue focal fish (FF) at the center and green perceived fish (non-perceived fish are represented in red).In the metric model, the FF perceives no (A) or a high number (B) of neighbors.In the topological model, the position of the n th closest neighbors can be conflicting (C) or disproportionate regarding the rest of the group (D).Even in visual model, the position of the perceived fish can lead to a resulting vector oriented between the stimuli (E) or the number of fish can be overestimated by their captured angle due to proximity (F).
haviour of the agents that react to their perception field (inspired by SPP models).In the model, the agents chose a direction to move according to a probability distribution function (PDF) that is determined by the presence of stimuli in their visual perception field, in accordance with observed stochastic choices made by zebrafish larvae [47].This PDF is computed as a mixture distribution of von Mises distributions centered on each perceived stimulus.Once the probability distribution function has been computed, the direction of the agent is chosen accordingly to this PDF.With this model, we simulate motion of single individuals or groups of fish evolving in a bounded environment that can include other stimuli like spots of interest.
To validate this model, we measured the individual (single fish) and collective (group of 10 fish) motion of adult zebrafish in different environmental conditions.Zebrafish form loosely cohesive groups that do not show strong alignment and could be challenging to model with a classical approach.In addition, we observed the behaviour of zebrafish in a bounded tank with potential spots of interest to take into account the interactions with the environment.First, we analysed the locomotion of isolated individual evolving in a uniform environment to determine the intrinsic characteristics of their motion (speed, change in orientation and probability of presence).We performed similar measurements in heterogeneous environment by placing two floating plastic disk acting as attractive spots.Then, we investigated the influence of conspecifics on the spatial distribution of fish by observing collective motion of group of zebrafish in both homogeneous and heterogeneous environment.We measured their probability of presence in the experimental tank and their inter-individual distances.This experimental data is used for both, setting parameter values for individual behaviour, as well as to compare the predictions obtained from our model.

II. NEW STOCHASTIC MODEL
Our aim is to model fish swimming in nearly 2D in a bounded environment with potential spots of interest that attract them.To do so, we simulate agents that update their position vector X i with a velocity vector V i though a discrete time process in a bounded twodimensional space: with v i the linear speed of the i th agent and Θ i its orientation.Since we focus on the decision making process of the fish to chose its orientation in a complex environment (walls of the tanks, spots of interest) with other fish, we assume the simple hypothesis that the linear speed v i of the agent is randomly drawn from the instantaneous speed distribution measured in our experiments.The novelty of this model is the computation of the orientation Θ i .We model the spherical visual perception field of fish (Fig. 2) and describe the probability for fish to move in all potential directions by a circular probability density function extending from −π to π.Thus, Θ i is not computed as a resulting vector with potential noise but is drawn from a circular probability density function (PDF) formed by von Mises distributions, an equivalent to the gaussian distribution in circular probability.This PDF is characterized by a measure of location µ (equivalent to the mean of a Gaussian PDF) and a measure of concentration κ (an inversely proportional equivalent to the variance of a Gaussian PDF).For a fish that perceives no stimuli, the distribution of probability is described by µ = 0 while the value of κ 0 is determined experimentally (Eq.3).By doing so, a fish that perceives no stimuli will move forwards with deviation inversely proportional to κ 0 .Since our goal is to model fish moving in a bounded tank, we introduce the interaction of the fish with the walls in the computation of this PDF.As soon as a fish is situated in a distance shorter than a threshold value d w , we assume that the fish starts a wall-following behaviour.To simulate this behaviour, the value of µ is not equal to 0 but to the direction along the followed wall.Since there are two potential direction, the PDF is computed as the weighted sum of the PDF associated with each direction.Thus, the PDF f 0 (θ) for a fish to move in each potential direction θ in a bounded tank without perceptible stimuli is given by: with d the distance with the closest wall, d w the threshold distance determining the interaction with the walls, κ 0 and κ w the dispertion parameters respectively associated with the basic-swimming and wall-following behaviours, µ w1 and µ w2 the two possible directions along a considered wall and I 0 the modified Bessel function of first kind of order zero.The value of d w , κ 0 and κ w are determined experimentally.
Equations ( 1) to ( 4) are sufficient rules to simulate a fish swimming in an experimental tank.However, since we aim at simulating groups of fish moving in a homogeneous but also heterogeneous environment, we implement the interactions with other congeners and spots of interest.As soon as the fish perceive stimuli in its perception field, its PDF is influenced by those stimuli following two steps: information gathering and information processing.

A. Information gathering
We simulate fish-agents that can perceive and react to 3 dimensional stimuli perceived in their visual field.Fish are modeled as 3D polygons with 6 vertices swimming on a 2D plane space (Fig. 2A).Their visual perception is simulated as a cyclopean vision sensor that has a 270 degree spherical field of view extending frontally and laterally and an infinite effective radius (Fig. 2B).Fish perceive potential stimuli by the solid angle that the projection of their extremities capture in their spherical perception field (Fig. 2C).
To reflect our experimental conditions, we include two potential stimuli in our simulations: fish and spots of interest.Fish are considered as polygons of length = 0.035m, width = 0.01m and height = 0.01m whose extremities form the two boundaries of the fish.Spots of interest are considered as floating disks with a radius of 0.1m floating 0.05m above the plane space.

B. Information processing
Once all potential stimuli have been perceived, the model computes a PDF for the focal fish to move ac-FIG.2: Scheme of the simulated fish and their perception abilities.(A) Simulated fish swim on a 2D plane space and are characterized by a width (1 cm), length (3.5 cm) and height (1cm).(B) Their spherical perception field is defined by an angular perception zone and an infinite distance of perception.The position (x, y) of the fish is updated at each time step by a velocity vector computed according to the stimuli perceived.(C) Fish present in their perception field are perceived as the solid angle A f i captured by their extremities.Similarly, we computed the solid angle As i captured by the spots of interest.
cording to each stimulus (fish or spots in this study).For example, the probability of the focal fish to orient towards a perceived fish is given by a von Mises distribution clustered around this fish: with θ, the potential direction of movement of the fish, µ fi the location of the perceived fish i and κ f a measure of concentration.
The model draws such distribution for each stimulus (fish or spot) in the perception field of the focal fish.Then for each type of stimuli, it performs a weighted sum of all distributions proportional to the ratio of the solid angle A * i captures by each stimulus to the sum of the solid angles captured by all stimulus A T * .For example, the PDF computed for the perceived fish is given by : with A T f to the sum of the solid angles A fi captured by all fish.Thanks to the summation of PDFs rather than vectors, the model intrinsically produces transitions between consensus (i.e. the fish orients between two stimuli) and choice (i.e. the focal fish orients toward one of two stimuli) according to the angle between to stimuli (Fig. 3).
We calculate a similar PDF for the spots of interest perceived by the focal fish: A Si (10) with µ si the location of the center of the perceived spots, κ s the dispersion parameters of the perceived spots, A si the solid angle captured by the spot and A Ts the sum of the solid angles A Si captured by all spots.
Once the PDFs have been computed for each type of stimuli (fish -spots), we calculate a weighted sum of the PDFs to obtain the global probability distribution function f (θ) of the focal fish to move towards a given direction.In this first approach, we assumed that the weight of the PDF associated with each type of stimuli is a linear function of the total solid angle A T * that they capture in the perception field of the focal fish (Fig. 4).This implies FIG.3: Evolution of the total probability density function fF (θ) according to the position of the neighboring individuals.Contrary to classical models, the fish will not always move forward as it would be predicted by weighting the attraction vectors.When the neighbors are far from each other, the focal fish will randomly orient towards one of them.On the contrary, if the two neighbors are closer, the sum of the PDF associated with to these fish predict that the focal fish will favor the direction between them rather than selecting one of them.Thus, by summing the PDFs rather than interaction vectors, the model reproduce transitions from choice to consensus and vice versa according to the angle between two perceived stimuli.
that the fish respond more strongly to largely perceived stimuli but it also allows a potential hierarchy in the response to different stimuli.Thus, the global PDF f(θ) is given by: with α 0 and β 0 the parameters weighting the influence of respectively the fish and the shelters for a fish distant from any wall and α W and β W for a fish following a wall.These parameters are fitted experimentally.
Then, we numerically compute the cumulated distribution function (CDF) corresponding to this custom PDF f (θ) by performing a cumulative trapezoidal numerical integration of the PDF in the interval [−π,π].Finally, the model draws a random direction Θ i in this distribution by inverse transform sampling.The position of the fish is then updated according to this direction and his velocity with equations 1 and 2.
FIG. 4: Weighted sum of the three PDFs calculated for the focal fish according to the congeners and the shelters perceived by the individual to compute its final PDF.The direction taken by a fish is drawn randomly from the final computed PDF (in green) by inverse transform sampling.

A. Homogeneous environment
We measured the positions of ten fish tested individually swimming alone in our 1.20m x 1.20m experimental tank during 1 hour.Based on this tracking, we build the trajectories of the fish and computed their speed and change in orientation.An example of a 10 minutes trajectory of a fish is given on Fig. 5A.Fig. 6A shows the cumulated distribution of all instantaneous speeds measured in a homogeneous environment with a average speed of 0.07 ± 003 ms −1 .Similarly, Fig. 6B represents the cumulative distribution of the changes of orientation along the trajectories and highlights that fish are mainly moving forwards with soft change of orientation (average change = -0.03± 0.84 rad).The distribution of the positions detected in the tank (Fig. 11A) shows that the higher probability of presence was found along the walls.Thus, in a homogeneous environment, fish were mainly swimming along the walls of the tank and avoid the centre of it.We used this experimental data to set the parameters of our model in order to simulate the movement of a single fish in a homogeneous tank.In the simulations, the speed of the agent is drawn from the experimental distribution of the instantaneous speed of the fish.Speeds are drawn independently from each other so that there is no correlation between the speed of agent i at time t and t + 1.While this differs obviously from the reality, for simplicity we do not take into account speed matching in this first parametrization of our new model.Experiments with single fish allow us to fit the parameter value characterizing the change of direction of fish κ 0 .To do so, we measured the change of direction of the fish when they were at least at 0.30m from any walls.By doing so, we excluded the potential influence of the walls and consider only the intrinsic change of direction.Then, we compared this experimental distributions to theoretical ones and select the best fitting.In this first approach, we chose the sum of least squares minimization as a rapid and low computational costly fitting method.The best fitting of this experimental distribution was obtained by κ 0 = 6.3, as shown by Fig. 7.
For experiments involving a single fish, only the interaction with the walls of the tank is present.Therefore, the other relevant parameters are the distance of interaction with the walls d w and the measure of concentration κ w of the PDFs associated with wall following.To esti- Then, we performed experiments with 10 groups of 10 zebrafish.As observed for single fish experiments, fish were mostly detected along the walls of the tank (Fig. 11C).Since we did not track the fish individually when swimming in group, we could not build the individual trajectories of the fish.However, we measured the distance between all pair of fish at each time step as a measure of group cohesion.The distribution of these interindividual distances shows an average of 0.394m ± 0.38m with the mode of the distribution between 0.1 and FIG.7: Experimental distribution and fitting by sum of least squares minimisation of direction changes of single zebrafish swimming in a homogeneous tank.(A) Experimental distribution (blue) and fitting (red) of changes of direction obtained for κ0 = 6.3.The data were calculated for trajectories measured at least at 0.3m from any walls to minimize their influence on the fish orientation.(B) Evolution of the sum of the mean squares between the experimental distribution and a theoretical distribution of 100,000 random draws in a von Mises distribution with parameters µ = 0, κ0.0.2m (Fig. 9A).
To simulate experiments with 10 fish, we introduce three parameters describing the interaction with the fish: the measure of concentration κ F associated with the PDF computed for each fish and the parameters α 0 and α W that weight the influence of other individuals on a fish that is far from (α 0 ) or close (α W ) to a wall.The value of κ F is assumed to be similar than κ W and is equal to 20.By doing so, we consider that a fish orients towards a given target µ with a high accuracy.To determine the value of the weights α * we perform simulations with different values of (α 0 , α W ) and compare the distribution of interindividual distances and probability of presence with those obtained for the experiments.The best values to reproduce both distributions are α 0 = 55 and α W = 20 (Fig. 10).Thus, fish that follow a wall are less influenced by other congeners than fish situated in the center of the tank.With these parameter values, our model was able to reproduce the probability of presence displayed by groups of 10 zebrafish as shown in Fig. 11D.Concerning the distribution of interindividual distances, the model reproduces the decreasing distribution observed in the experiments except for the mode of the distribution that is between 0m and 0.1m (Fig. 9B).

B. Heterogeneous environment
We added two spots of interest in the experimental tank placed at 25 √ 2 cm from two opposite corners along the diagonal of the tank.These spots consisted of blue plastic disks (20cm of ) floating at the water surface and hung by nylon threads.An example of path followed by a fish during 10 minutes is shown on Fig. 5B.We calculated similar parameters from the individual positions of fish (10 x 1 fish) moving alone in the tank with two spots.In the presence of two spots, the fish are mainly detected along the walls and under the spots as shown by their probability of presence (Fig. 13A).Experiments with single fish also showed that fish decreased their speed under these spots.Indeed, the separation of the speed distribution measured Outside or Inside the spots shows that the average speed was three times slower when fish were located under a floating disk (Fig. 12A).On the contrary, the presence of the floating disks did not affect the distribution of the changes in orientation that were similar Outside and Inside (Fig. 12B).For experiments involving a single fish, only the interaction with the walls and the shelters of the tank are present.Since d w = 0.05 and κ w = 20 were fitted by our experiments in homogeneous environment, we explore the parameter values of β 0 and β W (the ponderation of the influence of the spots) and assume that the measure of concentration associated with the spots κ S = κ w = 20.We perform simulations for different values of (β 0 , β W ) and compare their results with the experimental probability of presence and distribution of change of orientation.The best value to reproduce our experimental data are β 0 = 0.15 and β W = 0.01 as shown by Fig. 14.As observed for the influence of the congeners, these values indicate that fish following a wall are less influenced by the spots than fish swimming in the centre of the tank.With these parameter values, the model reproduce the spatial distribution of the fish along the wall and under the floating disks (Fig. 13C).
Finally, we observed 10 groups of 10 zebrafish swim- ming in the presence of two spots of interest during one hour.In this case, the fish were also observed mainly under the spots and along the walls but show a preference for the spots (Fig. 13B).The measure of the interindividual distances shows that the presence of spots does not have a strong influence on the distance between the fish (Fig. 16A).Indeed, the average distance between the individuals is 0.439m ±0.331m, which is 6mm less than observed in the absence of floating disks.
We simulated these experiments with groups of 10 zebrafish with our model by integrating the interactions of the agents with both the other fish and the spots of interest.In the previous experiments, the parameter ruling the interactions with the fish (α 0 , α W ) and the spots of interest (β 0 , β W ) were fitted independently but here, both stimuli are simultaneously present in the perception field of the fish.Therefore, we investigate the relative importance of both stimuli by weighting the influence of the other fish or the spots of interest.To do so, we multiply the previously fitted values of (α 0 , α W ) and (β 0 , β W ) by different weighting factors w F = { 1  1 , 1 2 ...  while values w F = 1 2 and w S = 1 5 imply that the influence of the fish is divided by 2 and the influence of the spots by 5. Thus, we perform simulations for each couple of (w F , w S ) and compare the distributions of the probability of presence and the interindividual distances with those measured experimentally.The best fit is given by w F = 2 and w S = 9 (Fig. 15) which implies that the influences of the fish and the spots have to be decreased by a factor 2 and 9 respectively.Therefore, when both stimuli (congeners and spots) are perceived by the fish, the best values of α * and β * to reproduce the experimental data are α 0 = 27.5, α W = 10, β 0 = 0.016 and β W = 0.0011.While these values give a correct fit of the experimental probability of presence (Fig. 13D), the model do not perfectly reproduce the distribution of the interindividual distances (Fig. 16B).Similarly than for the groups of fish in a homogeneous environment, the mode interindividual distances measured in the simulation is between 0 and 0.1m while the mode of the experimental distances is between 0.1 and 0.2m.

A. Experimental results
In this study, we observed individual and collective behaviour of zebrafish in homogeneous and heterogeneous environments.Firstly, we observed single D. rerio swimming in our experimental tank to describe the swimming behaviour of zebrafish.In homogeneous environment, the fish were mainly following the wall of the tank and avoid the center of it.This observation was also reported in studies performed with zebrafish and robotic-fish [48].We characterized the motion patterns of single individuals and found out an average speed of 0.07 ± 0.03 m/s and an average change of orientation of −0.03 ± 0.84 rad, in coherence with previous studies performed on single zebrafish individuals [39,40,49].Our experiments with 10 zebrafish showed that the spatial repartition of the group did not differ significantly from the individual one.Fish in groups were also mainly detected along the walls of the tank.
The presence of floating disks influence the spatial distribution of the fish in the experimental tank.The shaded area seemed as attractive as the walls since fish showed a similar probability of presence for both stimuli.These disks had no influence on the change of direction of the fish but resulted in a spatial differentiation of the instantaneous speed of the individuals.Indeed, the fish swam with an average speed of 0.09 ± 0.06 m/s outside the shelters but with an average speed of 0.03 ± 0.02 m/s under them.Such reduction of speed can indicate that shaded areas are potentially considered as temporary resting sites by the fish.The observation of groups of 10 fish showed similar results with preference for both the walls and the shaded area.These results show that zebrafish are avoiding free water and prefer to swim near potential shelters (floating objects or bank).Although fish were attracted by the floating disk, they did not seem to avoid the light since their presence under the disk and along the wall (that are exposed to light) are similar.These observations are in accordance with the ecology of the species that shows a diurnal activity in the Nepalese and Indian shallow water and rice paddies [50].

B. A new hybrid modeling approach
Based on our observations and on the literature, we developed a model describing individual and collective motion.Currently, collective motion receives attention from researchers of numerous fields such as biology, physics, computer science and robotics.Current modeling tends to give up traditional methods (metric or topologic) accounting for the perception of influential neighbors by the focal fish for vision-based approach [43][44][45].Here we present a 3D perception system accounting for zebrafish vision in which the objects are described by the solid angle that they capture in their perception field.By doing so, we are closer to a realistic description of the sensory system of the fish.In this first step, we assumed the simple hypothesis that object were homogeneously perceived in this 3D sensory field.However, the recent characterization of the visual system of zebrafish highlighted centers of acute vision (i.e.areae) in the fronto-dorsal region [46].Therefore, future models should take into account such heterogeneity in the perception field.In addition, the position of the areae differs from one species to the other and is expected to influence the structure of the fish school [46].The extension of our model to 3 dimensional movements would allow to test such hypothesis.
In addition to this sensory system, we proposed a new mechanism to determine the direction of an agent according to its visual field.Rather than computing a resulting vectorial force that is applied to the fish, we redefined the modeling approach by describing the decision-making process of the fish to make an intentional movement according to its perception field.In this first step, we represented the choice of the individual by a stochastic process.The fish can potentially move in any direction but it will favor directions associated with a perceived stimuli (congeners for example).This stochastic model can reproduce collective behaviour exhibited by species that show cohesive behaviour without presenting higher order or only occasionally without introducing a high level of noise accounting for disturbances.This is made possible by the representation of the perception field of the fish and its translation into a probability distribution function.By doing so, we are closer to an effective description of the individual decision-making process during motion [46].Indeed, with such approach of PDFs' summation, we can include potentially all kinds of stimuli (congeners, environment, food...) that are perceived by the fish and account for a choice or consensus between potentially antagonist stimuli.Such choice between two concurrent stimuli has been evidenced in zebrafish larvae that orient towards one of two light source rather than swimming towards their bisector [47].The authors showed that two retinal pathways controlling turn movements and rapid forward swimming are responsible for phototaxis.Such advances on the understanding of information processing by neuronal pathways should be integrated in further multi-scale models to make the link between fish movement, perception of information and its processing based on biological knowledge.
Moreover, most of the models consider motion in unbounded homogenous space (torus geometry).While this hypothesis is reasonable to study the collective behaviour of animal living in pelagic water, the interactions with can not be neglected for species living in small streams.We extend our model to take into account bounded and heterogenous space getting closer to natural conditions of fish like D. rerio.The model correctly reproduced the behaviour of single individual swimming in a bounded tank.The fish mainly follows the wall but sometimes swim in the center of the tank.The probability of presence was also correctly reproduce but the distribution of interindividual distances was biased towards short distances.This could originate from the absence of preferred distance or avoidance distance between the agents.Indeed, while the agents of the model can overlap, the fish have to respect a distance between them.Such distance was not introduce in this first parametrization of the model to limit the number of parameters.In a heterogeneous environment, the model was also able to reproduce the individual trajectories of single fish that transits between the walls and the spots of interest.As in the homogeneous environment, the probability of presence of groups of fish is also fitted, but again, the distribution of the interindividual distances is biased towards short distances.Therefore, these results indicate that the approach developed in this study can successfully describe individual and collective motions of fish but that further version could include additional biological variable and behaviour that are species dependent.For example, here the probability distribution function for a simulated fish are centered on the position of the other fish that it perceives but the PDF could be centered on the direction of the congeners to simulate an alignement behaviour.Rather than developing a model that exactly described the behaviour of zebrafish, our goal was to introduce a new decisionmaking algorithm for motion in complex environment.
In this study, we applied our decision making algorithm to an individual-based model (IBM).Recently, a kinetic model (KM) was proposed to account for the individual movement of isolated zebrafish [39,40].This model inspired by [37,38] took into account a dynamic speed regulation characterizing D. rerio motion.In our model, we did not implement a function accounting for speed mod-ulation in order to focus on the decision-making mechanism.The instantaneous speed was drawn from the experimental distribution with a time step corresponding to the tail-beat period of zebrafish.Then, future work should investigate the impact of the proposed stochastic mechanism for orientation on such KMs.Moreover, the development of a KM version of our IBM could be an intermediate step towards a continuum model (CM) description of the group of agents.This could then be use to perform large-scale analysis and prediction of the collective behaviour displayed by very large population.Such multiscale modeling approach would allow us to identify the properties of the group that are preserved at all scales of analysis or on the contrary that are specific to a particular level of observation [51].We performed simulations with a small number of agents to mimic our experimental conditions in this study that are close to the natural size of zebrafish group [50].While our IBM could model larger groups of tens of individuals, simulations involving thousands of agents would require a longer computational time than KM and CM.
In parallel to the understanding of information processing by individuals, this approach is also a new step towards bio-inspired algorithms that can be implemented in robotic agents.Indeed, it is a major scientific challenge to build artificial systems composed of robots that can perceive, communicate to, interact with other agents (biological or robotic) and adapt to their environment [52].To do so, we need to develop artificial agents that communicate through appropriate channels corresponding to specific animal traits but also that correctly perceive and interpret signals emitted by the animals [53,54].This was firstly achieved in 2007 by building bio-inspired artificial cockroaches that where able to sense the presence of congeners and to adapt their behaviour following a bio-inspired algorithm [55].
In fish, an increasing number of studies aim at developing such robotic agents to interact with group of fish [56][57][58][59].Current experiments generally involve one robot that follows a predetermined trajectory or that moves according to the position of fish detected through the intermediary of a camera that films the entire setup.While this methodology is in the line of the classical ethological experimentation to investigate behavioural responses of animals, the development of fully autonomous integrated lures in fish schools (or other species) requires the development of perception abilities for the robotic agents as well as adapted behavioural algorithms.
In this perspective, the development of perceptionbased models is a necessary step towards intelligent artificial systems capable of closing the loop of interaction between animals and robots.
V. METHODS

A. Animals and housing
We acquired 150 adult wild-type zebrafish (Danio rerio AB strain from Institut Curie (Paris).Fish were 18 months old at the time of the experiments.We kept fish under laboratory conditions, 27 • C, 500µS salinity with a 10:14 day:night light cycle.The fish were reared in 55 litres tanks and were fed two times per day (Special Diets Services SDS-400 Scientific Fish Food).Water pH was maintained at 7.5 and Nitrites (NO 2− ) are below 0.3 mg/l.

B. Experimental setup
We recorded the behaviour of zebrafish in a 120 x 120 x 30 cm experimental tank made of glass with internal walls covered with white adhesive.The water depth was kept at 10cm during the experiments.A Logitech R HD Pro Webcam C920 was mounted 160 cm above the water surface to record experiment at a resolution 1920 x 1080 and at 15 FPS.The camera was connected to a workstation Dell R Precision T5600 dedicated to the recording of the videos and their analysis.One halogen lamp (450W) was placed at each corner of the tank and oriented towards the wall to provide indirect lightning of the tank.The whole set-up was confined behind white sheets to isolate experiments and homogenize luminosity.

C. Experimental procedure
We recorded the behaviour of zebrafish swimming in our tank during one hour.We tested two numbers of individuals (single fish or groups of 10 fish) in two environmental conditions (homogeneous or heterogeneous).The heterogeneous environment was created by adding two floating disks made of blue coloured Plexiglas (200 mm diameter and 3 mm thick) suspended by nylon threads.The two spots were spaced from 70 cm and located on a diagonal of the square.Before the trials, fish were placed with a hand net in a cylindrical arena (20 cm diameter) made of Plexiglas placed in the centre of our experimental tank.Following a five minutes acclimatization period, this arena was removed and fish were able to freely swim in the experimental tank.We performed 10 replicates for each combinaison of parameters (number of fish x environmental condition).

D. Data analysis
The recorded videos were analyzed offline using a custom Matlab script developed to detect the position of the fish.This script performed a background subtraction on each frame and transformed it in a binary image according to a pixel intensity threshold given by the user.The software then identified the blobs on this image and kept only the blobs that were formed by more than 20 and less than 200 pixels (those values were obtained by manually identifying the fish on multiple frames).Since this method did not allow a perfect detection of all the individuals, we developed a second script that was run after the first one and that plotted the frame where a fish (or more) was undetected for the user to manually identify the missing individual(s).While this analysis tool is time-costly, it allowed us to identify the fish that were partially hidden during a collision/superposition with another fish or the fish that were situated under the floating disks since our program was not able to detect them due to a lack of intensity of the pixel after the background subtraction.The positions P (x, y) of the fish were recorded at each time step t = 1/15s during the experiment with single fish in homogeneous environment and t = 1s for all other experimental conditions.This allowed us to build the trajectory of each individual for experiments involving a single fish and to compute the speed of the individuals as well as their change in orientation between successive positions.The instantaneous speed v t was calculated on three positions and thus computed as the distance between P (x, y, t − 1) and P (x, y, t + 1) divided by 2 time steps while change in orientation were computed as the angle between two successive speed vectors).The distributions of speed were computed only for parts of the trajectory during which the fish were not in freezing behaviour (i.e.immobile).This corresponds to a spontaneous speed higher than 1mm per second.Since our tracking system did not resolve collision with accuracy, we did not calculate individual measures for data obtained with groups of fish but characterized the aggregation level of the group.

E. Implementation and numerical simulations
The model was implemented in a Matlab script.The simulations were run during 10800 time steps, each time step representing an increment of 1/3 second to simulate a total time of 1 hour, similarly to our experiments.This time step was chosen according to the tail beat frequency of the zebrafish of 2.5 Hz.By doing so, we assume that zebrafish can potentially change their orientation at each tail beat.The position of the agents on the 2D plane space is described by the position of their head (x, y, 0).The positions of the other vertices are computed according to the position of the head and the direction of the fish.To compute the solid angle of the perceived stimuli in the perception field of the focal fish, we calculated the area of the spherical polygon delimited by the projection of the stimuli's vertices on a unit sphere centered on the focal fish.To do so, we divided the polygon in two spherical triangle and computed their spherical excess using L'Huilier's theorem : with a, b, and c the length of the arcs between the vertices expressed in spherical coordinates (ρ, θ, φ) and computed by : a = arccos(sin(φ1) sin(φ2) + cos(θ1 − θ2) cos(θ1) cos(θ2) (15) and s the semi parameter given by :

FIG. 5 :
FIG. 5: Example of experimental (A-B) and simulated (C-D) trajectories of a fish swimming alone during 10 minutes in the absence (A-C) or presence (B-D) of two floating disks.The colour of the trajectory indicates the speed of the individual.

FIG. 6 :
FIG. 6: Experimental individual behaviour of single fish from AB strain in the experimental tank without stimuli.(A) The distribution of the speed shows an average speed of 0.07 ± 0.03 ms −1 .(B) The distribution of the change in orientation highlights that fish are mainly swimming forward with low deviation.Results are cumulated for 10 replicates of one hour.

FIG. 8 :
FIG. 8: Fitting by sum of least squares minimisation of the parameters dw and κW determining the interaction of a single fish with the walls of the tank.The parameter dw corresponds to the threshold distance of interaction with the walls and κW is inversely proportional to the width of the von Mises distribution associated with wall following.To each couple (dw, κW ) corresponds a couple of squares whose colours indicate the value of the sum of least squares obtained for the comparison of the changes of direction (left square) and the probability of presence (right square) with the experimental data shown in Fig. 6B and Fig. 11A.Lower values of sum of least squares corresponding to better fits are in the purple and blue colour scale.(A) The exploration of a first set of parameter values indicated that the best couple (dw and κW ) are found for values (dw = 0.05 and 15 < κW < 30), highlighted in the red rectangle.(B) The refinement of the parameters exploration in the ranges determined in (A) showed that the best fitting is obtained by dw = 0.05 and κW = 20.

FIG. 9 :
FIG. 9: Cumulated interindividual distances measured between all pairs of fish.Results are obtained for 10 experiments of one hour with 10 groups of 10 fish (A) and 10 simulations with 10 agents (B).

FIG. 10 :
FIG. 10: Fitting by sum of least squares minimisation of the parameters α0 and αW determining the interaction of a focal fish that far away or close to a wall with other individuals.To each couple (α0, αW ) corresponds a couple of rectangles whose colours indicate the value of the sum of least squares obtained for the comparison of the interindividual distances (left rectangle) and the probability of presence (right rectangle) with the experimental data shown in Fig. 9A and Fig. 11B.Lower values of sum of least squares corresponding to better fits are in the purple and blue colour scale.(A) The exploration of a first set of parameter values indicated that the best couples (α0, αW ) are found for values (α0 ≤ 100, 10 ≤ αW ≤ 100), highlighted in the red rectangle.(B) The refinement of the parameters exploration in the ranges determined in (A) showed that the best fitting is obtained by α0 = 55 and αW = 20.

FIG. 11 :
FIG. 11: Probability of presence for experimental (A, B) and simulated (C, D) data.Results are obtained for 10 replicates of 1h.(A) Experimental individual behaviour of single fish from AB strain in the empty experimental tank.The probability of presence showed that fish were mainly swimming along the walls of the tank.(B) Experimental results obtained for groups of 10 AB strain zebrafish in a homogeneous environment.Similarly to single fish, groups of 10 zebrafish were mainly swimming along the walls of the tank.(C) Probability of presence of a simulated single fish in a homogeneous environment during one hour (results for 10 simulations).(D) Probability of presence of a simulated group of 10 fish in a homogeneous environment during one hour (results for 10 simulations).

FIG. 12 :
FIG. 12: Experimental individual behaviour of single fish from AB strain in the experimental tank with two spots of interest.(A) The distribution of the speed shows an average speed of 0.09 ± 0.06 ms −1 outside the spots while fish were swimming with an average speed of 0.03 ± 0.02 ms −1 under the spots.(B) The distribution of the change in orientation highlights that fish are mainly swimming forward with low deviation both outside and inside the spots.Results are cumulated for 10 replicates of one hour.

FIG. 13 :
FIG. 13: Probability of presence for experimental (A, B) and simulated (C, D) data.Results are obtained for 10 replicates of 1h.(A) Experimental individual behaviour of a single fish from AB strain in a tank with two floating discs.The probability of presence showed that fish were mainly swimming along the walls or under the discs.(B) Experimental results obtained for groups of 10 AB strain zebrafish in a heterogeneous environment.The probability of presence showed that fish were mainly present under the floating disks.Results are obtained from 10 replicates of one hour.(C) Probability of presence of a simulated single fish in a homogeneous environment during one hour (results for 10 simulations).(D) Probability of presence of a simulated group of 10 fish in a homogeneous environment during one hour (results for 10 simulations).

FIG. 14 :
FIG. 14: Fitting by sum of least squares minimisation of the parameters β0 and βW determining the interaction of a focal fish that far away or close to a wall with the spots of interest.To each couple (β0, βW ) corresponds a couple of rectangles whose colours indicate the value of the sum of least squares obtained for the changes of orientation (left square) and the probability of presence (right square) with the experimental data shown in Fig. 12B and Fig. 13A.Lower values of sum of least squares corresponding to better fits are in the purple and blue colour scale.(A) The exploration of a first set of parameter values indicated that the best couples (β0, βW ) are found for values (0.05 ≤ β0 ≤ 0.5, 0 ≤ βW ≤ 0.25), highlighted in the red rectangle.(B) The refinement of the parameters exploration in the ranges determined in (A) showed that the best fitting is obtained by β0 = 0.15 and βW = 0.01.

FIG. 15 :
FIG. 15: Fitting by sum of least squares minimisation of the parameters weighting the influence of the fish wF and the spots wS in simulation with 10 zebrafish swimming with two spots of interest.To each couple (wF , wS) corresponds a couple of rectangles whose colours indicate the value of the sum of least squares obtained for the comparison of the interindividual distances (left square) and the probability of presence (right square) with the experimental data shown in Fig. 16A and Fig. 13B.Lower values of sum of least squares corresponding to better fits are in the purple and blue colour scale.The exploration of a set of parameter values indicated that the best couples (wF , wS) is wF = 1 2 , wS = 1 9 .

FIG. 16 :
FIG. 16: Cumulated interindividual distances measured between all pairs of fish swimming in the presence of two spots of interest.Results are obtained for 10 experiments of one hour with 10 groups of 10 fish (A) and 10 simulations with 10 agents (B).