Achieving functional neuronal dendrite structure through sequential stochastic growth and retraction

Class I ventral posterior dendritic arborisation (c1vpda) proprioceptive sensory neurons respond to contractions in the Drosophila larval body wall during crawling. Their dendritic branches run along the direction of contraction, possibly a functional requirement to maximise membrane curvature during crawling contractions. Although the molecular machinery of dendritic patterning in c1vpda has been extensively studied, the process leading to the precise elaboration of their comb-like shapes remains elusive. Here, to link dendrite shape with its proprioceptive role, we performed long-term, non-invasive, in vivo time-lapse imaging of c1vpda embryonic and larval morphogenesis to reveal a sequence of differentiation stages. We combined computer models and dendritic branch dynamics tracking to propose that distinct sequential phases of stochastic growth and retraction achieve efficient dendritic trees both in terms of wire and function. Our study shows how dendrite growth balances structure–function requirements, shedding new light on general principles of self-organisation in functionally specialised dendrites.


15
A fundamental open question in neuroscience is understanding how the shape of specific 16 neuron classes arises during cell development to perform distinct computations (Carr et al.,17 2006). In the past, technological and conceptual advances have allowed exciting discoveries on 18 how the coupling of class type-specific dendrite geometry with various ion channels provide 19 the substrate for signal processing and integration in dendrites (Mainen and Sejnowski, 1996;20 van Elburg and van Ooyen, 2010; Gabbiani   However, to date, these efforts have fallen short of clarifying the link between the devel-27 opmental elaboration of dendrite structure and the structural constrains dictated by the 28 computational tasks of the neuron (Lefebvre et al., 2015). Unravelling these patterning pro-29 cesses is important to achieve a mechanistic understanding of the nervous system and to 30 3/57 gather insights into neurological and neurodevelopmental disorders alike (Copf, 2016  In particular, the dendrites of the ventral posterior c1da neuron (c1vpda) exhibit an unmis-59 takable stereotypical comb-like shape with a main branch (MB) running perpendicularly to 60 the anteroposterior direction of contraction and lateral branches typically running parallel 61 to the direction of contraction. As the peristaltic muscle contraction wave progresses along 62 4/57 the anteroposterior axis during crawling lateral branches bend, while the MB remains almost 63 unaffected. The different deformation profiles likely arise from the distinct orientation of the 64 branches. (Vaadia et al., 2019). 65 Dendrite morphology, dendrite activation pattern and function of c1vpda neurons are known. 66 These sensory neurons thus provide an ideal platform to address how dendrite structure 67 is optimised towards the neuron's appropriate functional response and such an optimised 68 structure is achieved. Do dendrites form through an intrinsic deterministic program or are 69 they shaped by stochastic processes? Moreover, do these functional requirements coexist with 70 optimal wire constraints, i.e, minimisation of dendrite cable material costs, observed in many 71 neuronal dendrites (Cuntz et al., 2007;Wen and Chklovskii, 2008)? In this work, we used the 72 c1vpda neuron to address precisely these key questions. We reasoned that by elucidating 73 the spatiotemporal differentiation of the cell we could further our understanding of how 74 functionally constrained morphologies emerge during development. In previous studies, 75 analysis of the underlying developmental trajectories of distinct cell types provided important 76 insights into how neurons (Miller, 1981;Lim et al., 2018) and circuits (Langen et al., 2015) 77 pattern into functional structures. 78 We therefore combined long-term time-lapse imaging of dendrite development, quantitative 79 analysis, theoretical modelling, calcium imaging in freely moving animals, and in silico 80 morphological modelling to describe the spatiotemporal patterning of c1vpda dendrites. We 81 find that dendrite growth can to a large degree be described by a random growth process that 82 satisfies optimal wire and a randomised retraction of branches that preferentially preserves 83 functional dendrites.

85
Embryonic and larval differentiation of c1vpda dendrites 86 To better understand the relationship between dendrite structure and function in c1vpda 87 sensory neurons, we dissected the developmental process of apical dendrite formation quanti-88 tatively using long-term, non-invasive time-lapse imaging from embryonic stages (16hrs after 89 egg laying AEL) until early 3 rd larval stage (72hrs AEL) (Figure 1). 90  A, Imaging procedure throughout embryonic (E) stages. The eggs were imaged at higher temporal resolution in a time window ranging from 16−24hrsAEL. Sketch (top row left) illustrating the experimental conditions, drawing (top row right) depicting the ordering of c1vpda branches (black: MB order 1, blue: lateral branch order 2, orange: lateral branch order > 2). Timeline and maximum intensity projections (middle row) of image stacks as well as reconstructions (bottom row) of a given representative c1vpda dendrite. White arrows in images and corresponding black arrows on reconstructions indicate exemplary changes between the time points (see main text). B, Subsequent imaging of Larval instar (L) 1, 2, 3 stages with similar arrangements as in A. Times shown are AEL (after egg laying).

5/57
To visualise cell morphology we expressed a membrane-tagged fluorescent protein specifically 91 6/57 in c1vpda neurons. Within the egg (Figure 1A), the main branch (MB) emerged from the 92 soma at around 16hrs AEL and extended in a dorsal orientation. Afterwards, a number of 93 second-order lateral interstitial branches appeared from the initial MB extending in both 94 the anterior and posterior directions, with the MB dorsal position potentially biasing their 95 growth direction along the anteroposterior axis (Yoong et al., 2019). Then, shorter third-order 96 lateral branches sprouted interstitially from the second-order lateral branches mainly along 97 the dorsoventral axis. Lateral branches underwent repeated cycles of extension and retraction 98 until reaching a maximum number of branches around 18.5 − 19hrs AEL. Even at this stage 99 few fourth or fifth-order lateral branches were observed.

100
The c1vpda sensory neuron then entered a stage of arbour reorganisation, marked predom-101 inantly by the retraction of branch tips ( Figure 1A, 18.5hrs and 19.5hrs). This phase of 102 removal of dendritic branches, hereafter referred as the retraction phase, was followed by a 103 pre-hatching stabilisation period ( Figure 1A). During hatching, larvae showed severe head 104 swings and anteroposterior contractions, followed by body swirls inside the egg preventing 105 the collection of images in this period.

106
After hatching (24hrs AEL), we imaged dendrite development at the time points of 30hrs, 107 50hrs and 72hrs AEL ( Figure 1B). The neurons continued growing concomitantly with the 108 expansion of the body wall. However, the post-embryonic growth phase preserved the shape 109 and complexity of c1vpda dendrites, with only very few new branches emerging. The increase 110 of dendrite cable was due primarily to the scaling elongation of existing branches. The 111 dendritic pattern observed at 30hrs AEL was fundamentally the same as the one observed at 112 72hrs AEL, consistent with an isometric scaling of da sensory neurons during larval stages 113 (Parrish et al., 2009).

114
To gain a quantitative insight into the morphological maturation process of these sensory 115 neurons, we reconstructed the dendrites in the image stacks obtained from the time-lapse 116 imaging and we measured their structure using 49 distinct morphometrics (see Methods). 117 Using a t-distributed Stochastic Neighbour Embedding (tSNE) (van der Maaten, 2008) of the 118 entire dataset we reduced the 49−dimensional space to a 2D plot preserving neighbourhood 119 relationships that indicate morphological similarity (Figure 2A). After examining the tSNE 120 plot, it is evident that developmental time was a strong source of variation in the data with 121 neurons becoming increasingly morphologically divergent over time. Cells from early stages 122 formed large continuums in the tSNE plot, whereas darker green discrete clusters emerged 123 7/57  we compared the relationships of these morphometrics across the different developmental 132 phases ( Figure S1). During the initial extension phase, new branches were added with a 133 linear increase with total length (R 2 = 0.86) and surface area alike (R 2 = 0.73; Figure S1A). 134 Accordingly, the dendrite cable length also increased linearly with the available spanning area 135 (R 2 = 0.92; Figure S1A). 136 Throughout the retraction phase, the dendrite cable length decreased linearly with the reduc-137 tion of branches (R 2 = 0.77; Figure S1B). However, the retraction of branches only slightly 138 affected the surface area of the cell (R 2 = 0.21), neither did the reduction of dendrite cable 139 (R 2 = 0.41; Figure S1B). This suggests that shorter, proximally located, higher-order lateral 140 branches (third order or higher) were the ones most strongly involved in retraction (see also 141 Figure 1A, arrows). These branches, due to their location in the inner part of the dendritic 142 field had only a small influence in defining the spanning area of the c1vpda dendrites.

143
In the subsequent stabilisation phase, virtually no new branches were added despite of 144 the small increase of the total length (R 2 = 0.33) and surface area (R 2 = 0.27; Figure S1C). 145 Dendrite cable length slightly increased linearly with the available spanning area (R 2 = 0.74; 146 Figure S1C), but at a lower rate than during the initial extension phase.

147
Finally, only very few new branches emerged during the stretching phase from c1vpda 148 dendrites regardless of the increase of dendrite cable (R 2 = 0.17), or new available surface area 149 (R 2 = 0.1; Figure S1D). Dendrite cable length increased linearly with the available spanning 150 area (R 2 = 0.97; Figure S1D). A, A t-distributed stochastic neighbour embedding (tSNE) plot showing the entire dataset of neuronal reconstructions using a 49−dimensional morphometric characterisation reduced to two dimensions. B, Time course of the number of branch points during development (see also Figure 6C). C, Time courses of the total length of dendrite cable (left) and square root of the surface area (right) during development (see also Figure 6C). D, Scaling behaviour of the square root of the surface area against total length (left) and total length against number of branch points (right) showing the relationships expected from the optimal wire equations (Cuntz et al., 2012;Baltruschat et al., 2020). The dashed line shows the average scaling behaviour of simulated synthetic trees (n = 1, 000 simulations; see Methods). In all panels, each dot represents one reconstruction with the colour scheme indicating imaging time AEL roughly dissecting embryonic (red) and larval (green) developmental stages (colour bar in A). The thick yellow arrows show trajectories averaging values of all reconstructions across two hour bins in A, and 1 hour bins in B and C for higher resolution. Data from n = 165 reconstructions, n = 48 neurons, n = 13 animals. See also Figure S1 for details on the scaling in the different stages of development.
Comparing the relationships between basic geometric features of tree structures has previ-152 ously allowed linking dendritic architecture with wire saving algorithms (Cuntz et al., 2012;153 Baltruschat et al., 2020). For planar dendrites that minimise wire, a scaling law relating branch 154 points (N ), total length (L) and surface area of the spanning field (S) was formerly derived 155 (Cuntz et al., 2012): Thus, as a first step to assess if c1vpda sensory neurons saved wire during development we 157 verified if their dendrites obeyed the expected geometrical square root scaling relationship. 158 As predicted by the aforementioned equation, a square root relation between dendrite length 159 L and surface area S, and a square root relation between total length L and number of branch 160 points N were found at each developmental time point ( Figure 2D; see Methods). In the 161 scaling plot of the length L and surface area S, the slight offset between the light green and 162 red dots marks the stage transition between embryonic growth and the subsequent isometric 163 stretching observed during instar stages.

164
To further test the wire minimisation properties of c1vpda neurons we compared the scaling 165 relations of synthetic dendritic morphologies against real data (see Methods). Synthetic trees 166 were generated using a formerly described minimum spanning tree (MST) based algorithm 167 and were simulated to match the morphometrics of the real neurons (Cuntz et al., 2008(Cuntz et al., , 2010. 168 To facilitate comparing the total length and number of branch points of the datasets, artificial 169 and real morphologies were normalised to a standard arbitrary surface area of 100µm 2 . As 170 a result, we could then show that the square root of the number of branch points √ N and 171 total length L of the synthetic trees scaled linearly with each other, with the experimental data 172 being well fitted by the synthetic data (R 2 = 0.98, Figure 2D).

173
Taken together, the results indicate that throughout morphological differentiation during 174 development, c1vpda sensory neurons respect minimum wire constraints. This suggests that 175 while functional requirements for dendritic morphology here may shape the dendrites, these 176 must also respect wire optimisation constraints. A, Sketch illustrating lateral branch orientation angle and dendrite morphology of a sample c1vpda sensory neuron before retraction. Morphology on the left side is colour coded by branch segment angles and morphology on the right is colour coded by branch length order (MB is coloured in black; see Methods). On the right, histograms for branch length (one dot per branch) and number of branches per angle are shown separated by branch length order (blue: order 2, orange: order > 2, n = 429 branches). B, Similar visualisation but for dendrites after retraction (n = 223 branches).
We therefore investigated the effects of the retraction phase on the spatial distribution of 187 lateral branches, measuring their orientation before and after retraction. Imaging the immobile 188 embryo did not enable us to directly measure the branch orientation of the imaged cells in 189 11/57 relation to the direction of the body wall contraction during crawling. Therefore, we took 190 advantage of the stereotypical c1vpda structure and location in the body of the larva and 191 defined the MB as perpendicular to the direction of contraction. We then measured the angle 192 of a given lateral branch in relation to the MB as a proxy for the direction of contraction 193 ( Figure S2, see Methods). The orientation angle varied between 90 • for a lateral branch 194 aligned along the anteroposterior axis, e.g. some second-order lateral branches, to 0 • for a 195 branch extending in the dorsoventral axis, e.g. the MB (Figure 3A). The angles were measured 196 separately in the longer second-order lateral branches emanating directly from the MB (order 197 2, blue branches) and in higher-order lateral branches which branch out from the second-order 198 lateral branches (order > 2, orange branches).  A, (Top) Mean normalised Ca 2+ responses of c1vpda dendrites during forward crawling. The signal was calculated as the fold change of the signal R = F GCaM P 6m F tdT omato in the fluorescence ratio ∆R R 0 (see Methods and Figure S3). ∆R R 0 signal amplitude was normalised for each trial. Data from 6 animals, n = 25 neurons; solid pink line shows average values where data comes from n > 5 neurons and dashed pink line where n < 5 neurons. Standard error of the mean in pink shaded area. (Bottom) Average normalised contraction rate during crawling behaviour (similar plot as in top panel but in black colour). Segment contraction and Ca 2+ responses were aligned to maximal segment contraction at t = 0s. B, (Top row) Simulated contraction of a c1vpda morphology by wrapping around a cylinder. (Main panel) Relationship between normalised curvature increase experienced by a single branch as a function of its orientation angle θ. C, C1vpda dendrite morphologies before (left) and after (right) retraction. Morphologies are colour coded by local curvature increase during segment contraction. D, Similar visualisation of the same data as in Figure 3 but for curvature increase before and after retraction. Rightmost panel additionally shows the distribution (%) of retracted branches by bending curvature increase (red shaded area). activation, we measured dendritic Ca 2+ responses in freely forward moving larvae following 225 branch deformation due to body wall contraction ( Figure 4A, see Methods and Figure S3). 226 We generated a fly line in which c1vpda neurons specifically express tdTomato (red) as a 227 fluorescent marker to visualise the dendrites and at the same time also GFCaMP6m (green) to 228 report changes in cytoplasmic Ca 2+  prominent Ca 2+ signals in the dendrites. 238 We then modelled c1vpda membrane curvature, to simulate the effects of morphological 239 alterations in the lateral branches due to cuticle folding during segment contraction. We 240 designed a geometrical model of tubular structure bending, to measure the relative curvature 241 increase of a given branch from resting state to the point of maximum segment contraction 242 in relation with its orientation (see Methods; Figure S4). The orientation angle of the tubes 243 representing dendrite branches varied from 0 • ≤ θ ≤ 90 • with respect to the direction of 244 contraction (θ = 0 • perpendicular; θ = 90 • parallel to the direction of contraction). We then 245 plotted the normalised branch curvature increase as a function of the orientation angle. As 246 shown in Figure 4B, branch curvature increased steadily with the increase of the respective 247 orientation angle independently of branch length or the size of the cylinder. Our data and 248 modeling indicate that dendritic branches extending along the anteroposterior body axis may 249 be in the optimal orientation for bending during segment contraction ( Figure 4C). 250 To explore this further in the context of retraction, we computed the relative bending curvature 251 of lateral branches in c1vpda morphologies before (median of 0.93 for second-order lateral 252 and of 0.71 for higher-order lateral branches with a difference between medians of 0.22, 253 p < 0.001, by bootstrap) and after retraction (median of 0.93 for second-order lateral and of 254 0.76 for higher-order lateral branches with a difference between medians of 0.18, p < 0.001, by 255 bootstrap) (Figure 4D). Similarly to the angle orientation measured in Figure 3, the retraction 256 of predominantly higher-order lateral branches led to an overall higher median bending 257 curvature (7.6% increase, p < 0.001, by bootstrap). The increment was caused by the retraction 258 of low bending curvature branches ( Figure 4D). Taken together, these data and simulations 259 suggest that functional constraints of mechanical responsiveness may represent a strong 260 determinant in c1vpda dendrites patterning.

Fig 5. In silico simulations and single branch tracking analysis quantify retraction phase dynamics.
A, Key morphometrics comparing real neurons after retraction with simulated retraction schemes applied on the morphology before retraction. Each dot is one morphology, bars indicate mean, and stars indicate p-values as follows: *< 0.05, **< 0.01 (n = 429 branches, n = 9 neurons, from six animals). B, Dynamics of retraction phase for one sample c1vpda dendritic morphology with branches coloured by their respective dynamics, red circles-to be retracted; orange-shortened; green-newly formed; blue-elongating; grey-stable. C, (Left) Branch dynamics similar to B but quantified as growth rates ( µm hr ) for all branches of all dendrites tracked during the retraction phase, n = 1, 139; same colours as in B. (Right) Assignment of branches to the five types in B as a function of time. Shading represents the standard error of the mean.
In silico simulations and in vivo branch dynamics are consistent with a 262 stochastic retraction 263 Having established a putative functional role of the retraction phase, it is interesting to deter-264 mine the precise principles upon which branch retraction operates. Is a selective retraction of 265 higher-order lateral branches, or one that is specific to branches with non-optimal angles most 266 consistent with the data at hand? To address this question we simulated in silico a variety of 267 schemes that selectively retract specific types of lateral branches from real morphologies (see 268 the real morphology after retraction ( Figure 5A). Surprisingly, the random retraction was the 279 only scheme that yielded good results across all morphometrics compared to the experimental 280 data.

281
Our simulations narrowed down the possible retraction schemes used in biology. A random 282 retraction could be responsible for the c1vpda comb-like shape in a self-organised manner that 283 may be less costly to genetically encode than a deterministic retraction program (Hiesinger 284 and Hassan, 2018). Interestingly, this would make the random retraction scheme efficient 285 at realising functionally specialised morphologies while being itself potentially the product 286 of a rather non-specialised genetic program. In order to better understand the dynamics of 287 this process and its interactions with branch outgrowth we performed time-lapse analysis at 288 the single branch resolution (see Methods). For this analysis, branches were classified into 289 one of the following five types: retracted, shortened, new, elongated, and stable branches 290 ( Figure 5B). 291 Interestingly, when measuring the rates of extension and reduction by tracking individual 292 lateral branches, we found that all types of branches maintained a moderately constant 293 16/57 trend throughout the retraction phase ( Figure 5C). Both reduction and extension averaged 294 approximately between 2 and 3 µm hr in all cases. This analysis suggests a branch type and time 295 invariant mechanism of branch extension and reduction in c1vpda sensory neurons. 296 Since the rates of extension and reduction were similar throughout, the specific proportion of 297 branches per branch type must vary across the examined development window in order to 298 accommodate a retraction phase. Indeed, an initial phase of more intense branch dynamics, 299 with only a small amount of branches remaining stable, lasted approximately half of the 300 analysed time period. In that period of time, roughly half of the branches were involved in 301 retraction while the number of new and elongating branches decreased steadily over time 302 ( Figure 5C). This was followed by a phase defined by the sharp decrease in the number of 303 retracting branches, contrasting with the increase of stable branches, corresponding to the 304 initiation of the stabilisation stage. In this latter phase, the number of new branches kept 305 decreasing to virtually negligible values. In the same time, the proportion of elongating 306 branches increased back to efficiently compensate for the remaining shortening further con-307 tributing to the stabilisation phase. In conclusion, both our retraction simulations as well 308 as measurements of single branch dynamics indicate that retraction is neither specific to 309 functionally suboptimal branches, nor to smaller or higher order branches but stochastic 310 in nature. Nevertheless, the stochasticity of retraction does not prevent it from supporting 311 optimal mechanical responsiveness as shown above.

312
Computational growth model reproduces c1vpda dendrite development 313 In order to better understand how the retraction phase improves c1vpda branch orientation 314 and how it complements the outgrowth phase to produce functionally efficient dendritic 315 patterns, we designed a computational model simulating c1vpda development based on 316 the time-lapse data. The model was based on previous morphological models that satisfy 317 optimal wire considerations through minimising total dendritic cable and conduction times 318 from dendrite tips to the soma (Cuntz et al., 2007(Cuntz et al., , 2008(Cuntz et al., , 2010. In particular, it relied on a 319 recent model designed for class IV da (c4da) neurons that satisfies wire constraints while 320 reproducing the iterations of dendrite growth during development (Baltruschat et al., 2020). 321  The number of branch points, total length and surface area were consistently well fitted by 341 the growth model with random retraction at all simulated developmental stages ( Figure 6C 342 and Figure S5). Importantly, the model reproduced the scaling relationships from Figure 2D, 343 indicating that the resulting morphologies followed basic wire constraints ( Figure 6B). The 344 results also showed remarkably good correspondence with other key morphometrics.

345
The model strengthened the hypothesis that a stochastic retraction was responsible for arbour 346 refinement in c1vpda sensory neurons. The model branch length and angle distributions 347 before and after retraction matched the real data (Figure 6D, c.f. indicates that possibly other mechanisms may be involved in enhancing tips growth direction 356 preference, such as specific cell adhesion molecules (Hattori et al., 2013).

357
Discussion 358 We have shown that the spatiotemporal patterning of c1vpda mechanosensory dendrites 359 during development can be accurately predicted by a noisy growth model that conserves 360 wire, in combination with a stochastic retraction that plausibly enhances their performance at 361 sensing larval contractions. Using single branch tracking analysis on long-term time-lapse 362 reconstructions, we were able to constrain the model without recurring to parameter fitting. 363 We showed how a sequence of three simple stages (1) MB polarisation, (2) subsequent branch 364 outgrowth and (3) a final stochastic retraction stage generates specialised dendrites that favour 365 functional branches, as found in real c1vpda sensory neurons.

382
The initial innervation of the dendrite's spanning field by lateral branches produced -similarly 383 20/57 to previously observed class IV da neurons -optimally wired (see Figure 2) and space filling 384 dendrites (Baltruschat et al., 2020). In the c1vpda the branches at this early stage divided into 385 two distinct morphological classes: (1) longer second-order lateral branches that spread along 386 the anteroposterior axis with growing tips mostly targeting distal and sparser areas of the 387 dendritic territory. (2) In contrast, higher-order lateral branches exhibited shorter lengths, 388 mainly innervating the dorsoventral axis, and more often located in proximal and densely 389 packed areas of the dendrite's spanning field.

390
Phases of c1vpda development 391 Following the extension phase, we observed a retraction step that refined the spatial arrange-392 ment of the dendritic tree (Figure 3). In the past, studies based on low temporal resolution 393 static data of dendrite development suggested that distinct growth and retraction phases may 394 happen sequentially during development (Lázár, 1973

401
The retraction of a dendritic tree could have economical purposes and minimise the amount 402 of wire, or it could refine the branching pattern to enhance functionality. Our data indicate 403 that the latter is the case, with a simple random retraction selectively remodelling the tree 404 structure, influencing the mechanisms of dendritic signal integration (Figure 5). This result 405 was surprising at first because it suggested that to ensure the removal of sub-optimal branches 406 retraction effectors could be spatially constrained around higher-order lateral branches or 407 branches with low orientation angle, exerting control over their elimination. However, the 408 biased retraction of higher-order lateral branches was really attained due to the combination 409 of three factors: asymmetry of branch length distributions between branch orders (Figure 3)   We are grateful to A. Berthelius for comments on the manuscript. We would like to thank 505 M. Weigand for help with using the 3D printer, and to A. Kohli and R. Khamatnurova for 506 discussions on the tree alignment algorithm. This work was supported by a BMBF grant 507   In the embryo (7 animals), 28 neurons were imaged at 5mins resolution between 16hrs AEL 526 and around 24hrs AEL (Figure 1A), for periods ranging from 30mins to 6hrs. Image stacks 527 When the image stacks using these voxel sizes were blurred we increased the resolution 544 to (0.3907µm × 0.3907µm × 0.5635µm). For L2 stages (50hrs AEL), we used a 40 × 1.4 NA 545 oil immersion objective and a wide range of voxel sizes -(0.5209µm × 0.5209µm × 1µm), 546 to assure high resolution images for all cases. Finally, to acquire images during L3 stage 548 (72hrs AEL), we used a 20 × 0.8 NA multi-immersion objective and voxel sizes (0.8335µm × 549 0.8335µm × 1.5406µm) and (0.7144µm × 0.7144µm × 1µm). Before embryo collection, a dab of yeast paste was added to a fresh apple agar plate. This 553 first plate was removed and discarded after 1hr and exchanged with a fresh plate with yeast 554 paste. In this way, we assured that older and retained embryos were discarded. For the 555 actual embryo collection, embryos were collected for 30mins and then allowed to age until the 556 appropriate time for imaging. Until the imaging session started, the embryos were kept in the 557 incubator at 25 • C and 60% relative humidity on apple agar to prevent them from drying out. 558 Before the imaging session started, the embryos were dechorionated with mild bleach (50% 559

26/57
Refining dendrite function during development Castro et al.
Clorox; final concentration: 2.5% hypochlorite) for 3.5mins. Not all embryos were dechorion-560 ated by this gentle treatment, but only dechorionated embryos were selected to be imaged. 561 After being selected, the embryos were handled using an artist's brush and were washed with 562 water three times in a filtration apparatus. The components were gently mounted with screws between the metal plate objective slide 578 and the plastic slide. Again, throughout all imaging sessions the larvae were covered in 579 halocarbon oil to ensure access to oxygen.

580
In between imaging sessions, every animal was kept at 25 • C at 60% relative humidity in a 581 separate 500µl Eppendorf tube, which was filled with 200µl flyfood. Holes were carved on 582 the lid of the tube to guarantee air exchange. Before the next imaging trial, the flyfood was 583 dissolved in water and the larvae were localised under a binocular microscope and washed 584 three times with tap water.   615 The regions of interest (ROIs) in which to measure the Ca 2+ signal were first defined manually 616 as a rough contour around the apical dendrite of the central cell of a given triplet for every 617 time point of an imaging session, using the ROI functionality from Fiji. Afterwards, we auto-618 matically generated tighter contours using the "Defaultdark" parameter from the roiManager 619 menu (see available code) by setting a threshold for the intensity values of the tdT omato 620 signal, enabling the capture of pixels from the dendrite branches and not spurious noise in the 621 larger ROI (Figure S3). Every ROI was defined on the red channel to capture dendrite cable 622 tagged with CD4 − tomato, ensuring that the following Ca 2+ fluorescence extraction was done 623 exactly on the c1vpda dendrite's membrane.

624
Ca 2+ imaging analysis 625 The intensity values of GCaM P 6m and tdT omato were then extracted for each ROI and time 626 point and then exported from Fiji. The analysis of the fluorescence signals was performed 627 using custom made code in Matlab (www.mathworks.com). The GCaM P 6m signal was 628 normalised with the CD4 − tomato signal and the ratio R = F GCaM P 6m F tdT omato was used to calculate 629 ∆R R 0 . After the ratio between GCaM P 6m and tdT omato was calculated, the background signal 630 (R 0 ) was subtracted from every time point. R 0 was computed as the average of the first five 631 frames of a given time series. Overall, the fold change of GCaMP6m fluorescence intensity 632 over time was calculated as ∆R R 0 = R−R 0 R 0 . The function unsharpmask from Fiji (radius: 1.5, 633 weight: 0.4) was applied to the images for visualisation in Figure S3 to enhance dendrites, but 634 the quantitative analysis was done with the raw imaging data.

635
To link Ca 2+ dynamics to the contraction of body wall experienced during crawling behaviour, 636 we plotted the contraction rate against the ∆R R 0 . However, as previously mentioned, the 637 crawling speed can vary significantly between animals and across trials. Thus, to avoid 638 averaging artifacts when comparing the ∆R R 0 transients against segment contraction, we first 639 realigned the Ca 2+ traces to a biologically relevant marker. We chose to realign the ∆R  Modelling curvature increase 643 To understand how the bending of tubular membrane branches with different orientations 644 affects their curvature, we assumed a marginal case for which the larva's cuticle folding can 645 be approximated by the surface of a cylinder with radius R (Figure S4A). The orientation 646 of the branch is then defined by the angle θ between the cylinder axis of symmetry and the 647 central axis of each branch. The angle varies from θ = π 2 = 90 • for a branch oriented in the 648 anteroposterior axis of the larva's body and perpendicular to the axis of symmetry of the 649 cylinder in our model, to θ = 0 = 0 • for a branch oriented in the dorsoventral axis of the 650 larva's body and parallel to the axis of symmetry of the cylinder in our model. Starting from 651 an initial branch with θ = π 2 and length L = 2πR, we kept the branch length constant and 652 calculated the curvature increase of the branch for different orientation angles 0 ≤ θ ≤ π 2 . For 653 simplicity we approximated the shape of a tilted branch, which follows an elliptical profile 654 with diameters a = R = L 2π and b = a sin θ on the cylinder, with a circular branch with a radius 655 of curvature R c = 0.5 (a + b) resulting in 1 sin θ = 4πRc L − 1 (see Figure S4B). An initial straight 656 branch of radius r has two principal curvatures c 1 = 0 and c 2 = 1 r . Upon bending of the 657 tubular branch around the cylindrical body with radius R r, the second principal curvature 658 is almost constant. Therefore, we computed the relative increase in the first principal curvature 659 c1 to represent the curvature variation. The curvature increase is rescaled with respect to 660 its maximal value for a branch oriented in the anteroposterior axis of the larva's body and 661 perpendicular to the cylinder axis of symmetry with θ = π 2 . The curvature is a steadily rising 662 function of the angle θ, varying from zero for a straight branch with θ = 0 (see Figure S4A, 663 bottom branch), to one, for a fully bent, i.e., circular, branch with θ = π 2 (see Figure S4A, left 664 most branch; and Figure 4B).    dorsoventral oriented paths between terminals and MB ( Figure 1A, middle row). The 720 longer branches were reminiscent of the lateral branches in L1-L3 stages.

721
Taking into account assumptions 1 − 3, we measured the angles and curvature increase of 722 the segments of a given dendrite branch in relation to the MB of the tree as a proxy for the 723 direction of the body wall contraction. However, during development, the c1vpda sensory 724 neurons migrate in the embryo changing their location and orientation relative to their initial 725 position. This was also the case in larval instar stages where the dendritic orientation changed 726 through different time points due to mechanical forces exerted on the larvae between the 727 preparation and the cover slip during imaging sessions. We therefore required an unbiased 728 procedure to reorient the dendrites.

729
To this effect we wrote the TREES Toolbox function PB c1 tree that automatically finds the 730 c1vpda MB and rotates the entire dendrite to align the MB to the y−axis (Figure S2). For 731 a particular cell of interest the algorithm was initialised by finding the last node from the 732 longest path (pvec tree function) and rotating the tree (rot tree function) until the last node 733 was approximately aligned vertically (±1µm) with the root at position (0, 0). This initialisation 734 helped to reduce the number of computations required in the following steps of the algorithm 735 ( Figure S2). 736 Afterwards, a bounding box around the dendrite was computed using the polyshape and 737 boundingbox functions (Matlab). The closest nodes of the tree to the top left and top right were 738 then identified (pdist, Matlab function; see Figure S2). The first shared branch point between 739 those two corners was then defined to be the last node of the MB (using ipar tree function). 740 Finally, the tree was rotated again until the new MB tip was approximately vertically aligned 741 with the root at position (0, 0) ( Figure S2A). The previous steps were repeated until no new 742 last node was found between two consecutive iterations ( Figure S2B). 743 After finding the MB of a given tree and taking into account assumption 3, we partitioned 744 the tree into all the lateral subtrees that emerged from the MB. Each subtree was considered 745 separately and its root was set to the node that connected it with the MB. The MB was then 746 removed from further analysis. Considering assumption 4 we ordered the branches of every 747 subtree according to their length using the BLO c1 tree function. This new TREES Toolbox 748 function returns the branch length order (blo) values for each branch by first taking the longest 749 path from the root of the subtree and defining it as blo = 1. It then defines all the longest 750 paths that branch off from this initial path and labels them as blo = 2. This procedure is 751 recursively executed for higher order branches that sprout from previously ordered branches 752 until all branches are labeled (see Figure 3). This method was chosen to better accommodate 753 the traditional identification of primary, secondary and tertiary branches in this system. It 754 distinguishes itself fundamentally from the branch order that increases in steps of one at every 755 branch point away from the root as well as from the Strahler order where order 1 starts at the 756 dendrite's terminals. The branch order starts at 0 at the root of the tree and increases after every branch point 770 max (BO tree (tree)).

771
3. Mean branch order as mean (BO tree (tree)). Since the trees were resampled to have 1 772 and 0.1µm distances between nodes each branch order value was thereby approximately 773 weighted by the length of dendrite with that branch order.           34. Cable density was calculated as the ratio between the total length and the surface area 836 of a given tree. This was obtained by combining the len tree function to calculate the 837 total length and the span tree function to calculate the surface area of the tree.

Time-lapse analysis at single branch resolution during the retraction phase 864
The terminal and branch points of the retraction dataset (n = 9) of c1vpda sensory neurons 865 that underwent the retraction phase were registered using ui tlbp tree (TREES Toolbox), a 866 dedicated user interface as described previously (Baltruschat et al., 2020) For any specified c1vpda time series (n = 9) during retraction, we selected the reconstructions 879 when the number of branch points was maximal, i.e., before retraction, and when the number 880 of branch points was minimal after retraction. Afterwards, we computed the difference in 881 number of branch points between the aforementioned trees using the B tree function (TREES 882 Toolbox).

883
Then, using the B tree, T tree and dissect tree functions (TREES Toolbox) we generated a 884 set of all "terminal branches" belonging to a given tree before retraction, defined as the piece 885 of dendrite cable between a given termination point and the immediately preceding branch 886 point on its path to the soma. Afterwards, we removed the same number of branches from the 887 tree as the number of branch points difference, by applying four different retraction schemes: 888 • Small branches first: in this branching scheme the terminal branches were sorted in 889 ascending order by length using the len tree function (TREES Toolbox) and the smaller 890 branches removed first.

891
• Lower angle branches first: terminal branches were sorted in ascending order by the aver-892 38/57 age orientation angle of all segments of the branches using the perpendicularity c1 tree 893 function (new TREES Toolbox function) and the branches with lower angles were re-894 moved.

895
• Higher branch length order first: terminal branches were sorted in descending order 896 accordingly to their branch length order using perpendicularity c1 tree function 897 (new TREES Toolbox function) and the branches with highest branch length order were 898 removed.

899
• Random retraction: this retraction scheme contrasts with a rigid and deterministic 900 sequence of programmed retraction, and replaces it by a stochastic retraction. Terminal 901 branches were selected randomly with a uniform distribution and eliminated accordingly. 902 An average over 100 simulations was used.

903
These results were then analysed and compared as explained in the Results section.

929
The noisy growth phase of the model was then initialised and at each iteration the surface 930 area was probed with N = 100, 000 random target points. For each target point the shortest 931 Euclidean distance to the tree was detected and the resulting distances were capped at a 932 maximal growth range radius of r = 2.5µm, before retraction (19.5hrs AEL) and r = 1.81µm 933 after retraction. These radii were defined as the average growth rate of new branches until 934 and after retraction respectively (from Figure 5C) reported as: * p < 0.05, ** p < 0.01, *** p < 0.001.

964
Data and Software Availability 965 The data and custom Matlab scripts that support the findings of this study will be made 966 available on publication.   Illustrative rough ROI's (middle panels) used to generate the tight ROI's around the cells dendrites (right panels). The rightmost insets with orange borders show zoomed in images of the neuron indicated by the orange arrow in the left panels. In B, images showing increased GCaMP6m activity in c1vpda dendrites during contraction, but in C, GCaMP6m activity decreased back to baseline during distension. Scale bar, 50µm.  Time course of the number of branch points (left), total length of dendrite cable (middle) and surface area (right) during embryonic development. Same arrangement and same data as in Figure 6B but for the growth model without retraction.