Selective social interactions and speed-induced leadership in schooling fish

Significance Grouping animals interact socially to move together and make collective decisions. These interactions are typically assumed to be attraction to distant individuals, repulsion from too close neighbors, and alignment among neighbors to coordinate movement directions. Combining analysis of experimental data of schooling fish with agent-based modeling, we find that social interactions are modulated by relative speeds between neighbors, where individuals tend to align only with faster neighbors and ignore slower ones. These selective social interactions can be linked to dynamically changing leader–follower relationships defined by relative speeds of neighbors. Our results provide a deeper understanding of emergent leadership based on variable and adaptive speeds of individuals and a different perspective on mechanisms of movement coordination in natural and artificial systems.


INTRODUCTION
Moving animal groups can exhibit a complex and highly coordinated collective behaviour that results in the formation of spatial patterns changing dramatically in time, as observed in fish schools or bird flocks [1,2].A possible framework for interpreting this complex behavior relies on the concept of effective forces acting on individuals.However, contrary to physical forces, these * andreu.puy@upc.eduforces mainly originate from individual decision-making processes and, in particular, do not necessarily fulfil the action-reaction Newtonian principle [3].Depending on their origin, we can classify them into individual forces and social forces.Individual forces are independent of the social environment.They can have a physical explanation related to the mechanics of locomotion, such as propulsion and friction, or be a consequence of nonphysical processes linked to individual movement decision, including intrinsically stochastic behavior and response to environmental cues, such as the presence of tank walls, food sources or predators.Social forces, on the other hand, emerge from the interactions between the individuals of the group and are usually described in terms of a combination of attraction, repulsion and alignment forces [1,2,4].More specifically, attraction allows individuals to aggregate in groups, repulsion prevents collisions and alignment induces individuals to head in the same direction as their neighbours.
Models of collective motion based on self-propelled particles interacting with neighbours via these three kinds of social interactions are able to reproduce typical features observed in moving animals such as polarized movement, where individuals move globally in the same direction; swarming, where individuals aggregate in a group but move in random directions; and milling, where individuals rotate around a core [5,6].Although explicit alignment forces are a straight forward way to induce global orientational state, they are not a necessary condition [3,[7][8][9][10][11].
From an experimental point of view, studies have provided different results regarding the existence of explicit alignment interactions.One possible approach is to postulate a model and optimize its parameters from the experimental data.Lukeman et al [12] assumed a zonal model, where the different attraction, repulsion and alignment forces are implemented in concentric layers around the individual, and found that the strength of alignment was comparable to that of attraction.In a similar spirit but without choosing a specific model, Theraulaz and collaborators [13,14] proposed symmetrical constraints to identify the contributions of the different interactions and obtained simple analytical functions, assuming that the effect of different variables can be separated as a product of functions.They reported alignment interactions that depend on the relative headings and positions between neighbours.An alternative method is to train a neuronal network with experimental data and infer interactions from it.Heras et al. [15] found evidence of alignment for large neighbour speeds and an anti-alignment region behind the individual that was associated to possible interactions with the walls.
The most common procedure to measure forces, however, is the use of 'force maps', also known as 'averaging method', where forces are inferred from the dependency of the acceleration with some relevant variables and averaging over all others.While force maps have been used with great success to infer attraction and repulsion forces in moving animal groups [14,[16][17][18][19][20], they are not free from criticism [14,15,21]: since force maps can be visualized mainly up to two-dimensions, one either has to visualize cuts of higher dimensional objects that may lack statistics or average over some variables; it is not necessarily straightforward to obtain simple analytical expressions to reproduce the observed force maps; different interactions in a force map can appear mixed, which can make them difficult to identify and disentangle; and different interaction rules may result in similar force maps.The existence of effective alignment forces has been investigated through the analysis of changes in relative heading of neighbouring individuals [22].Whereas earlier works failed to identify alignment interactions [16,17], later studies found some evidence for alignment between neighbours [14,18,20].
A common view assumed in most numerical models and experimental analysis is that coherent collective motion emerges spontaneously from symmetrical interactions among identical self-propelled group members.This contrasts with studies of leadership in which the strength of the interactions between pairs is asymmetric and displays a net information flow, sometimes with time delays [23].From the group perspective, one way to represent leader-follower relationships is via complex directed interaction networks [24,25].Furthermore, leadership structures depend strongly on the characteristics of the species but also on many individual factors such as information, physiological state, dominance and navigational competence.In previous works on birds [24], bats [26], and fish [16,17,25,[27][28][29][30], information flow was identified to naturally occur from influential individuals at the front of the group towards following in-dividuals located further back.Leadership was also observed to depend on average individual speeds of previous solo flights for homing pigeons [31] and for schooling fish [29,32,33].Furthermore, deep learning tools have provided evidence that individuals are more influenced by neighbours moving at high speeds [15,30].
Here we review the concept of force maps and introduce a more natural alignment force map in Cartesian coordinates that depends on relative velocities of the focal individual with respect to its neighbours.Using a simple model of collective motion with social and individual forces, we demonstrate the utility of the force maps to capture the attraction, repulsion and alignment forces.Equipped with the proposed alignment force map, we apply it to experimental data of schooling fish and obtain two distinct behaviours: alignment with a neighbour that moves faster than the individual and an unexpected region of apparent anti-alignment when a neighbour moves at slower speeds than the individual.In order to explore the origin of this anti-alignment signal, we investigate an agent-based model with explicit alignment and anti-alignment forces, and show that it fails to reproduce realistic behavioural dynamics.Instead, we are able to reproduce the qualitative behaviour of the experimental data with a selective interactions model, where individuals only interact with neighbours at faster speeds and ignore neighbours with slower speeds.We further examine the selective-interaction hypothesis by studying the effect of leadership at the level of force maps and demonstrate that a follower displays a pure alignment force and a leader effectively a pure anti-alignment force.Finally, we validate the hypothesis that individuals with slower and faster neighbours are leaders and followers respectively, studying time-delayed correlations between the velocities of a focal fish and its neighbour.

Force maps
The force map method allows inferring forces from a system.It assumes the system has several force terms depending on sets of independent variables, and that the average in time of each force term is zero.Consider we want to infer a force term ⃗ f (x) as a function of only the variable x.We can achieve this from Newton's second law by studying the acceleration depending on x while averaging over all other variables in the system, ⃗ a(x) [16].Similar procedures have also been employed in deriving effective equations of motion for motile cells [34].Working in units of mass m = 1, Newton's second law will become ⃗ f (x) ≃ ⃗ a(x), as all other forces will cancel out in the average.In practice, this approach is implemented by binning over the whole dataset the relevant variable x as {x k } k=1,...,M , where k is the index of the bin, and averaging the values of the acceleration on that bin, ⃗ f (x k ) ≃ ⟨⃗ a(x)⟩ x∈x k .

Attraction-repulsion force map
This force map was introduced both by Katz et al. [16] and Herbert-Read et al. [17].It obtains the attraction and repulsion forces from the average acceleration ⃗ a i of an individual i as a function of its position relative to the nearest neighbour N N , ⃗ x i − ⃗ x N N , assuming this neighbour dominates the interaction.We can demonstrate it with a simple model of schooling fish, which we refer as standard model.In this model individuals interact with some social forces, described by attraction-repulsion and alignment terms, and respond to some individual forces, represented by a friction-propulsion term to drive the motion and noise (for more details see Methods).Employing simulations of the model, we display in Fig. 1a the average attraction-repulsion force acting on a focal individual depending on its position relative to the the nearest neighbour.We use values for all focal individuals and time steps (counts are shown in Supplementary Fig. S1a).The components of the force are displayed with arrows and the modulus with the colormap.The y-coordinate is oriented along the direction of motion of the focal individual.We observe for near distances arrows point outwards, indicating the focal fish experiences a repulsive force away from the neighbour.For intermediate distances there is an area with no net force (the equilibrium distance).Finally, for far away distances arrows point inwards, signaling an attractive force towards the neighbour.Now in Fig. 1b we display the attractionrepulsion force map given by the average acceleration for an individual depending on its relative position with the nearest neighbour.Indeed, we observe it recovers satisfactorily the attraction-repulsion force.This procedure works adequately because other forces do not depend directly on the relative position of the individual with the nearest neighbour and tend to cancel out in average (Supplementary Fig. S1b and c).
We note that previous works on the attractionrepulsion force map employed the reversed coordinates ⃗ x N N − ⃗ x i , but they typically separated the acceleration components in different plots and did not display the force with arrows (except in [20]).Because here instead we display the force as a vector, we find more natural to represent it analogously to a force field from physics, where the force at a point indicates the force a particle would feel at that point.Furthermore, we also want to remark that, in absence of other forces, a trajectory observed in the force map is more complex than just following the direction of the arrows, as there will be rotations caused by the y-axis pointing towards the direction of motion of the focal individual.

Alignment force map
Previous works used force maps for the alignment force that depend on angular differences as well as on relative positions, which make the alignment force more difficult to disentangle from the attraction and repulsion forces.
Here instead we introduce a more natural force map for alignment in Cartesian coordinates obtained from calculating the average acceleration ⃗ a i of an individual i as a function of its relative velocity with the nearest neighbour N N , ⃗ v i − ⃗ v N N .This approach is directly inspired from the expression of the alignment force between neighbours in our standard model (see Eq. 2 in Methods).It naturally accounts for the alignment of the full velocity vectors of neighboring individuals, thus not only their direction of movement but also of their speeds.
In Fig. 1c we show the average alignment force acting on a focal individual depending on its relative velocity with the nearest neighbour for the standard model.We employ values for all focal individuals and time steps (counts are shown in Supplementary Fig. S2a).The components of the force are displayed with arrows and the modulus with the colormap.The y-coordinate is oriented along the direction of motion of the focal individual.We observe the force vectors point inwards and increase with the velocity differences.This results in the force term decreasing the relative velocity and aligning the velocity of the focal individual with that of its neighbour.In Fig. 1d we show the alignment force map given by the average acceleration in this representation.This force map also recovers successfully the qualitative behaviour of the alignment force, with arrows pointing inwards (this is clearly observed looking at the projection of the acceleration in the radial direction of the force map in Supplementary Fig. S3a).Again, this works because other forces of the model do not depend directly on the relative velocity of the individual with the nearest neighbour and have small contributions in this representation (Supplementary Fig. S2b and c).

Experimental force maps
Equipped with the force maps technique outlined above, we are now able to explore experimental data of schooling fish.With this purpose, we analyze the motion of N = 39 individuals of the species black neon tetra Hyphessobrycon herbertaxelrodi, a highly social fish that tends to form polarized, compact and planar schools, freely swimming in an approximately two-dimensional experimental tank (see Methods for experimental details).
We start with the attraction-repulsion force map in Fig. 2a (the counts of the force map are shown in Supplementary Fig. S4a).We see this force map has a similar qualitative behaviour to the attraction-repulsion force for the standard model (Fig. 1a), with repulsion for short distances, no net force for intermediate distances and at- traction at large distances.
Now we turn our attention to the alignment force map obtained from experimental data, displayed in Fig. 2b (the counts are shown in Supplementary Fig. S4b).Contrary to the alignment force from the standard model (Fig. 1c), we can identify two qualitatively different behaviours depending on the sign of the difference of velocities between an individual and its nearest neighbour in the direction of motion of the individual (y-axis).If the neighbour is moving at faster speeds than the individual (lower-half part), we observe alignment interactions with the acceleration pointing inwards.However, when the neighbour moves at slower speeds than the individual (upper-half part), the acceleration points outwards and indicates a surprising anti-alignment interaction, with fish turning away from neighbours.This observation is made more apparent with the projection of the acceleration in the radial direction of the force map, in Supplementary Fig. S3b.
We find that the qualitative behaviour of the alignment and anti-alignment regions in the alignment force map is robust against a variety of factors: different number of fish (Supplementary Fig. S5); different distances between neighbours (Supplementary Fig. S6), which tests for possible effects originating from the attraction or repulsion regimes in the attraction-repulsion force; different distances to the tank walls (Supplementary Fig. S7), which discards possible interactions with the walls; for the case the fish is approaching or moving away from the neighbour (Supplementary Fig. S8); for different heading orientations between the fish and its neighbour (Supplementary Fig. S9); and for different velocities of the focal individual (Supplementary Fig. S10).Only when differentiating the case where the neighbour moves at faster or slower speeds (Supplementary Fig. S11), we observe exclusively alignment or anti-alignment interactions in the expected regions of the map.

Explicit anti-alignment model
We find the standard model of schooling fish reproduces properly the attraction-repulsion force map in the experimental data of schooling fish, but is unable to account for the alignment force map.To correct this, we now consider a model variation implementing explicitly the alignment force observed experimentally.We do so by defining an alignment force given by an interpolation of the values in the experimental alignment force map, which is previously smoothed with a Gaussian filter of window σ = 2.All other forces and parameters are kept the same as in the previous section.
Despite the model reproduces qualitatively the expected alignment force map (Fig. 3a and Supplementary Figs.S12 and S3c), the dynamics is unrealistic.When an individual is moving faster than its neighbours, it is located in the anti-alignment region of the force map and the explicit anti-alignment force causes the individual to accelerate in the forward direction, which in the absence of other forces will result in an even larger speed.This behaviour is observed in the simulations of the model (see Supplementary Video S3), where some individuals acquire large speeds and move towards the front of the group.However, this is not found in the experimental data and there is no biological motivation for fast fish to waste energy by increasing their speed further.

Selective interactions model
The non-physical and non-biological features of the explicit anti-alignment model suggest that the antialignment region observed in the alignment force map of the experimental data may not originate from an explicit anti-alignment rule, but it could instead emerge from some other interaction that appears effectively as an anti-alignment force.
To explore this idea, we first study the effect of a persistent random force in the alignment force map.We propose a variation of the standard model, in which individuals have some probability rate r to switch off their social interactions and feel instead a persistent force in a fixed random direction with a given amplitude A for some time τ .Biologically, this can be motivated as an individual fish may decide to follow private information based on environmental cues and temporarily ignore social cues.Depending on the relative strength of the persistent random force compared to the alignment force, we observe two different outcomes.When the alignment force dominates the persistent random force, we obtain an alignment force map that is still full alignment (Supplementary Fig. S13b).However, the persistent random force contributes to the total force with anti-alignment (Supplementary Fig. S13d).We can understand this as in a group with overall high directional alignment, a persistent "private" force acting temporarily in a fixed random direction will tend to make the focal fish turn away from their neighbour's direction and appear effectively as an anti-alignment interaction.Naively, one could expect that in the regime when the persistent random force dominates the alignment force, the resulting alignment force map would be anti-alignment.However, that is not the case as there is not anymore ordered collective motion and the force map is essentially noise.To connect this idea with the observed experimental alignment force map, we propose another variation of the standard model, a selective interactions model where individuals pay attention primarily to neighbours exhibiting strong movement cues.We assume that individuals interact socially with neighbours that move at a speed larger than their own, and switch off social interactions with neighbours that move at a smaller speed (see Supplementary Video S4).The weights in the social interactions are calculated as in the standard model (see Methods) but considering only faster neighbours.We display the alignment force map in Fig. 3b (see Supplementary Figs.S14 and S3d).We see this model reproduces the features observed in the experimental data, with alignment for faster neighbours and anti-alignment for slower neighbours.The emergence of anti-alignment for slower nearest neighbours in this model can be traced back to the attraction-repulsion force (see Supplementary Fig. S14).Although this force is switched off for slower neighbours, the focal individual will continue to interact with other non-nearest faster neighbours.Thus, when we construct the alignment force map for the slower nearest neighbours, the actual dynamics of the focal agent is driven by attraction to farther away neighbours, which may be located at random relative positions.This force then can act in any direction and, therefore, appears effectively as a persistent random force.As we found previously, this results in individuals on average turning away from their nearest neighbour and displaying apparently an anti-alignment interaction.

Comparison of model observables
Our analysis based on the alignment force map suggests the selective interactions model as a more accurate depiction of the experimental data than the standard model.Here, we extend our investigation by compar-ing the models and the experimental data with a set of observables (Fig. 4 and Supplementary Fig. S15).The polarization ϕ, defined as is a measure of the group order that tends to 1 if all individuals move in the same direction, and decreases when they move in increasingly different directions.The nearest neighbour distance averaged for all individuals ⟨d N N ⟩ is a measure of the cohesiveness of the group.The convex hull of the group is defined as the smallest convex polygon that contains all individuals.Its area normalized by the number of individuals s is a measure of the extension occupied by the group.The contact duration time between Voronoi neighbours t V is a measure of the persistence of the local neighbours structure.In addition we also consider individual speeds v i and turning rates ω i .The selective interactions model outperforms the standard model in its ability to reproduce the various experimental observables: it is on average less ordered by displaying a broad distribution of order parameter values (with more low polarization values in Fig. 4a); it exhibits a larger variability in the nearest neighbour distances and in individual speeds (wider PDFs in Fig. 4b and Supplementary Fig. S15b, respectively), more extended groups (with higher values for the convex hull areas in Fig. 4c) and larger rates of neighbours shuffling (with shorter contact duration times of Voronoi neighbours in Fig. 4d).On the other hand, individual turning rates are similar for the models and the experimental data (Supplementary Fig. S15a), despite the unbounded space of the models result in less large turning rates.We also observe in Supplementary Fig. S15c that both models display oscillations in individual speeds that resemble the oscillations in the experimental data, which are a consequence of the burst-and-coast mechanism of fish locomotion [35][36][37].The similarities in a set of observables between the selective interactions model and the experimental data provide additional support for the selective interactions hypothesis.However, given the model's parsimonious approach, we do not anticipate it to account for many specific details of the system.

Leadership and alignment
The above results suggest that the features of the experimental alignment map may be explained by selective social interactions with faster individuals.In this section, we want to validate this hypothesis, connecting it to the possible presence of leader-follower relationships.
We start by constructing surrogate data where we know a priori the flow of information between leaders and followers, and use the alignment force map to explore it.To achieve this, we use the following trick in the experimental data: for the focal individual we take the individual i at the present time t, while for the neighbour we consider the same individual i at a delayed time t + τ .The situation is depicted in Fig. 5a.In the case of a pos-itive delay τ , the direction of the individual at present will follow that of the individual in the future after the delayed time, such that the individual at present can be interpreted as the follower within this pair.Now, when we observe the alignment force map for the individual at present (Fig. 5b and Supplementary Figs.S16 and S3e), we find alignment in all regions.This suggests a follower aligns with a leader.In the case of a negative delay, we have the opposite situation and the direction of the individual at present is adopted by the individual in the past after the delayed time and thus the individual at present can be interpreted as the leader.In the alignment force map (Fig. 5c and Supplementary Figs.S16 and S3f), this results in anti-alignment in all regions, i.e. a leader appears to anti-align with a follower.However, this does not necessarily imply explicit anti-alignment, but originates rather from the leader ignoring the follower and moving in a different direction.
Extrapolating this analysis to the experimental alignment force map (Fig. 2b) hints to the idea that individuals act as leaders when moving faster than their neighbours (anti-alignment region), while they act as followers when moving slower than their neighbours (alignment region).We verify this idea by calculating correlations between the velocities of the individual and the nearest neighbour at a delayed time in the experimental data.We consider two types of correlations, in the orientation given by ⟨v i (t) • vNN (t + τ )⟩ [24] (Fig. 6a) and in the speed given by the Pearson correlation coefficient r(v i (t), v N N (t + τ )) [16] (Fig. 6b).Both measures are computed employing all time frames t.In the presence of leadership interactions, a follower requires some time to react and copy the leader.This results in these correlations having a higher value at that delayed time, provided the frame rate is higher than the reaction time of the follower.If the maximum occurs for a positive delay τ , this implies the individual is the leader.While for a negative delay, the individual is the follower.Moreover, the value of the maximum reflects the amount of information transmitted by the leadership flow.We are interested in studying correlations differentiating by the state of the individual.In Fig. 6, the red and blue lines display the correlations performed for individuals faster and slower than their neighbour, respectively.Indeed, we see in both correlations that faster individuals have a maximum for positive delays, which means they are leaders.The opposite occurs with slower individuals, which act as followers.We also compare this measure of leadership with the commonly used measure of frontal distances along the direction of motion of the individual [24,38], filtering for frontal and rear individuals (orange and green lines).In fact, we find correlations have higher values for faster and slower individuals than for frontal and rear individuals, while frontal and rear individuals are more similar to the base line correlations considering all individuals (black dashed line).This indicates leadership in neighbours is better described by relative speeds rather than with frontal distances along the direction of motion.Note also that the faster and slower curves are not necessarily symmetrical along the y-axis, as several individuals can have the same nearest neighbour.The same occurs for frontal and rear, but in addition, a frontal and rear individual in the direction of motion of the individual can also be frontal and rear respectively in the direction of motion of the neighbour.
As an example of this phenomenon, in Supplementary Video S5 we display a sample of a recording where we observe how the focal individual (green) tends to align with faster neighbours (blue) and ignore slower neighbours (red).

DISCUSSION
In this paper we have introduced a force map to study the alignment force.Using this force map together with the attraction-repulsion force map, we have been able to capture and distinguish the attraction-repulsion and alignment forces in a simple model of schooling fish.Applying it to experimental data, we found a robust signature of alignment of the focal individual with faster neighbours and anti-alignment with slower neighbours.Instead of explicit anti-aligning behavior, we suggest that the signatures of anti-alignment are the result of a selective attention mechanism, where fish pay less attention and, thus, have weaker interactions with slower neighbours.We were able to find support for this hypothesis by analysing the effective interactions in an agent-based model with selective social forces.While inferences from interactions in force maps are unlikely to be unique [14], we tested the hypothesis building a connection between the alignment patterns and leadership interactions.We show that followers display only alignment force and leaders only anti-alignment force.We then verified in the experimental schooling fish that faster and slower individuals are leaders and followers respectively with their nearest neighbours by calculating correlations between the velocities of the individual and the nearest neighbour at a delayed time.This measure of leadership is found to be more statistically significant than the traditionally used in the literature of frontal distances along the direction of motion [24,27,38].
Our findings of selective social interactions based on relative individual speeds provide further evidence of attention switch mechanisms previously described in collective behaviour [3,[39][40][41][42], as well as in the similar field of animal contests over resources [43,44].Attention switch mechanisms are believed to reduce the cognitive load of individuals and facilitate efficient and accurate decision-making processes [39][40][41].Our experimental species black neon tetra displays a strong schooling behavior.Thus we expect our results to be representative of other fish species forming highly polarized schools.In any case, the methods introduced in this work are general and therefore, applicable to other scenarios.
If we interpret social interactions between individuals as a method to transfer information across the group, these results suggest higher relevance of information provided by faster moving individuals [30].This makes biological sense as informed individuals acting on privately acquired information, such as perception of a predator or food, are expected to move at higher speeds [25].More generally, motion cues are believed to play a major role in visual sensory processes of organisms, conveying information that can directly impact the individual, such as in navigation, foraging, courtship or predator avoidance [40,45]; but also as faster movement cues, embedded in a background of slower moving ones, are perceptually more salient [39,46,47].Apart from vision, the lateral line, with which fish detect movement, vibration, and pressure gradients in the surrounding water, is also reactive to neighbouring individual speeds [48,49].It is important to emphasize that, in the context of these latter hypotheses, the reported selective interactions would not be attributed to an adaptive selective attention mechanism, but would instead emerge from cognitive constraints related to receiving information from slower-moving individuals.
While previous research suggests that individual speeds play an important role in shaping collective movement, and that leader-follower interactions are mediated by speeds, the proposed mechanism was based on individuals with different average speeds, assuming homogeneous and constant social interactions [29,[31][32][33].Having different average speeds induce sorting of individuals and ultimately give rise to the well-established leadership of frontal distances along the direction of motion [18].With the current work we take a step forward connecting speed and leadership.The presence of selective social interactions based on instantaneous relative speeds implies a dynamic modulation of social interactions, which not only amplifies the importance of individual speed, but also provides a mechanism for dynamic adaptation of leader-follower relationships on short time-scales independently of the average preferred speed of individuals.
In the calculation of force maps, we considered only the relative position and velocity of a single, nearest neighbour.While this is supported by 1-2 influential neighbours identified in previous work on fish schools [17,50,51], one could, in principle, also use the relative position and velocity of all Voronoi neighbours (Supplementary Fig. S17).While we observe partial screening of attractive interactions in the attraction-repulsion force map, the force maps with Voronoi neighbours resemble qualitatively the force maps with the nearest neighbour.This suggests that the nearest neighbour dominates the interactions.We also find support for this idea when we explored simulations with individuals interacting only with the nearest neighbour and found similar results (Supplementary Fig. S18); and for simulations with individuals interacting with Voronoi neighbours without weights that resulted in more inadequate force maps with some screening effects.
Force map techniques to infer underlying interactions are straightforward and easy to apply.However, interpreting the results requires caution, and implementing certain validation procedures is advised.In this work, we have presented a force map to extract the alignment force between individuals in experimental data of schooling fish.A first step in validating the results involves ensuring the force map is unaffected by other interactions.
We approached this by identifying potential confounding factors such as the influence of tank walls, the attractionrepulsion force, and the group's density.We then demonstrated that the results were consistent under changing conditions of distances to the walls, distances and orientations to neighbours, and employing schools with differing numbers of fish.A secondary validation measure consists of applying the force map to simulations of models with controlled interactions and comparing the findings.We found that a simple model of schooling fish does not reproduce the experimental signatures and some modifications had to be introduced.Finally, to conclusively validate the results, it is recommended to employ other independent methods to infer interactions.In our study, we accomplished this by analyzing leader-follower relationships.Other possible methods include fitting simple expressions from symmetrical constraints and simplifying hypotheses [13], and training neural networks [15].
Our results showcase how selective social interactions may lead to unexpected signatures at the level of averaged behavioral responses to social cues.It is of relevance for quantitative analysis of social interactions across taxa, as it demonstrates that extreme caution is needed when extracting behavioral algorithms from aggregated data such as force maps, in particular in the context of complex self-organized collective behaviors.Here, a combination of quantitative data as well as theoretical modelling taking into account properties and constraints of perception will provide deeper insights into social interactions and functional aspects of collective behavior with respect to transfer and distributed processing of information.More specifically, selective social interactions de-pending on relative speeds likely play an important role for different grouping phenomena [3], and provide an explicit mechanism on how speed may be a core variable at the individual level affecting the dynamics and the structure of animal collectives [32,33,[52][53][54].

Standard model
We consider a model of schooling fish in twodimensions with N individuals where each individual i is subject to a total force ⃗ F i given by social forces, represented by attraction-repulsion ⃗ F att-rep i and alignment ⃗ F alig i forces, and individual forces, consisting of a frictionpropulsion force ⃗ F fric-prop i and noise ⃗ F noise i that capture other unknown forces [56]: For simplicity, we use a first order approximation for the different force terms.The attraction-repulsion force acting on an individual i due to the neighbour j reads: where d 0 is the equilibrium distance between neighbours, d ij = |⃗ x j − ⃗ x i | is the distance between individuals i and j, ⃗ x i is the position of individual i and k = k rep for d ij ≤ d 0 and k = k att for d ij > d 0 .This force acts as a restoring force towards the equilibrium distance between the neighbours.The alignment force experienced by an individual i due to its neighbour j is given by [57]: where µ is the alignment constant and ⃗ v k are individual velocities.This force acts as a restoring force for the focal individual towards reaching the same speed and heading as its neighbour.
We use interactions with Voronoi neighbours, which are a good approximation to visual interaction networks and can be calculated efficiently [57][58][59][60], and we average the social forces, ⃗ for the different neighbours with weights given by the inverse of their metric distance d ij : where w ij = 1 dij .With this choice of weights, closer neighbours exert more influence, a result observed in previous studies [15,17,25,61].
For the individual forces, we use a friction-propulsion term [57]: where v 0 is the fish preferred speed and τ is the speed relaxation time.This introduces a self-propulsion force for the fish to move with a speed around v 0 , with τ being the typical timescale of velocity adaptation.The noise force corresponds to active fluctuations [57,62], with independent noise terms acting on the direction of motion vi and its perpendicular direction φi : where σ v and σ φ are the noise constants, and ξ v (t) and ξ φ (t) are independent Gaussian white noise processes with ⟨ξ x (t)ξ y (t ′ )⟩ = δ(t − t ′ )δ xy .We perform simulations integrating numerically the equations of motion in order to obtain the trajectory ⃗ x i : where ⃗ a i = d 2 ⃗ xi dt 2 is the acceleration, and we work with units of mass m = 1.The values of the parameters in the model, shown in Table I, have been selected in order to provide similar results to our experimental data, as described in the Supplementary Information.
Here we work with N = 39 individuals, matching the maximum number of fish in our experimental data.We solve the stochastic differential equation with the Euler-Maruyama algorithm [63].We choose random initial positions and velocities for the individuals such that the extension of the group and speeds are similar to the experimental school, but each individual is oriented uniformly at random.The simulation space is unbounded and positions can reach any value.We set a time step ∆t = 0.02 s and save all frames, analogous to the experimental data.We discard as transient the first 1000 frames and run simulations for 150000 frames.We show in Supplementary Video S2 samples of trajectories generated by the standard model.

Experimental data
Experiments, performed at the Scientific and Technological Centers UB (CCiTUB), University of Barcelona (Spain), were made with black neon tetra Hyphessobrycon herbertaxelrodi, a small freshwater fish of average body length 2.5 cm that has a strong tendency to form cohesive, highly polarized and planar schools [64].Applicable institutional guidelines for the care and use of animals were followed.All procedures performed were in accordance with the standards approved by the Ethics Committee of the University of Barcelona.
Experiments consisted in N individuals freely swimming in a square tank of 100 cm of side with a water column of 5 cm of depth, resulting in approximately two-dimensional movement.Videos of the fish movement were recorded at 50 frames per second with a resolution of 5312×2988 pixels, such that the side of the tank measures 2745 pixels.Digitized individual trajectories were obtained from the video recordings using the software idtracker.ai[65].Invalid values returned by the program caused by occlusions were corrected in a supervised way, semi-automatically interpolating with spline functions (now incorporated in the Validator tool from version 5 of idtracker.ai).For better accuracy, we projected the trajectories in the plane of the fish movement, warping the tank walls of the image into a proper square (see Supplementary Information).Moreover, we smooth the trajectories with a Gaussian filter with σ = 2, truncating the filter at 5σ.We calculate the velocities and accelerations from the Gaussian filter using derivatives of the Gaussian kernel.
We performed experiments with N = 39 fish (2 recordings of 60 minutes) and N = 8 (6 recordings of 30 minutes).In Supplementary Video S1 we show a rendering of of the evolution of the N = 39 school with the digitized trajectories overlapped with the real video.

TRAJECTORIES PROJECTION
The perspective of the camera was not exactly perpendicular to the plane of motion of the fish.For better accuracy, we project the calculated trajectories to the plane parallel to the bottom of the tank.In order to do this, first we look for the pixels of the corners of the tank walls in the videos and calculate the height and base of the corresponding rectangle in pixels.Because the tank is actually a square, we define the side of the tank L in pixels as the average value of the base and height of the rectangle image.We define the new tank corners: (0, 0), (0, L), (L, 0) and (L, L) and we calculate the perspective transform matrix M from the original and new tank corners using the function getPerspectiveTransform() from the OpenCV library [66].Finally, we obtain the transformed trajectories (x ′ , y ′ ) applying a perspective transformation to the original trajectories (x, y), as ex-plained in the OpenCV documentation: Video S1.Rendering of the movement of fish in a experimental school of size N = 39, overlapped with the digitized trajectories, displayed in blue.
Video S2.Dynamics for the standard model of schooling fish.The reference frame is comoving with the center of mass of the group.The position of the individuals and their velocities are shown in blue.We also display the different force terms in the model (legend): the alignment force (magenta), the attraction-repulsion force (red) and the friction-propulsion force (cyan).Each individual is linked with an edge to their Voronoi neighbours: in blue when they have attraction and in orange when they have repulsion.
Video S3.Dynamics for the explicit anti-alignment model.The reference frame is comoving with the center of mass of the group.The position of the individuals and their velocities are shown in blue.We also display the different force terms in the model (legend): the alignment force (magenta), the attraction-repulsion force (red) and the friction-propulsion force (cyan).Each individual is linked with an edge to their Voronoi neighbours: in blue when they have attraction and in orange when they have repulsion.
Video S4.Dynamics for the selective interactions model.The reference frame is comoving with the center of mass of the group.The position of the individuals and their velocities are shown in blue when they interact with other individuals and in black when they do not interact.We also display the different force terms in the model (legend): the alignment force (magenta), the attraction-repulsion force (red) and the friction-propulsion force (cyan).Each individual is linked to their Voronoi neighbours with an edge reaching half their distance if they are interacting: in blue when they have attraction and in orange when they have repulsion.

FIG. 1 .
FIG. 1. Attraction-repulsion and alignment force maps for the standard model.The force maps are able to recover qualitatively the behaviour of the corresponding forces.Average (a) attraction-repulsion force and (b) acceleration (attractionrepulsion force map) acting on an individual i depending on its relative position with the nearest neighbour N N , ⃗ xi − ⃗ xNN .We observe for small distances repulsion, for intermediate distances no net force and for large distances attraction.Average (c) alignment force and (d) acceleration (alignment force map) acting on an individual i depending on its relative velocity with the nearest neighbour N N , ⃗ vi − ⃗ vNN .In all plots, the y-axis is along the direction of motion of the focal individual, the colormap displays the modulus of the force and the arrows its components.Forces are expressed in units of mass m = 1.We employ values for all focal individuals and time steps in the simulation.

FIG. 2 .
FIG. 2. Force maps for the experimental data: (a) attraction-repulsion and (b) alignment force map.While the attractionrepulsion force map is similar to the standard model, the alignment force map displays a striking different behaviour: in the lower-half region arrows point inwards indicating alignment but in the upper-half region arrows point outwards indicating anti-alignment.

FIG. 3 .
FIG. 3. Model variations with alignment and anti-alignment regions in the alignment force map.Alignment force maps for (a) the explicit anti-alignment model and (b) the selective interactions model.

FIG. 4 .
FIG.4.The selective interactions model is more similar to the experimental data than the standard model for a set of observables.Probability density functions (PDF) of (a) polarization ϕ, (b) instantaneous average nearest neighbour distance ⟨dNN ⟩, (c) area of the convex hull normalized by the number of individuals s and (d) contact duration time between Voronoi neighbours tV .The error bands are calculated from the standard deviation of a Bernoulli distribution, with the probability given by the fraction of counts in each bin.

FIG. 5 .FIG. 6 .
FIG. 5. Surrogate data of the experimental school with known leader-follower interactions.(a) We compare the individual i with itself at a delayed time τ .(b)-(c): Alignment force maps comparing the individual i with itself at a (b) positive and (c) negative delayed time τ = 0.2 s.When the delay is positive, the individual at present acts as a follower and we see pure alignment.When the delay is negative, the individual at present acts as a leader and we see pure anti-alignment.
ACKNOWLEDGMENTS A.P. acknowledges a fellowship from the Secretaria d'Universitats i Recerca of the Departament d'Empresa i Coneixement, Generalitat de Catalunya, Catalonia, Spain and a scholarship Erasmus+.P.B. and P.R. acknowledge funding by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany's Excellence Strategy -EXC 2002/1 "Science of Intelligence" -project number 390523135.M.C.M. acknowledges financial support from the Spanish MCIN/AEI/10.13039/501100011033,under Projects No.

Video S5 .
Sample of a recording where the focal fish i (green) tends to align with faster neighbours (blue) and ignore slower neighbours (red).Arrows indicate the velocity of individuals.Voronoi neighbours are coloured by their relative speed with the focal individual, vjV − vi.
FIG. S1.(a) Counts, (b) average alignment and (c) average friction-propulsion force acting on an individual i depending on its relative position with nearest neighbour N N for the standard model.The y-coordinate is along the direction of motion of the individual.Forces are expressed in units of mass m = 1.
FIG. S4.Counts for (a) attraction-repulsion and (b) alignment force maps for the experimental data.
FIG. S5. force maps for experimental data for a smaller number of fish N = 8.

TABLE I .
Parameters used in the standard model.We work in units of mass m = 1.