DOI: 10.5061/dryad.83bk3j9xr
title: Data from: taking a shortcut: what mechanisms do fish use?

description: Path integration is a powerful navigational mechanism whereby individuals
 continuously update their distance and angular vector of movement to
 calculate their position in relation to their departure location, allowing
 them to return along the most direct route even across unfamiliar terrain.
 While path integration has been investigated in several terrestrial
 animals, it has never been demonstrated in aquatic vertebrates, where
 movement occurs through volumetric space and sensory cues available for
 navigation are likely to differ substantially from those in terrestrial
 environments. By performing displacement experiments with Lamprologus
 ocellatus, we show evidence consistent with fish using path integration to
 navigate alongside other mechanisms (allothetic place cues and route
 recapitulation). These results indicate that the use of path integration
 is likely to be deeply rooted within the vertebrate phylogeny irrespective
 of the environment, and suggests that fish may possess a spatial encoding
 system that parallels that of mammals.
description: Ethics and Approval The
 study was approved by the University of Oxford’s Animal Welfare and
 Ethical Review Body (AWERB) (project code:
 APA/1/5/ZOO/NASPA/Burt/DistanceEstimation).
 Animal husbandry We used 40
 naive adult male cichlids (<em>Lamprologus ocellatus,
 </em>Figure 4), sourced from a captive-bred laboratory population
 (standard body length = 3-5cm). Individuals came originally from 6
 subpopulations: B (n=4), C (n=7), D (n=1), E (n=4), F (n=16), G (n=8,
 Table S3). Subjects were housed individually in tanks measuring 35 cm x 32
 cm x 60 cm (width x height x length) containing a sand substrate to a
 depth of 4 cm and a single home shell. Illumination via fluorescent light
 followed a 12h light/dark cycle. Individuals were fed twice a day, in the
 morning and the afternoon, with commercial flake food, supplemented with
 <em>Mysis</em> shrimps once a week. The tanks were cleaned
 once a week and the water quality checked to maintain constant pH, gH and
 KH of 8.4, 23 and 12ppm respectively. Ammonia and nitrites were kept at
 0ppm, while nitrates were maintained below 10ppm. The water temperature
 was maintained at 26±1° C. One individual (C39d), from
 subpopulation G, died between its two test sessions from an unknown cause
 and was replaced by individual C39 (Table S1).
 Experimental apparatus We
 used a 1.3 m<sup>2</sup> experimental tank (height: 0.45 m),
 with 0.06 m of sand substrate and 0.18 m of water. Water parameters and
 water changes were managed as for the home tanks. On the top left corner
 of the experimental tank, a shell was placed in front of an L-shaped
 tunnel 0.6 m long (the two external walls were 0.3 m and 0.3 m, Figure 1)
 and 0.07 m diameter. The 0.6 m length of the tunnel was chosen because it
 produced an average beeline distance in the centre of the tunnel of 0.53
 m, which is within the average range of inter-shell distance for this
 species <sup>16</sup>. The tunnel led to a transparent holding
 chamber of diameter 0.1 m where a food reward was placed. The holding
 chamber had a sliding door connected to the L-shaped tunnel. The sliding
 door was operated by the experimenter, situated outside the experimental
 apparatus. The sides of the experimental tank were covered by white opaque
 Perspex (31 cm in height). A plain white curtain (length: 6 m; height: 1.5
 m) covered the entire tank to eliminate external visual cues. An
 achromatic checkerboard pattern printed on fabric was suspended above the
 experimental tank 1.5  m<sup>2</sup>). Two holes (1 cm
 diameter) were cut in two different black squares of the checker pattern
 and cameras was mounted in these positions. The first camera was
 positioned above the reward chamber (top left corner of the experimental
 tank) and was used to visually ensure that the fish entered the chamber
 before the door was closed. The second camera was positioned in the centre
 of the experimental tank and used to record the trajectories of the
 fish. Testing procedure
 Individual fish were placed in the experimental tank for
 acclimation the day before the test (between 15:00 – 17:00). They were
 transferred from their home tank to the experimental apparatus within
 their home shell to limit their stress (see Figure 1a for position in the
 experimental tank). The following morning, the L-shaped tunnel and chamber
 were placed into the experimental tank. A high-quality food reward
 (bloodworm) was placed in the chamber and the sliding door was then
 opened. Fish eventually swam into the reward chamber in search of food.
 Only once the fish reached the reward chamber and began eating, was the
 door shut. A black plastic sheet was then clipped onto the chamber to
 prevent the fish from seeing the experimenter. Once the tunnel and shell
 were removed, the holding chamber was slowly displaced either laterally:
 0.5m to the right (Figure 1c) or diagonally: 0.71 m right-down (Figure
 1d). Those two displacement positions were chosen to ensure that the
 predicted search areas were at least 0.5 m from any tank walls, and
 reducing the likelihood that fish used the walls as navigational cues. The
 two positions were marked by white Perspex squares fixed to the bottom of
 the experimental tank and hidden under the sand. To ensure the chamber was
 displaced to an exact position, the experimenter aligned the Perspex
 squares with the chamber. After displacement, the sand substrate was mixed
 thoroughly and relevelled to scramble any visual or odour cues. The
 plastic sheet covering the reward chamber was then removed and the door
 was opened (mean ± sd latency before opening the reward chamber after
 displacement = 210 ± 50 sec). Following release, the fish was allowed to
 swim in the experimental tank for 5 min. If the fish did not exit the
 reward chamber after 15 minutes, the trial was terminated.
 Subjects were divided into two groups of 20 individuals (Table
 S1). Each individual was tested in a lateral and a diagonal displacement
 test (Figure 1b, 1c), with an interval of two weeks between tests. Group 1
 was tested first for lateral displacement and then for diagonal
 displacement and group 2 was tested for displacement diagonal and then
 lateral (see Table S1). Data
 collection The water temperature and times
 were recorded on both the acclimation and experiment day. The number of
 times each fish swam backwards and forward into the first and second
 branch of the L-shape tunnel before entering the holding chamber was
 recorded. The time taken to 1) enter the tunnel, 2) enter the chamber, and
 3) exit the chamber after displacement was also recorded.
 All trials were recorded using an overhead web camera (ELP Webcam
 10-megapixel, Model X000VD0KT5). Videos were manually processed using
 custom code written for MATLAB version R2022a, MathWorks Inc. Every
 second, the position of the fish was identified by clicking on the head of
 the fish. X and Y coordinates were then extracted and used to produce a
 continuous 2D trajectory. Fish movements were analysed for one minute
 after exiting the chamber. Individuals did not display any search
 behaviour, such as loops of ever-increasing size around the expected
 location of the starting point <sup>19</sup>. Therefore, each
 trajectory, beginning at the opening of the reward chamber, was cropped
 once the fish oriented back to the chamber, following e.g., Holbrook
 & Burt de Perera <sup>20</sup> (Figure S1).
 Of the 40 fish tested, 24 completed one or both trials
 successfully (n = 37 successful trials). In the remaining trials, fish
 failed to enter the reward chamber (21 individuals, 26 trials), exit the
 reward chamber after displacement (6 individuals, 7 trials) or did not
 move away from the reward chamber after exiting (10 individuals, 10
 trials). Statistical
 analysis Trajectory analysis was performed
 using custom MATLAB code. All statistical analyses were performed using R
 studio (version 2022.07.1, R version 4.0.2).
 Statistics and reproducibility
 Trajectory analysis was performed using custom MATLAB code. All
 statistical analyses were performed using R studio (version 2022.07.1, R
 version 4.0.2). The significance threshold was set at .05
 <em>Multimodal trajectories</em>
 We used a model-based approach with maximum likelihood to
 investigate circular orientation. The CircMLE package
 <sup>25</sup> was used to determine if our trajectories
 followed uniform, unimodal or multimodal model orientation (for further
 details see Fitak & Johnsen <sup>25</sup>). We first
 used the package circular <sup>44</sup> to obtain “circular”
 class data with angles in radians and modulo = π, as our data could spread
 only from 0 to 180°. We used the ‘check_data’ function from the CircMLE
 package to ensure our data were in the correct format and ran the
 ‘circ_mle’ function to test our orientation data including (a) first
 orientation data and (b) start to the end of the trajectory orientation
 data. The first orientation data followed model M5A (Homogenous bimodal)
 and the start-end orientation data followed M5B (Bimodal) models (see
 Supplementary Tables S2a and S2b for full details). This analysis
 indicates that multimodal orientation defines our data significantly
 better than uniform or unimodal. Grouping our data following navigational
 model trajectories can then be applied. We computed the circular mean
 direction <sup>44</sup> as a descriptive statistic and
 performed the following analyses on angles using ordinary statistics that
 are robust and powerful as our angles are restricted to 0-180° (after
 recommendation by Dr U J Lund, authors of the circular package
 <sup>44</sup>). <em>Deviation from
 the model trajectories</em> To measure the extent
 to which observed trajectories deviated from the three model trajectories
 (PI, AC and RR) prediction, we measured the average distance between both
 trajectories: We first cropped the smallest of either the model trajectory
 or the observed trajectory so that they were both of equal length. We then
 fitted the observed data using 1,000 evenly spaced points using a modified
 akima interpolation (makima, MATLAB) and did the same with the model
 trajectories. Finally, we calculated the Euclidian distance between each
 pair of interpolated points (i.e. distance between the tenth interpolated
 point in the trajectory from the tenth interpolated point in the model
 trajectory). Average distances between the observed and the model
 trajectories are presented in Table S2. All interpolated trajectories are
 presented in the supplementary material Figure S2.
 <em>Determination of the closest model
 trajectory</em> A generalised mixed linear model
 (GLMM) was used to test the similarity between observed trajectories and
 the three model trajectories. We used glmmTBM (glmmTBM package
 <sup>34</sup>), which fits models using maximum likelihood
 estimation via 'TMB' (Template Model Builder). For each fish,
 the distances between the 1,000 points interpolated along the observed
 trajectory and the 1,000 points interpolated model trajectories were added
 as the response variable. Model trajectory (i.e. PI, AC, RR) was added as
 the explanatory variable and as a random intercept. Distribution and
 dispersion of residuals were assessed using the DHARMa package
 <sup>35</sup>. No overdispersion of residuals was detected for
 any of the fish tested (p &gt; 0.05). A well-fitted statistical model
 predicts normality of the residuals and homoscedasticity, but this was
 rarely observed in our models. The lack of residual normality was due to
 both the large number of samples (n = 1000) and inclusion of “model” as a
 categorial fixed effect. A large number of samples often leads to
 statistical significance even if deviations are minor. The lack of
 homoscedasticity can be explained by the difference in shape of the three
 model trajectories: two trajectories (PI, AC) are straight, while the
 third (RR) includes a right angle. Therefore, if the fish trajectory
 closely follows PI or AC we can expect a significantly higher variance to
 the right-angle trajectory. While these issues prevent obtaining a perfect
 fit between the models and the data, the models we selected provided a
 better fit than alternatives, determined by comparison of 10 model
 structures using different GLMM packages, distributions and data
 transformations. Average distance ± SD between the observed fish
 trajectory and the model trajectories and Average distance ±
 IC<sub>95% </sub>are presented in the supplementary material
 Table S2 and Figure S3 respectively. For further details, see raw data and
 model output in R Code-Dryad depository.
 <em>Deviation from random trajectories</em>
 To determine whether an individual’s trajectory was closer to a
 random trajectory than to one of the three model trajectories (PI, AC,
 RR), we measured the distance between the observed trajectory and 10,000
 randomly generated trajectories. Each random trajectory was a straight
 line of a given length and angle and was generated using a custom MATLAB
 code. The angle, between 0 and 180 degree, was randomly-generated on the
 MATLAB code. The length and was the same as the smaller of either the
 individual’s trajectory or the PI model trajectory. We then measured the
 distance between the 1,000 interpolated points of the randomly generated
 trajectories and the 1,000 interpolated to the observed trajectory. We did
 this for 10,000 randomly generated trajectories. We then calculated the
 average distance between the observed trajectory and the 10,000 random
 trajectories. The distribution of the average distance between the
 observed trajectory and the 10,000 randomly generated trajectories was
 assessed using a Cullen and Frey graphic analysis from the “descdist”
 function (fitdistrplus package <sup>36</sup>, Rstudio version
 2022.12.0). It followed a continuous uniform distribution (See
 supplementary Figure S4).  If the difference between
 the observed trajectory and one of the model trajectories was less than
 the average distance minus SD<sub>uniform</sub> of all random
 trajectories, then the fish was assigned to the model trajectory category
 (Figure 5a). If the average distance minus
 SD<sub>uniform</sub> from all random trajectories was less
 than the distance between the fish trajectory and the model trajectories,
 then the fish was assigned to the random trajectory category (Figure 5c).
 If the standard deviation was calculated assuming a normal distribution
 for the 10,000 distances (see formula below), two fish trajectories (3L
 and 29L) would be assigned to a random trajectory instead of AC.
 Finally, using a 20% threshold on the cumulative distribution
 function of the 10,000 distances (Figure 5b, 5d) resulted in the same path
 categorisation as that obtained using the standard deviation calculated
 assuming a normal distribution. <em>
 </em> <em>Calculation of the fish First
 angle (first orientation when exiting the chamber) and Angle start-end
 (orientation from the first point out of the chamber to the end of the
 trajectory)</em> Each observed trajectory was
 made up x and y coordinate indicating the fish position and extracted
 every second from the time the individual excited the reward chamber. The
 trajectory was therefore divided into multiple segments between each
 coordinate points. The first direction taken by the fish was calculated as
 the angle of the first straight displacement (in degrees). The first
 straight displacement length was the addition of segments that does not
 deviate by more than 10 degrees from the previous segment. We took the
 coordinate of the first point out of the chamber and the coordinate from
 the point as the end of the first straight displacement and measure the
 angle of the first direction taken by the fish.  The
 angle start-end was calculated using the coordinates of the first point
 out of the chamber and the last point before the fish turn back toward the
 origin. <em>Comparison of model and observed
 angle swum</em> To test whether the direction
 taken by the fish when first exiting the chamber was significantly
 different from the model prediction, a one-way bootstrap t-test was used
 (number of bootstrap replicates = 9999). For each grouping (PI, AC or RR),
 the angle of the first straight displacement of the fish trajectories was
 tested against the expected model angle (PI: 45°; AC: 135° ; RR: 90°).
 Normality of the data was tested using a Shapiro test (PI group: W = 0.93,
 p-value = 0.51, AC<sub>lateral</sub> group W = 0.77, p-value =
 0.06, RR group W = 0.92, p-value = 0.55). We performed the same analysis
 to determine if the angle start-end of the fish trajectory was different
 from the expected model direction (normality test: PI group: W = 0.78,
 p-value = 0.02, AC<sub>lateral</sub> group W = 0.93, p-value =
 0.60, RR group W = 0.95, p-value = 0.72). The expected angle start-end of
 RR model was 45 degrees. When normality was not verified (PI group) we
 performed a signed-rank Wilcoxon test. Only two fish
 were found to adopt an AC strategy after diagonal displacement. The
 expected angle for those two fish was 180 degree. However, a sample of two
 individuals is insufficient for statistical analysis therefore the raw
 values only are reported in the results. To draw Figure
 2, we used circular statistics (package circular
 <sup>37</sup>). For each group, mean circular directions were
 calculated using the mean function on circular data (units = degrees). The
 uniformities of direction were assessed with a Rayleigh test. The length
 of the arrow on the figure indicate the strength of uniformity.
 <em>Comparison of model and observed distance
 travelled</em> A one-way t-test was used to test
 whether the first trajectory length was different from the expected model
 length. For each grouping (PI, AC or RR), the length of the fish
 trajectory was tested against the expected model length (PI: 38.6 cm; AC
 first vector: 38.6 cm; RR: 54.5 cm). Note that for this analysis the
 entire trajectory before orienting back to the origin was used, not the
 cropped trajectory used to group fish trajectories into different model
 types. Normality of the data was tested using a Shapiro test (PI: W =
 0.72, <em>p</em> = 0.003; AC: W = 0.76, <em>p</em>
 = 0.047; RR: W = 0.94, <em>p</em> = 0.67). Where normality was
 confirmed, a one-way bootstrap t-test (number of bootstrap replicates =
 9999) was used. Otherwise, a signed-rank Wilcoxon test was performed. Only
 two fish were found to adopt an AC strategy following diagonal
 displacement. The expected distance for those two fish was 27.3 cm.
 However, a sample of two individuals is insufficient for statistical
 analysis therefore the raw values only are reported.
 <em>Testing the effect of age, speed, trial number and
 displacement on chosen strategy.</em> To
 determine if individual age, swimming speed, trial number (first or second
 time in the experimental tank) and displacement direction (lateral versus
 diagonal) had an impact on the strategy chosen, we performed a multinomial
 mixed effects regression (“mblogit” function, mclogit package;
 <sup>38</sup>). Strategy (PI, AC, RR or random) was added as
 the multinomial response variable. Fish age, swimming speed, displacement
 direction and trial number were added as explanatory variables. Fish
 identity was added as a random intercept. No overdispersion was detected
 (dispersion function, mclogit package <sup>38</sup>). A
 posthoc analysis was performed using “emmeans” and “contrast” functions
 with Holm Bonferroni adjustment (emmeans package
 <sup>39</sup>) it allowed to evaluate the effect of the
 explanatory variables on paired response variable (i.e. probability to
 follow a strategy rather than another: PI vs AC, PI vs RR, AC vs
 random…).
description: # Taking a shortcut: What mechanisms do fish use? Please find below all
 descriptions of data files and code used for the manuscript: Taking a
 shortcut: what mechanisms do fish use? , by Sibeaux et al. 2024 To better
 understand the data analyses and processing we have organised this file
 into 5 subsections: 1-Matlab trajectory analysis 2-Distance Analysis with
 R 3-Distance to Random 4-Comparison fish versus model angle and distance
 5-intrinsic and extrinsic effects on model chosen 6--Extra analyses asked
 by reviewers Some files are reused among subsections --- ## 1-Matlab
 trajectory analysis Please find below the description of the MATLAB code
 used for the analysis of the fish trajectories and the associated data
 files. 1\_ "PathIntegrationVideoTracker.m" MATLAB file produced
 by C.N. to track the fish in the experimental apparatus and extract the x
 and y coordinates of the fish 2\_ "PathAnalysisCropingtoSize.m"
 MATLAB file (by A.S.) allows to crop the fish trajectory and the model
 trajectories to the same size. The MATLAB file then implements 1000 points
 along the fish trajectory and the model trajectories. It requires the .csv
 files: "Model.csv" and
 "PathUntilDirectionBackToOrigine.csv" that gives the coordinates
 of the fish and of the 3 model trajectories. The output of this program
 can be found in "1000CoordinateData.csv" and
 "distanceData.csv" output files. 3\_
 "PathAnalysisForDDisplacementH2.m" Similarly to the file 2, this
 MATLAB file (by A.S.) allows to crop the fish trajectory and the model
 trajectory to the same size but only focussed on the H2D trajectory = APC
 trajectory after diagonal displacement. The output is the
 "distanceDataH2DDisplacement.csv" --- 4\_ "Model.csv"
 : gives the x and y coordinates of the 3 model trajectories (h1 refers to
 PI; h2 to APC and h3 to RR navigational strategies). The chamber origin
 point possess the coordinate(0;0). Model: the three model strategies (H1,
 H2 or H3) XcoordinatefromOrigine: X coordinate of the model strategy
 YcoordinatefromOrigine: Y coordinate of the model strategy
 lengthfromOrigine : length of the straight line from the origin of the
 model strategy (in pixels) lengthSegment: length of each segment (in
 pixels) cumulatedLength: cumulated length of the model strategy (in
 pixels) --- 5\_ "PathUntilDirectionBackToOrigine.csv" : All
 information about the fish movement until the fish orient back toward the
 origin. The coordinate were taken every second. NaN indicates that the
 data is not available for the concerned cell. FishID: fish identification
 TrialD/L : 1 if the displacement was diagonal, Lateral if the displacement
 was Lateral FrameNumber: video frame number when the coordinate was
 extracted (please note that some videos were recorded at a frame rate of
 30 fps and other at 20 fps) X_coord: x coordinate of the fish in the
 experimental apparatus Y_coord: y coordinate of the fish in the
 experimental apparatus displacement: whether the fish experienced diagonal
 (D) or lateral (L) displacement time: time in seconds total time: total
 time of the trajectory before the fish orientate back toward the origin
 (reward chamber) in seconds video fps: the video frame rate in frame per
 second LengthSegment (pixel): Length of the segment in pixels
 cumulatedLenghtPath(pixel): cumulated length of the fish trajectory in
 pixels total length segment(pixel): actually the length of the entire fish
 trajectory until back to the origin in pixels XcoordinatefromOrigine: x
 coordinate of the fish recentered on his first coordinate out (0)
 YcoordinatefromOrigine: y coordinate of the fish recentered on his first
 coordinate out (0) Distance from origine: straight distance from the
 origin in pixels Xend: last fish x coordinate in the experimental
 apparatus Yend: last fish y coordinate in the experimental apparatus
 AngleSegment360degrees: the angle of the trajectory segment
 AngleFromOrigine360: the angle from the point of origin
 Cumulated360Angles: cumulative angles along the fish trajectory Angle-10:
 angle of the fish + ten degrees (to calculate deviation &gt; 10 degrees
 between 2 consecutive segments) Angle+10: angle of the fish - ten degrees
 (to calculate deviation &gt; 10 degrees between 2 consecutive segments)
 stopSup: stop if 2 consecutive angles deviate more than 10 degrees above
 the first angle, straight if 2 consecutive angles do not deviate more than
 10 degrees **above** the first angle stopInf: stop if 2 consecutive angles
 deviate more than 10 degrees below the first angle, straight if 2
 consecutive angles do not deviate more than 10 degrees **below** the first
 angle straightPath:stop if 2 consecutive angles deviate more than 10
 degrees, straight if 2 consecutive angles do not deviate more than 10
 degrees xv: x velocity (in pixels/sec) yv: y velocity (in pixels/sec)
 FishDirectionBackToOrigine: yes if the fish orientate back toward the
 origine Yt&gt;Yt+1 FirstOrSecondTimeDisplacedInExpTank: first or second
 time the fish was in the experimental apparatus FishDisplacement: combine
 fish ID and displacement Angle first straight path: angle of the first
 straight path of the fish (before 10-degree deviation) AngleStartEnd:
 angle between the start and the end of the fish trajectory --- ## Output
 files: 6\_ "1000CoordinateData.csv" : gives the coordinates of
 the 1000 extrapolated points along the model and fish trajectories fishID:
 fish identity xH1: 1000 extrapolated x coordinate for the PI model
 trajectory yH1: 1000 extrapolated y coordinate for the PI model trajectory
 xH2: 1000 extrapolated x coordinate for the APC model trajectory yH2: 1000
 extrapolated y coordinate for the APC model trajectory xH3: 1000
 extrapolated x coordinate for the RR model trajectory yH3: 1000
 extrapolated y coordinate for the RR model trajectory xFishH1H2: 1000
 extrapolated x coordinate for the fish trajectory matching the length of
 PI or APC-lateral- trajectories yFishH1H2: 1000 extrapolated y coordinate
 for the fish trajectory matching the length of PI or APC-lateral-
 trajectories xFishH3: 1000 extrapolated x coordinate for the fish
 trajectory matching the length of RR trajectories yFishH3: 1000
 extrapolated y coordinate for the fish trajectory matching the length of
 RR trajectories --- 7\_ "distanceData.csv": gives 1000 distances
 between the interpolated points of the fish trajectory and the
 interpolated points of the 3 model trajectories. fishID: fish identity
 distanceH1 : distance to PI model trajectory in pixels distanceH2 :
 distance to AC model trajectory in pixels distanceH3 : distance to RR
 model trajectory in pixels --- 8\_
 "distanceDataH2DDisplacement.csv": gives 1000 distances between
 the interpolated points of the fish trajectory and the interpolated points
 of H2D model trajectory. fishID: fish identity distanceH2 : distance to AC
 model trajectory after diagonal displacement in pixels --- 9\_
 "DistanceDataAnalysisForR.csv": Combine the 7 and 8 .csv files.
 This.csv file containing the distances between the 1000 interpolated
 points along the fish trajectory and the 1000 interpolated along the model
 trajectories. fishID: fish identity distanceH1 : distance to PI model
 trajectory in pixels distanceH2L : distance to AC model trajectory after
 lateral displacement ("NA" when the fish follow diagonal
 displacement) in pixels. NAs are present for the fish following a diagonal
 displacement. distanceH3 : distance to RR model trajectory in pixels
 Displacement : displacement in the experimental apparatus, D=diagonal,
 L=laterak fishID2: fish identity (=fishID) distanceH2D : distance to AC
 model trajectory after diagonal displacement ("NA" when the fish
 follow lateral displacement) in pixels. NAs are present for the fish
 following a lateral displacement. --- ## 2-Distance Analysis with R Please
 find below the description of the R code used for the analysis of the fish
 trajectories model trajectories distances and the associated data files.
 9\_ "DistanceDataAnalysisForR.csv": .csv file containing the
 distances between the 1000 interpolated points along the fish trajectory
 and the 1000 interpolated along the model trajectories. fishID: fish
 identity distanceH1 : distance to PI model trajectory in pixels
 distanceH2L : distance to AC model trajectory after lateral displacement
 ("NA" when the fish follow diagonal displacement) in pixels. NAs
 are present for the fish following a diagonal displacement. distanceH3 :
 distance to RR model trajectory in pixels Displacement : displacement in
 the experimental apparatus, D=diagonal, L=laterak fishID2: fish identity
 (=fishID) distanceH2D : distance to AC model trajectory after diagonal
 displacement ("NA" when the fish follow lateral displacement) in
 pixels. NAs are present for the fish following a lateral displacement.
 10\_ "DistanceAnalysisR.R": This is the R code used to run the
 statistical analysis to determine if the distances between the fish
 trajectory and each of the model trajectories were significantly
 different. This code also allows to generate the figure S3 --- ##
 3-Distance to Random Please find below the description of the MATLAB code,
 R code and associated .csv code used to determine if the fish trajectory
 was random or followed one of the model trajectory. 11\_
 "permutation.mat": MATLAB code used to generate 10 000 random
 model trajectories and calculate the distance between the fish trajectory
 and the each of the 10 000 randomly generated trajectories. Gives output
 files "permutationData10000Random1D-29D.csv" and
 "permutationData10000Random29L-end.csv" 12\_
 "permutationData10000Random1D-29D.csv" and
 "permutationData10000Random29L-end.csv" : These data files
 contains the 10000 mean distances between the fish trajectory and the
 10000 random trajectories in pixels. fishID: fish identity
 distanceRandomFish: average distance between the fish and the random model
 trajectory in pixels AngleofRandomTrajectory: The angle of the random
 trajectory 13\_ "StatDistance-Model-Random.R" : the R code file
 containing the analysis of the distance between the fish trajectory and
 the random trajectories versus the three model trajectories. Gives also
 the code for the Figure 4 and the Figure S4 of the paper --- ##
 4-Comparison fish versus model angle and distance Please find below the
 description of the R code used for the analysis of the trajectory expected
 angle and the fish observed angle along with the associated data files.
 The MATLAB code is used to generate the figure 3. --- 14\_
 "AngleDistanceStats.R" : R code and statistical analysis testing
 the differences between the angle and distances expected by the model and
 observed (gives the output presented in table 2). Allows also to generate
 figure 2. Require: "PathUntilDirectionBackToOrigine.csv",
 "FishGroup.csv", "Path integration data.csv" --- 15\_
 "FishGroup.csv" : Fish are grouped under one of the three model
 trajectories or Random trajectory. FishDisplacement: Fish identity
 (association of fish ID and the displacement of the fish for the trial).
 RandomPermutationAndSDUniform: Fish identified trajectory (H1=PI model
 trajectory, H2D= APC after diagonal displacement, H2L= APC after lateral
 displacement, H3= Route Recapitulation, Random=Random). The fish was
 assigned to one of the model trajectories or random by checking if the
 average distance between each fish and the model trajectories were smaller
 than the average distance to 10000 randomly generated model trajectories
 -SD uniform. --- 16\_ "Path integration data.csv" : dataset
 containing information about the experimental trial for each fish. NAs
 indicate that the data is not available for a given cell (the fish did not
 enter the tunnel or the trapping chamber). date: date of the trial fish
 ID: fish identity displacement: the displacement in the experimental
 apparatus (lateral or diagonal) population: the fish population Age: age
 of the fish tested (in years) timeINAcclimation(previousday): time of
 acclimation for the fish- acclimation was over night so the day before the
 experiment (over 24 hours) temperatureAcclimation: temperature in the
 experimental apparatus when the fish was placed in for acclimation (in
 degree celsius) TimeDoorOpen : Time at which the door of the reward
 chamber was open so the fish could travel through the tunnel to receive a
 food reward. TemperatureExpDay: Temperature in the experimental apparatus
 before to start the experiment (in degree celsius) FirstTimeInTunnel: The
 first time the fish entered the tunnel beforeEnteringTunnel(min): latency
 before the fish entered the tunnel for the first time (in minutes)
 GoInTunnelFirstBranch: number of time the fish entered the first branch of
 the tunnel GoInTunnelsecondBranch: number of time the fish entered the
 second branch of the tunnel (branch from which the food reward was
 visible- and leading to it by a straight path) TimeInChamber: Time when
 the fish entered the reward chamber timeBeforeToEnterChamber(min): latency
 before the fish entered the reward chamber in minutes
 LatencyDisplacement(min.sec): time between the door closing (once the fish
 entered the reward chamber) and the door openning (after displacement of
 the chamber, removing all the landmark cues and stirring the sand) in
 minutes:secondes timeBeforeEnteringChamber(in h:min): latency before the
 fish entered the reward chamber in hour:minutes test: first or second time
 in the experimental apparatus FishDisplacement: Fish identity linked with
 the displacement in the experimental apparatus. --- 5\_
 "PathUntilDirectionBackToOrigine.csv" : All information about
 the fish movement until the fish orient back toward the origin. The
 coordinate were taken every second. NaN indicates that the data is not
 available for the concerned cell. FishID: fish identification TrialD/L : 1
 if the displacement was diagonal, Lateral if the displacement was Lateral
 FrameNumber: video frame number when the coordinate was extracted (please
 note that some videos were recorded at a frame rate of 30 fps and other at
 20 fps) X_coord: x coordinate of the fish in the experimental apparatus
 Y_coord: y coordinate of the fish in the experimental apparatus
 displacement: whether the fish experienced diagonal (D) or lateral (L)
 displacement time: time in seconds total time: total time of the
 trajectory before the fish orientate back toward the origin (reward
 chamber) in seconds video fps: the video frame rate in frame per second
 LengthSegment (pixel): Length of the segment in pixels
 cumulatedLenghtPath(pixel): cumulated length of the fish trajectory in
 pixels total length segment(pixel): actually the length of the entire fish
 trajectory until back to the origin in pixels XcoordinatefromOrigine: x
 coordinate of the fish recentered on his first coordinate out (0)
 YcoordinatefromOrigine: y coordinate of the fish recentered on his first
 coordinate out (0) Distance from origine: straight distance from the
 origin in pixels Xend: last fish x coordinate in the experimental
 apparatus Yend: last fish y coordinate in the experimental apparatus
 AngleSegment360degrees: the angle of the trajectory segment
 AngleFromOrigine360: the angle from the point of origin
 Cumulated360Angles: cumulative angles along the fish trajectory Angle-10:
 angle of the fish + ten degrees (to calculate deviation &gt; 10 degrees
 between 2 consecutive segments) Angle+10: angle of the fish - ten degrees
 (to calculate deviation &gt; 10 degrees between 2 consecutive segments)
 stopSup: stop if 2 consecutive angles deviate more than 10 degrees above
 the first angle, straight if 2 consecutive angles do not deviate more than
 10 degrees **above** the first angle stopInf: stop if 2 consecutive angles
 deviate more than 10 degrees below the first angle, straight if 2
 consecutive angles do not deviate more than 10 degrees **below** the first
 angle straightPath:stop if 2 consecutive angles deviate more than 10
 degrees, straight if 2 consecutive angles do not deviate more than 10
 degrees xv: x velocity (in pixels/sec) yv: y velocity (in pixels/sec)
 FishDirectionBackToOrigine: yes if the fish orientate back toward the
 origine Yt&gt;Yt+1 FirstOrSecondTimeDisplacedInExpTank: first or second
 time the fish was in the experimental apparatus FishDisplacement: combine
 fish ID and displacement Angle first straight path: angle of the first
 straight path of the fish (before 10-degree deviation) AngleStartEnd:
 angle between the start and the end of the fish trajectory --- 17\_
 "PlotTrajectoriesForPaper.m" : MATLAB code allowing to generate
 the figure 3 presented in the paper. Requires the .csv files:
 "Models.csv", "FishGroup.csv" and
 "PathUntilDirectionBackToOrigine.csv" already described. --- ##
 5-intrinsic and extrinsic effect on model choosen Please find below the
 description of the R code used to test the effect of the intrinsic and
 extrinsic factors on the fish propensity to choose one or the other model
 trajectory. --- 18\_ "statPopAgeSpeed.R" : R code and
 statistical analysis testing the effect of fish age, fish swimming speed,
 displacement in the experimental apparatus and trial number on the fish
 propensity to choose one of the model trajectory. Require:
 "PathUntilDirectionBackToOrigine.csv",
 "FishGroup.csv", "Path integration data.csv" files
 already described --- 5\_ "PathUntilDirectionBackToOrigine.csv"
 : All information about the fish movement until the fish orient back
 toward the origin. The coordinate were taken every second. NaNs indicate
 that the data is not available for the concerned cell. FishID: fish
 identification TrialD/L : 1 if the displacement was diagonal, Lateral if
 the displacement was Lateral FrameNumber: video frame number when the
 coordinate was extracted (please note that some videos were recorded at a
 frame rate of 30 fps and other at 20 fps) X_coord: x coordinate of the
 fish in the experimental apparatus Y_coord: y coordinate of the fish in
 the experimental apparatus displacement: whether the fish experienced
 diagonal (D) or lateral (L) displacement time: time in seconds total time:
 total time of the trajectory before the fish orientate back toward the
 origin (reward chamber) in seconds video fps: the video frame rate in
 frame per second LengthSegment (pixel): Length of the segment in pixels
 cumulatedLenghtPath(pixel): cumulated length of the fish trajectory in
 pixels total length segment(pixel): actually the length of the entire fish
 trajectory until back to the origin in pixels XcoordinatefromOrigine: x
 coordinate of the fish recentered on his first coordinate out (0)
 YcoordinatefromOrigine: y coordinate of the fish recentered on his first
 coordinate out (0) Distance from origine: straight distance from the
 origin in pixels Xend: last fish x coordinate in the experimental
 apparatus Yend: last fish y coordinate in the experimental apparatus
 AngleSegment360degrees: the angle of the trajectory segment
 AngleFromOrigine360: the angle from the point of origin
 Cumulated360Angles: cumulative angles along the fish trajectory Angle-10:
 angle of the fish + ten degrees (to calculate deviation &gt; 10 degrees
 between 2 consecutive segments) Angle+10: angle of the fish - ten degrees
 (to calculate deviation &gt; 10 degrees between 2 consecutive segments)
 stopSup: stop if 2 consecutive angles deviate more than 10 degrees above
 the first angle, straight if 2 consecutive angles do not deviate more than
 10 degrees **above** the first angle stopInf: stop if 2 consecutive angles
 deviate more than 10 degrees below the first angle, straight if 2
 consecutive angles do not deviate more than 10 degrees **below** the first
 angle straightPath:stop if 2 consecutive angles deviate more than 10
 degrees, straight if 2 consecutive angles do not deviate more than 10
 degrees xv: x velocity (in pixels/sec) yv: y velocity (in pixels/sec)
 FishDirectionBackToOrigine: yes if the fish orientate back toward the
 origine Yt&gt;Yt+1 FirstOrSecondTimeDisplacedInExpTank: first or second
 time the fish was in the experimental apparatus FishDisplacement: combine
 fish ID and displacement Angle first straight path: angle of the first
 straight path of the fish (before 10-degree deviation) AngleStartEnd:
 angle between the start and the end of the fish trajectory --- 15\_
 "FishGroup.csv" : Fish are grouped under one of the three model
 trajectories or Random trajectory. FishDisplacement: Fish identity
 (association of fish ID and the displacement of the fish for the trial).
 RandomPermutationAndSDUniform: Fish identified trajectory (H1=PI model
 trajectory, H2D= APC after diagonal displacement, H2L= APC after lateral
 displacement, H3= Route Recapitulation, Random=Random). The fish was
 assigned to one of the model trajectories or random by checking if the
 average distance between each fish and the model trajectories were smaller
 than the average distance to 10000 randomly generated model trajectories
 -SD uniform. --- 16\_ "Path integration data.csv" : dataset
 containing information about the experimental trial for each fish. NAs
 indicate that the data is not available for a given cell (the fish did not
 enter the tunnel or the trapping chamber). date: date of the trial fish
 ID: fish identity displacement: the displacement in the experimental
 apparatus (lateral or diagonal) population: the fish population Age: age
 of the fish tested (in years) timeINAcclimation(previousday): time of
 acclimation for the fish- acclimation was over night so the day before the
 experiment (over 24 hours) temperatureAcclimation: temperature in the
 experimental apparatus when the fish was placed in for acclimation (in
 degree celsius) TimeDoorOpen : Time at which the door of the reward
 chamber was open so the fish could travel through the tunnel to receive a
 food reward. TemperatureExpDay: Temperature in the experimental apparatus
 before to start the experiment (in degree celsius) FirstTimeInTunnel: The
 first time the fish entered the tunnel beforeEnteringTunnel(min): latency
 before the fish entered the tunnel for the first time (in minutes)
 GoInTunnelFirstBranch: number of time the fish entered the first branch of
 the tunnel GoInTunnelsecondBranch: number of time the fish entered the
 second branch of the tunnel (branch from which the food reward was
 visible- and leading to it by a straight path) TimeInChamber: Time when
 the fish entered the reward chamber timeBeforeToEnterChamber(min): latency
 before the fish entered the reward chamber in minutes
 LatencyDisplacement(min.sec): time between the door closing (once the fish
 entered the reward chamber) and the door openning (after displacement of
 the chamber, removing all the landmark cues and stirring the sand) in
 minutes:secondes timeBeforeEnteringChamber(in h:min): latency before the
 fish entered the reward chamber in hour:minutes test: first or second time
 in the experimental apparatus FishDisplacement: Fish identity linked with
 the displacement in the experimental apparatus. --- ## 6-Extra Analyses
 asked by reviewers 19\_ "CircMLEandExtraAnalyses.R" : R code and
 statistical analysis to answer multiple reviewers comments. (1) use
 model-based approaches with maximum likelihood to determine if the fish
 follow uniform, unimodal or multimodal distribution. (2) test path length
 and straightness and compare it between groups. (3) plot distance to
 cut-off point. (4)Test homogeneity of means with Circular statistics.
 Require: "PathUntilDirectionBackToOrigine.csv",
 "FishGroup.csv", "Path integration data.csv" files
 already described