Medicine, Faculty of
DSpace
UBCV
Lindsay, Adrian John
Doctor of Philosophy - PhD
University of British Columbia
A large body of experimental evidence across humans, primates, and rodents implicates the anterior cingulate cortex (ACC) as a component of emotional cognition. Studies of neural correlates have shown a wide variety of information being represented, including behaviour and emotional state, and previous work suggests that ACC constructs combined, complex representations of context from this variety of information, which is passed on to downstream areas concerned with emotional or autonomic state. Previous analyses in our lab have demonstrated that emotional state plays a role in this overall context, and that other representations such as behaviour are likely modulated by this emotional context. To tease apart these representations, describe their properties, and investigate how the contextualisation of representations by emotional state is functionally achieved we built and adapted a set of machine learning tools and analyses and applied it to our experimental paradigm of conditioned emotionally relevant outcomes, the ‘3-valence task’. We first built and applied HUB-DT, and unsupervised behavioural discovery tool, and generated a complete description of behaviour during our experimental task. Then, we utilised these complete sets of behavioural labels in conjunction with ACC recordings to disambiguate behaviour and emotional state in ACC, and quantify how these representations were related. Finally, we built and applied a novel neural network analysis approach, called the Neural Trajectory Point Net (NTPN) to extract the geometry of representations, their features and differences, and to gain an understanding of how their representational geometry is informed by their functional relationship. The results suggest that context representations in ACC are organized primarily by emotional state. Representations of behaviour, and likely other factors, are geometrically stable but are modulated or transformed by the influence of emotional state to form a combined context signal. These combined, transformed representations likely form the output of ACC to downstream emotional and autonomic brain areas, and support its proposed role in modulating the emotional response to context and informing the process of emotionally motivated decision making.
UNDERSTANDING THE GEOMETRY OF EMOTION by Adrian John Lindsay BSc, The University of British Columbia, 2008 BCS, The University of British Columbia, 2012 MSc, The University of British Columbia, 2018 A thesis submitted in partial fulfillment of the requirements for the degree of DOCTOR OF PHILOSOPHY in THE FACULTY OF GRADUATE AND POSTDOCTORAL STUDIES (Neuroscience) THE UNIVERSITY OF BRITISH COLUMBIA (Vancouver) August 2024 © Adrian John Lindsay, 2024 ii The following individuals certify that they have read, and recommend to the Faculty of Graduate and Postdoctoral Studies for acceptance, the dissertation entitled: Understanding the Geometry of Emotion submitted by Adrian John Lindsay in partial fulfilment of the requirements for the degree of Doctor of Philosophy in Neuroscience Examining Committee: Dr. Jeremy Seamans, Professor, Department of Psychiatry, UBC Supervisor Dr. Timothy Murphy, Professor, Department of Psychiatry, UBC Supervisory Committee Member Dr. Stan Floresco, Professor, Department of Psychology, UBC Supervisory Committee Member Dr. Nicholas Swindale, Professor, Department of Ophthalmology, UBC University Examiner Dr. Steve Wolfman, Professor of Teaching, Department of Computer Science, UBC University Examiner Dr. Bruno Averbeck, Section Chief: Learning and Decision Making, National Institute of Mental Health External Examiner Additional Supervisory Committee Members: Dr. Helge Rhodin, Professor, Head of Visual AI for Extended Reality, Bielefeld University Supervisory Committee Member iii ABSTRACT A large body of experimental evidence across humans, primates, and rodents implicates the anterior cingulate cortex (ACC) as a component of emotional cognition. Studies of neural correlates have shown a wide variety of information being represented, including behaviour and emotional state, and previous work suggests that ACC constructs combined, complex representations of context from this variety of information, which is passed on to downstream areas concerned with emotional or autonomic state. Previous analyses in our lab have demonstrated that emotional state plays a role in this overall context, and that other representations such as behaviour are likely modulated by this emotional context. To tease apart these representations, describe their properties, and investigate how the contextualisation of representations by emotional state is functionally achieved we built and adapted a set of machine learning tools and analyses and applied it to our experimental paradigm of conditioned emotionally relevant outcomes, the ‘3-valence task’. We first built and applied HUB-DT, and unsupervised behavioural discovery tool, and generated a complete description of behaviour during our experimental task. Then, we utilised these complete sets of behavioural labels in conjunction with ACC recordings to disambiguate behaviour and emotional state in ACC, and quantify how these representations were related. Finally, we built and applied a novel neural network analysis approach, called the Neural Trajectory Point Net (NTPN) to extract the geometry of representations, their features and differences, and to gain an understanding of how their representational geometry is informed by their functional relationship. The results suggest that context representations in ACC are organized primarily by emotional state. Representations of behaviour, and likely other factors, are geometrically stable but are modulated or transformed by the influence of emotional state to form a combined context signal. These combined, iv transformed representations likely form the output of ACC to downstream emotional and autonomic brain areas, and support its proposed role in modulating the emotional response to context and informing the process of emotionally motivated decision making. v LAY SUMMARY Emotion is a critical component in our cognitive machinery, and necessary for making appropriate decisions and actions in response to circumstance. While several areas of the brain are involved in the processing and expression of emotion, the anterior cingulate cortex (ACC) seems to play a particular role in modulating emotional response based on current context. By building and adapting a selection of machine learning tools, we were able to investigate what the representations of emotion and behaviour look like in populations of neurons in ACC, their common properties and differences, and gained some insight into how this modulation of emotional state is functionally achieved. We suggest that information in this part of the brain is primarily organized according to emotional state, and that the role of emotion in forming context is key to the cognitive function of ACC. vi PREFACE The main experimental task studied in this dissertation was designed by Dr. Jeremy Seamans and Barak Caracheo. The experiments were carried out and data collected by Barak Caracheo, Jamie Grewal and myself. The data analysis was performed by Dr. Jeremy Seamans and myself, with some addition analysis/annotation provided by Isabella Gallello. The software and analysis tools (HUB-DT, and the NTPN) were designed and developed by me. The experiments using animals were carried out in accordance with the Canadian Council of Animal Care, and with the approval of the Animal Care Committee at the University of British Columbia (A14-0084). Chapter 2 was published as a pre-print on Bio-ArXiv in 2024 as “HUB-DT: A tool for unsupervised behavioural discovery and analysis” by Adrian Lindsay and Jeremy Seamans (DOI: https://doi.org/10.1101/2024.01.08.574696). Chapter 3 was published in the Journal of Neuroscience in 2024 as “Reconfiguration of Behavioral Signals in the Anterior Cingulate Cortex Based on Emotional State” by Adrian Lindsay, Isabella Gallello, Barak Caracheo, and Jeremy Seamans (DOI: https://doi.org/10.1523/JNEUROSCI.1670-23.2024). vii TABLE OF CONTENTS ABSTRACT ...................................................................................................................................................... ii LAY SUMMARY .............................................................................................................................................. v PREFACE ....................................................................................................................................................... vi TABLE OF CONTENTS ................................................................................................................................... vii LIST OF FIGURES ........................................................................................................................................... xi ACKNOWLEDGMENTS .................................................................................................................................xiii DEDICATION ................................................................................................................................................ xiv Chapter 1: Introduction ................................................................................................................................ 1 Emotion in Cognition ............................................................................................................................ 1 The anterior cingulate cortex ................................................................................................................ 3 Emotion and Behaviour in the ACC ....................................................................................................... 4 The nature of neural representations in ACC ....................................................................................... 6 Constructing Context ............................................................................................................................ 7 Recording and visualising neural activity in the ACC ............................................................................ 8 Defining and quantifying behaviour ..................................................................................................... 9 Encapsulating Valence Experimentally ............................................................................................... 11 Outstanding Questions ....................................................................................................................... 13 Bringing it all together ........................................................................................................................ 13 Laying out our approach ..................................................................................................................... 14 Bridging the fields of machine learning and neuroscience ................................................................. 15 A case study in applied machine learning ........................................................................................... 16 Summary of Research Goals: .............................................................................................................. 19 Chapter 2: HUB-DT: A tool for unsupervised behavioural discovery and analysis ..................................... 20 Introduction ............................................................................................................................................ 20 HUB-DT: Motivating this Report ......................................................................................................... 22 A rich ecosystem of existing tools and techniques ............................................................................. 24 Discovering Behaviour for Comparative Neural Analysis ....................................................................... 29 Extracting Pose: Annotating limb position from multi-camera recordings ........................................ 29 Behavioural Space: Projecting extracted pose into a spatiotemporal manifold ................................ 31 Dimensionality Reduction and Density Maps ..................................................................................... 33 viii Hierarchical Unsupervised Clustering ................................................................................................. 37 Connecting Unsupervised Behavioural Discovery to Manual Behavioural Labels .............................. 42 Exploring the Hierarchy ....................................................................................................................... 48 Evaluating discovered behaviour ........................................................................................................ 48 Comparative Analysis and Discovering Relevant Behaviour ................................................................... 52 HUB-DT: Hierarchical Unsupervised Behavioural Discovery Tool ........................................................... 54 HUB-DT Use Cases:.................................................................................................................................. 55 Investigating the characteristics of neural activity related to behaviors versus other task events ... 55 Discovering the behaviours of addiction and withdrawal .................................................................. 59 Chapter 3: Reconfiguration of behavioural signals in the anterior cingulate cortex based on emotional state ............................................................................................................................................................ 63 Introduction ............................................................................................................................................ 63 Unsupervised detection and annotation of behaviour ....................................................................... 65 Representations of behaviour across distinct emotional contexts .................................................... 66 Methods .................................................................................................................................................. 66 Results ..................................................................................................................................................... 75 Hierarchical Unsupervised Behavioural Discovery Tool ..................................................................... 76 Discovering Behaviour at Variable Granularities ................................................................................ 81 Identifying Discovered Behaviours ..................................................................................................... 82 Comparing Human and Automatically Generated Behavioural Labels .............................................. 83 Disentangling Behaviour and Emotional Context Signals in Single Neurons ...................................... 85 Predictive Decoding from Populations of Neurons ............................................................................ 89 The dynamics of changing behavioural representations .................................................................... 93 Remapping of behavioral representations by emotional context ...................................................... 94 Contextual Shifts in Ensemble Encoding ............................................................................................. 95 Behavioural ‘Syllables’ and ‘Words’ .................................................................................................... 99 Variations in behaviour across contexts ........................................................................................... 101 Discussion.............................................................................................................................................. 103 Emotional Regulation ........................................................................................................................ 103 Defining and Extracting Behaviour ................................................................................................... 104 Representing Behaviour in ACC neurons .......................................................................................... 106 Emotional Valence and the Modulation of Behaviour...................................................................... 106 Mixed Selectivity and Population Encoding ...................................................................................... 107 ix ‘Context’ Encoding as a General Principle ........................................................................................ 109 Emotional ‘Gain’ and Contextually-appropriate Behaviour .............................................................. 110 Chapter 4: The geometry of emotion in ACC: Topological data analysis and the neural trajectory point net ............................................................................................................................................................. 111 Introduction .......................................................................................................................................... 111 Methods: ............................................................................................................................................... 115 Results ................................................................................................................................................... 138 Geometry of Neural Representations in ACC ................................................................................... 138 Testing the NTPN on a known system .............................................................................................. 138 Decoding Emotional Context and Behaviour .................................................................................... 139 Latent representations extracted from the NTPN ............................................................................ 139 Visualising geometry with Mapper ................................................................................................... 144 Distances between geometry ........................................................................................................... 146 Relationships between emotional contexts ..................................................................................... 148 Discussion.............................................................................................................................................. 150 Modulating behaviour by emotional state ....................................................................................... 150 Extended context and mixed-selectivity ........................................................................................... 151 Framing the results of topological and geometric analysis on neural data ...................................... 152 Defining the geometry of ACC representations ................................................................................ 153 Non-symmetric relationship between contexts ............................................................................... 155 Dynamics and geometry in the ACC .................................................................................................. 155 Extending the NTPN .......................................................................................................................... 157 Chapter 5: Discussion ................................................................................................................................ 159 Summary ........................................................................................................................................... 159 Emotion is Context ............................................................................................................................ 160 The case for the emotional contextualisation of behaviour ............................................................. 162 Encoding Relevance .......................................................................................................................... 163 Mixed selectivity ............................................................................................................................... 166 Modelling Biological Networks ......................................................................................................... 168 Alternate Machine Learning approaches .......................................................................................... 169 Ensuring Interpretability in Novel Analysis ....................................................................................... 172 HUB-DT, the NTPN and the Future ................................................................................................... 172 Additional Resources ................................................................................................................................ 173 x References ................................................................................................................................................ 174 Appendix: HUB-DT User Guide ................................................................................................................. 187 xi LIST OF FIGURES Figure 1-1 Exploring Representations of Emotion and Behaviour in ACC ................................................. 18 Figure 2-1 The HUB-DT Pipeline, Steps A-C ................................................................................................ 30 Figure 2-2 The HUB-DT Pipeline, Steps C-E ................................................................................................. 32 Figure 2-3 The HUB-DT Pipeline, Steps E-G ................................................................................................ 36 Figure 2-4 The HUB-DT Pipeline, Steps G-I ................................................................................................. 39 Figure 2-5 HDBSCAN. Hierarchical clustering at variable density ............................................................... 40 Figure 2-6 Clusters in Behavioural Space .................................................................................................... 41 Figure 2-7 Characterizing Manual Behaviours ............................................................................................ 45 Figure 2-8 The Hierarchy of Behavioural Clusters ...................................................................................... 47 Figure 2-9 Visually Evaluating Behavioural Clusters ................................................................................... 51 Figure 2-10 Identifying Emotional Context Specific Behaviours ................................................................. 56 Figure 2-11 Nerual Representation of Behaviour Across Emotional Contexts ........................................... 58 Figure 2-12 Extracting Morphine-Specific Behaviours ................................................................................ 61 Figure 3-1 Recording sites and task schematic ........................................................................................... 76 Figure 3-2 A schematic description of the HUB-DT process ....................................................................... 78 Figure 3-3 Behavioural discovery at different levels of the behavioural cluster hierarchy ........................ 80 Figure 3-4 Identifying different behaivours detected in a single session ................................................... 83 Figure 3-5 Comparing behavioural labels assigned by a human versus HUB-DT ....................................... 85 Figure 3-6 Measuring Responsive Neurons across the population ........................................................... 88 Figure 3-7 The impact of context-specific behaviours on contextual encoding ......................................... 89 Figure 3-8 ACC ensemble encoding of emotional context ......................................................................... 91 Figure 3-9 Quantifying the magnitude of change in behavioural representations .................................... 92 Figure 3-10 Visualizing shifts in behavioural representations across emotional contexts ......................... 98 xii Figure 3-11 Linking behaviours through time ........................................................................................... 100 Figure 3-12 Decoding context from behavioural coordinates versus neural repsonses .......................... 102 Figure 4-1 Labelling behaviour with HUB-DT ............................................................................................ 117 Figure 4-2 Generating neural trajectories from spike count data ............................................................ 118 Figure 4-3 Formatting data for the neural trajectory point net ............................................................... 122 Figure 4-4 Feature ablation on the neural trajectory point net .............................................................. 125 Figure 4-5 The Neural Trajectory Point Net: Step-by-step ...................................................................... 127 Figure 4-6 Critical sets and bound shapes ................................................................................................ 130 Figure 4-7 Generating and counting homology groups with a Vietoris-Rips complex ............................ 133 Figure 4-8 Persistent Homology ................................................................................................................ 134 Figure 4-9 Mapper: generating topology from structure ......................................................................... 136 Figure 4-10 Classification accuracy for the NTPN ..................................................................................... 137 Figure 4-11 Trajectories to Critical Sets .................................................................................................... 141 Figure 4-12 Differences in the geometry of neural representations ........................................................ 143 Figure 4-13 Measuring the distance between topologies ........................................................................ 145 Figure 4-14 Comparing neural trajectories between emotional contexts using Mapper ........................ 148 xiii ACKNOWLEDGMENTS This work could not have happened without my supervisor, Dr. Jeremy Seamans, who saw the potential of my multiple disciplines and offered me a place in neuroscience. I would also like to acknowledge the support of my committee members, Dr. Tim Murphy, Dr. Stan Floresco, and Dr. Helge Rhodin who were willing to bridge the gap between their various fields of expertise. I would like to thank my fellow Seamans Lab members for their direct contributions to this thesis, and also for providing both practical and moral support, and for sitting through many long-winded machine-leaning explanations from me. I am extremely grateful for the support from my family, particularly my mother, who has continued to support me through seemingly endless academic pursuits, and my friends who have kept me pointed towards the light at the end of this very long tunnel. This work was supported by funding from CIHR (MOP-137045, PJT-159796, 20R76081) and NSERC (05979, 20R77768). xiv DEDICATION For Dad 1 Chapter 1: Introduction Decision making is a complex and multifaceted process, and the biological machinery involved is just as complex. A huge swathe of our brain participates, different areas contributing different components to the decision-making puzzle, all working in concert to inform our actions. One crucial, and sometimes overlooked component in this cognitive melange is emotion. Emotion strongly modulates our motivation, and impacts how we assess different aspects of context and consequence. How we feel alters our evaluation of what is relevant, what is beneficial or harmful, and what is appropriate. Dysfunction of these processes can have a significant impact on decisions and behaviour, as we see manifest in many patients suffering with emotional disorders. Without these elements of emotionally informed motivation and context, we are ill-equipped to make appropriate decisions with desired outcomes, whether we consider the simple decisions of a foraging rodent, or the complex decisions of a human operating in a social landscape. Emotion in Cognition Defining emotion, and even more so defining the role of emotion in decision making, or cognition in general is a herculean task. In his book, ‘Descartes’ Error: Emotion, Reason, and the Human Brain’ Damasio (1994) suggests that emotion and feeling provide the bridge between rational and nonrational processes, or in anatomical terms, between cortical and subcortical structures. While there is some poetic license underlying the simplicity of this description, it nonetheless highlights a necessary role in cognition. One that is strongly supported by the evidence of human experience as well as experimental neuroscience. 2 In the field of psychology, emotion is harder to pin down. With descriptions varying from instinct, inner motivation, models of behaviour or belonging to a continuum of mental entities. Interestingly the field of artificial intelligence, specifically in developing agents with synthetic intelligence has arrived at a similar conclusion to Damasio; emotions are a necessary and critical component of a system of cognition that shows the behaviours and properties we want (Bach, 2009). Emotions in this framework are configurations of cognition: settings of the cognitive modulators, motivational parameters and urges. The experiential facet is the dominant aspect of emotion, and as emotional categories are simply descriptions of these cognitive configurations, emotions are functionally realized as these modulatory states. Such an agent does not simulate emotions, but rather is emotional (Bach, 2009). While the philosophical ramifications may be beyond the scope of this current investigation, the description is compelling in its similarity to that offered by neuroscience. Emotion, by its etymology, means ‘motion out’. An outward expression of internal state in the form of expression, posture, or most importantly, behaviour. We would, as a means both to refine its meaning and alleviate the confusion of overlapping terms label this emotional, motivated behaviour as action. It could certainly be argued that all behaviour is motivated, but here I highlight this terminology to emphasize motion with intent or goal, actions, as opposed to descriptions of muscular output, limbs, pose and position, behaviour (more on this distinction later). By consequence, just as action is motivated behaviour, the emotional machinery can be thought of as ‘motivated cognition’, in that its processes are modulated by cognitive instantiations of emotional relevance, biological needs, urgency and desires. Damasio states: “Emotion is the combination of a mental evaluative process, simple or complex, with dispositional responses to that process, mostly towards the body proper…but also toward the brain itself.” Emotion defined this way is both embodied (in the internal and external expressions of emotional state and emotionally motivated action), and cognitive (in its modulatory influence on 3 ongoing mental process). If emotions are, as suggested by Damasio (2012), bioregulatory reactions that aim to promote physiological states that secure survival and well-being, what are the effects of such reactions? There are of course the internal systemic changes, chemical and homeostatic, of emotional state, but the expression of emotion is in the actions that promote that survival and well-being. As Frijda (1986, 2012) states, emotions are the substrate for motivated behaviour, and while not every instance of emotion results in action, both the potentiation and selection of these actions depend on emotional control (Zhu and Thagard, 2002). In other words, emotion drives the preparation for, the selection of, and the expression of action. While the variety of descriptions of emotion demonstrates that the definition and scope of emotion is extremely heterogeneous, there is ample evidence to suggest that it is a critical component of cognition, inherently tied to our actions and the decisions that drive them. However, as should be clear from the breadth of its description, understanding the functional mechanisms of emotion, and how it is represented in the brain remains a significant challenge. The anterior cingulate cortex In our pursuit of gaining a greater understanding into the encoding of emotion, we have focused on the anterior cingulate cortex (ACC). While there are multiple theories on its primary function, anatomical and experimental evidence suggests that it is involved in the control of emotional or autonomic states (Critchley et al, 2003; Seamans & Floresco, 2022). At the level of individual neurons, this story of purpose becomes much more complex. ACC neuronal signals across a variety of species are known to encode almost any stimuli, event, or internal state. Decoding these complex neural signals is further complicated by the modulatory influence of context on individual representations. However, the action 4 of emotional state in shaping these contextual encodings may provide insight into the function of emotional signals in ACC, and perhaps emotionally motivated cognition more generally. Emotion and Behaviour in the ACC There is extensive evidence demonstrating the involvement of ACC in emotion, emotional cognition and emotionally motivated behaviour drawn from studies in both humans and animals. Shackman et al (2011) meta-analysis of 192 functional imaging studies in humans made a convincing argument that different modes of ACC activity differentiate between emotional states. Dysfunction of the ACC has also been implicated in a number of emotional (Jaworska et al, 2015; Drevets et al, 2008) and anxiety-related disorders like obsessive-compulsive disorder (OCD) (McGovern and Sheth, 2017). Studies of neural correlates in animals have shown encoding of internal states such as stress, fear, pain, and hunger amongst others (Padilla-Coreano et al, 2016; Quinn et al, 2008; Guiustino et al, 2015; Johansen et al, 2001). Electrical activation of the ACC in awake human patients can evoke motoric behaviors, changes in autonomic state (increases/decreases in heart rate, blood pressure and gastric motility) in addition to emotional reactions, like laughter and sadness (Caruana et al, 2018; Critchley et al, 2003; Yoshino et al, 2010). Disruption of the ACC and connecting pathways also has profound impacts on autonomic and emotional states. The surgical removal of ACC (anterior cingulotomy) or severing of the connective tracts from the anterior thalamus to ACC (anterior capsulotomy) can remediate aspects of otherwise treatment resistant depression, anxiety or chronic pain (McGovern et al, 2017; Brotis et al, 2009). These surgical interventions appear to work by reducing the exaggerated emotional reaction to severe psychic pain or anxiety without directly affecting the ability to sense pain or exhibit normal emotional reactions. More extensive damage to the ACC can result in akinetic mutism (Devinsky et al, 1995) in some patients, and 5 cause reduced motivated behavioural output to threatening stimuli in primates (Rudebeck et al, 2006; Bliss-Moreau et al, 2021). The idea that the ACC impacts autonomic arousal fits well with the anatomy of ACC. There are strong interconnections between the ACC and brain regions involved in the generation or control of emotional and autonomic states, including the amygdala, midbrain, and brain stem (Gabbot et al, 2020; Burgos-Robles et al, 2017, Hoover and Vertes, 2007). Projections to and from ACC are not limited to these emotional areas, however. The ACC also has connections to areas that generate behaviour, including the motor cortex, thalamus, striatum and spinal cord (Leow et al, 2022; Brokett et al, 2020; Takeuchi et al, 2022; Gabbot et al, 2020). Neuronal correlates of specific movements of individual limbs, and a variety of task related actions and behaviours have been shown across a number of animal studies (Jung et al, 1998; Seo et al, 2012; Lindsay et al, 2018). These correlates are not static however but change in response to changes in the environment, task structure, level of effort required to attain a reward and the outcome of the behavior (Sachuriga et al 2021; Porter et al 2020; Bryden et al 2019; Caracheo et al 2018; Ma et al 2016). Collectively, the representations of actions and behavior in the ACC depend on the prevailing context, where context can mean the physical environment, task or emotional state (more on this below). The contextualized representations formed with the ACCs likely feed into downstream efferent targets, which by and large are involved in generating or regulating emotional and autonomic states (Seamans and Floresco, 2022). Combined, these extensive literatures paint a picture of the ACC as deeply involved in the emotional regulation of behaviour. While there are many competing and overlapping theories of ACC function, such as the control of attention, contextually adaptive cognitive control, monitoring sensory streams, error detection, and the monitoring and control of emotional and autonomic states to name a few, I believe the theory advanced by Seamans and Floresco (2022) best captures the true function of the ACC in that it serves to impart representations of context with a kind of emotional ‘gain’, and that this 6 modulated, contextualized representation acts on downstream regions to ensure that actions are appropriate for a given situation or goal. The nature of neural representations in ACC While the representation of emotional states and actions has been comprehensively demonstrated, these are not the only factors encoded by ACC neurons. Indeed, the ability to encode a huge variety of different factors seems to be a feature of ACC neurons (Jung et al, 1998; Seo et al, 2012; Lindsay et al, 2018; Sachuriga et al 2021; Porter et al 2020; Bryden et al 2019; Cowen and McNaughton, 2007), and is perhaps a more general feature of cortical neurons, as demonstrated in other cortical areas as well (Fusi et al, 2013; Tye et al, 2024). In addition to motor correlates in limb and eye movements (Picard and Strick, 1996; McNaughton et al, 1994), studies in both primates and rodents have found that ACC neurons respond to sensory and mnemonic cues, especially those that signal motivationally relevant outcomes such as rewards and punishments (Cowen and McNaughton, 2007; Padilla-Coreano et al, 2016, Seo et al, 2012). This concurrent representation of multiple factors and modalities leads to a complex, dynamically varying encoding scheme. From a computational standpoint such an encoding scheme has several benefits in terms of the flexible representation of information in response to dynamic circumstances (Fusi et al, 2013, Tye et al, 2024). However, a consequence of this multiplexing of information is that it becomes extremely difficult to understand what these neurons are responsive to at any given point in time. By extension, this makes it difficult to draw reliable conclusions about exact functionality. This confound was demonstrated clearly in studies investigating working memory correlates in ACC. Neurons in the dorsolateral PFC of the primate exhibit persistent activity that maintains information throughout the delay period of working memory tasks. Persistent activity was also recorded from the medial frontal cortex of rats during the 7 delay period of a working memory tasks and it was presumed that this activity was similarly used to hold information (Baeg et al, 2003). However, subsequent work showed that much of the delay period activity could be attributed to the encoding of movement trajectories or poses the rats engaged in throughout the delay (Euston and McNaughton, 2006; Cowen et al, 2007; Euston et al, 2012). While working memory encoding in these neurons is still an open question, this example highlights the difficulties that arise when attempting to disambiguate representations of different information in ACC neurons. In rats, every decision must be expressed through actions, regardless of what the experiment seeks to study. Therefore, it is an absolute necessity to accurately quantify behaviour (or other task relevant factors) in order to make statements about the larger representational framework implemented by the ACC. Constructing Context I will use the term ‘context’ as a descriptor of overall situation or circumstance, the sum of all available information at any given point. In ACC, the complex multi-factor representations seem to align with this description. As suggested by Seamans and Floresco (2022), this is likely a consequence of the variety of inputs ACC receives; from cortical, thalamic, striatal, limbic and midbrain regions (Hoover and Vertes, 2007; Gabbott et al, 2005; Conde et al, 1995). Relevant inputs from all of these regions are integrated into a combined representation of overall context. This anatomy explains why ACC representations are so rich, containing information about a wide range of factors such as the environment, the task, emotional state and so on. The ACC Neurons that have been observed are exceedingly flexible, fluidly participating in many representations. While we might expect that consistent inputs from one region or modality should result in a consistent accompanying representation, this is not what is observed. Instead, every event is represented within some larger context. Encodings of any given factor is pushed 8 and pulled, shifted around in neural space according to their relevance to the overall context. This does not, in itself, imply that representing context is the region’s primary function, but it does go some way towards explaining why such a variety of information is represented in this region, and why individual ACC neurons are so seemingly multi-modal. Recording and visualising neural activity in the ACC The neural data utilized in our lab and the work covered here are electrophysiological recordings of neurons in rodents. These recordings are collected from groups of electrodes surgically implanted in rat ACC (Areas 24a and 24b), and the signals are carefully sorted to assign spikes of recorded firing to individual putative neurons. It is the collective activity, or ensemble activity, that is of primary interest, however, as the ensemble dynamics produce more stable representations than single neurons, and provide a better picture of how information is represented in the ACC. Visualising the activity of single neurons is relatively straightforward, as instantaneous firing rates can be calculated by binning spike activity at fixed time intervals and plotted as a series of raster plots. Viewing ensemble activity is more complex however, as gleaning informative trends from arrays of single plots is difficult and more complex temporal or spatial relationships contained within the ensemble are lost. We often plot the firing rates of individual neurons on separate axes of a multiple-single unit activity (MSUA) space. In this high-dimensional space, as neural recordings contain on the order of 10s to 100s of neurons, each point represents the activity of the entire ensemble at a single point in time. Clusters of points indicate common activity patterns, and following the progression of points through time yields a trajectory of neural activity evolving over a given time course. This MSUA space serves multiple purposes, as the matrix of binned firing rates that defines it is our primary input to downstream neural analysis in addition to allowing the combined visualisation of combined activity. As this space is high-dimensional, it 9 is by necessity compressed by scaling or a dimensionality reduction method to yield a low-dimensional projection; usually 2 or 3 dimensions for visualization. Building appropriate and informative low-dimensional projections is not trivial, and brings with it a significant degree of complexity and nuance that will be explored in greater detail in the subsequent chapters. This point is emphasized here to highlight the importance of visualisations in driving and enabling scientific intuition. While relying on visualisation alone can be misleading, our capacity to gain insight into complex phenomena is greatly enhanced by informative visual presentation over solely numerical measures. Defining and quantifying behaviour The understanding of the neural basis of emotion and cognition are closely linked to actions, as noted above. This is especially true in laboratory animals where emotional states and cognitive processes are often inferred from actions and behavior. What constitutes a ‘behaviour’ can be difficult to pin down. Behaviour can be defined in a number of different ways, and a specific framework is necessary for a principled investigation. Often the label ‘behaviour’ is approached in terms of goals or goal directed actions. Such an approach can also posit behaviours as strategies in response to a particular situation or task. Here, for practical reasons, we instead employ a much more restricted, operational definition of behaviour, based on directly measurable animal movements. Specifically, we define behaviour as changes in the animal’s pose, or equivalently the relative locations of body parts, evolving through time. In this descriptive paradigm, behaviours do not include the possible motivational goals or strategies, though these factors likely influence the neural correlates we record. Any investigation of behavioural representation requires the ability to adequately and reliably annotate behaviour. Traditionally, behavioural annotation has been done manually, by expert observers watching recorded video of behaving animals. Some ‘out-of-the-box’ solutions exist, commercial software with 10 accompanying hardware built for detecting specific behaviour in a single use case, but for freely-moving animals or other flexible behaviour applications the gold standard has remained manual annotation until very recently. Manual annotation brings with it a host of downsides however, as human annotators have difficulty maintaining performance and accuracy, particularly across long sessions, and subtle variations in behaviour may be unreliably annotated or totally missed even by expert observers. In addition, observation and annotation can be highly subjective, and there is often substantial variance between human annotators. Machine learning approaches have been the answer to many of these potential issues. In their 2020 paper, Sturman et al (2020) demonstrated with their own examples and with reference to the growing body of machine learning behavioural annotation techniques that their performance was at the very least comparable to expert observation in extracting ethological behaviours. In 2018, Mathis et al (2018), published their machine learning tool, DeepLabCut, which is a lab animal focused adaptation of DeepCut (Pishchulin et al, 2016), a computer vision approach to movement and pose tracking for human subjects, which is now the standard for the markerless tracking of experimental animals. In their review of behavioural annotation algorithms, Mathis and Mathis (2020), summarized an ever-growing host of techniques and tools. Indeed, there has been an explosion of approaches developed for a variety of uses in neuroscience, each with their own pros and cons and considerations. A key one of those considerations which is often overlooked both by machine learning approaches as well as manual annotation is a means to ascertain the relevance of externally defined behaviours. There is a need for our purposes of some general framework, or space to compare behaviours, whether defined by an expert observer, or automatically, and to evaluate how they relate to neural state. As mentioned, the particulars of specific approaches to behavioural annotation can have a profound impact on the kind and scope of behaviours available to downstream analysis. These constraints, and the complexity of neural signals we are interested in investigating necessitates that we are picky with our 11 choice of behavioural annotation technique. Behaviour after all, serves double duty in our experimental framework: It is a precisely observable task factor with known correlation to neural activity, and it is also an external indicator of internal state, specifically the emotional valence of interest in our experimental tasks. Encapsulating Valence Experimentally Like movements, it is important to be able to study ‘emotional states’ in laboratory animals. The studies and investigations covered in this report focus, for the most part, on a specific experimental paradigm from our lab designed to evoke distinct emotional reactions in rats. This paradigm is referred to as the ‘3-valence task’ and is a variant of a classic conditioning task, where an animal is trained to associate a stimulus of some kind with a particular outcome. In many simpler versions of this task, the outcome is solely appetitive, with some tone, light, smell, or other physical stimulus being paired with a food reward. In the 3-valence task, this conditioning is performed with three separate emotional valences. Animals remain in a single physical enclosure where they are given trials of a stimulus paired with different, motivationally-specific outcomes. Each stimulus is a distinct tone, with a learned association to one of three outcomes: an aversive outcome in the form of mild foot shock, an appetitive outcome in the form of food pellet delivery, and a neutral outcome (no outcome). The trials are separated by long inter-trial intervals (~50s), but are delivered in blocks, with a block containing trials with a single tone/outcome pairing; each block of trials therefor constitutes a single ‘emotional context’. With our goal of gaining a deeper understanding of how ACC neurons and ensembles represent emotional information, the 3-valence task serves as a well-suited avenue of investigation. This 3-valence task is the primary demonstrated use case for the tools and techniques contained herein, although other related use cases and alternate applications will be also be discussed. 12 In prior work utilizing this experimental task, Caracheo et al (2018) reported that ACC ensembles formed highly distinct clusters in MSUA space for each of the emotional contexts. Remarkably, the ensembles remained in the same state throughout the entirety of each block, including the tone periods, outcomes, as well as the long inter-trial intervals. The neurons then abruptly switched to a new stable state during the first tone presentation of the subsequent block and again remained in this state until the next block of trials began. As the most significant thing separating blocks of trials was the valence of the outcomes, this suggested that the ensembles formed representations of the unique physiological or emotional reactions evoked by the different outcomes in each emotional context. It should be noted that while these emotional states are a strong driver of ACC ensemble dynamics, they are not the only ones. Ma et al (2014, 2016) observed ensemble representations responding to changes in physical context, as well as to changes in task structure or rules. Similar to emotional context, these modulations were expressed by shifts in the representation of task factors, events, or behaviours. Furthermore, the type or pace of contextual change is also reflected in ensemble dynamics. Changing contexts by delivering a tone of a different valence or placing a rat in a new physical enclosure causes an abrupt shift (Hyman et al, 2013; Caracheo et al 2018). Conversely, when a change in the task rule is inferred through a trial-and-error process, the shift in ensemble dynamics is more gradual. However, the gradual shift still nevertheless still arises from abrupt changes at the single neuron level, it’s just that these shifts are asynchronous across the population (Seamans and Emberly, 2020; Russo et al, 2021). In a detailed analysis of shift dynamics, Ma et al (2016) found that the total ‘responsivity’ of the ensemble for any event was a fixed quantity, that gets re-allocated in each new context. This redistribution was proportional, with neurons shifting in concert to share the representational burden apace with shifting context. In other words, in terms of net firing contributions across the population, the ensemble representation remains exceedingly stable across contexts, so long as neuronal identities are ignored. 13 Outstanding Questions Equipped with these observations we are left with a series of questions about the underlying representational changes responsible for these shifts in ensemble activity that we see in MSUA space. Are ensemble dynamics actually reflecting emotional states, or are the changes we observe driven by other factors, such as changes in expressed behaviours? For example, it is possible that shifts in the 3-valence task occur because the behaviors are block-specific and ACC neurons track each of these behaviors via different patterns of activity. If I can overcome these technical issues and clearly establish emotional valence signals in ACC ensemble activity, then it opens the door to much more profound questions. In particular, what is the fundamental nature of emotional state representation and how do these representations differ from representations of stimuli or actions? Bringing it all together The ACC has extensive connections to both emotional/autonomic pathways of the brain and motor pathways (Gabbot et al, 2020; Burgos-Robles et al, 2017, Hoover and Vertes, 2007, Leow et al, 2022; Brokett et al, 2020; Takeuchi et al, 2022; Gabbot et al, 2020). Likewise, stimulation of the ACC drives emotional/autonomic states and movement, whereas lesions remediate pathologically elevated emotional/autonomic reactions to internal states of pain or anxiety. Finally, both functional imaging in humans and electrophysiological studies in animals have established a link between ACC activity and emotional states, actions and behaviour. As our previous work has shown (Caracheo et al, 2018; Lindsay et al, 2018), while both emotional state and behaviour are strongly represented, these representations are not alike in kind. At this point, our theory is that emotional state drives the reconfiguration of behavioural representations in ACC, and that 14 this is indicative of the primacy of emotion in ACC function. If, as suggested by psychologists (Fridja, 2012), emotion’s primary role is as a driver of appropriate actions, then the modulation of action representations by emotional state should be an expected part of the cognitive machinery of the ACC. Overall Hypothesis: I hypothesize that emotional state is not just one part of overall representation by the ACC, but rather is the primary driver of the contextual modulation of other signals. In other words, ACC neural dynamics are primarily organized according to emotional state, and furthermore this state determines how any given cue, action, or behaviour is encoded. This in turn lends strong support to its proposed output function in driving the expression of emotionally motivated behaviours. Laying out our approach In the following chapters I will undertake to answer some of these questions. The work will be roughly divided into three main sections, Chapters 2, 3 and 4, followed by a recap and overview of what we have learned. To facilitate the thorough investigation of behavioural representation in ACC it is necessary to first build a behavioural annotation tool suited to our experimental and analysis needs. Chapter 2: A technical report on our unsupervised behavioural discovery tool, HUB-DT, provides an in-depth technical breakdown of the tool in addition to some commentary on the motivation for building the tool and its application. The tool’s application to data and some use cases will also be briefly discussed. Armed with that tool in hand, the following chapter delves into the primary use case for HUB-DT. With the resulting complete behavioural descriptions to accompany our electrophysiology data, I then embark on an in-depth analysis of how behavioural signals are reconfigured and modulated by emotional context, at the level of the individual neuron as well as the ensemble in Chapter 3: a research paper focusing on the reconfiguration of behavioural signals by emotional context. Finally, I will elucidate the properties of the 15 representations of behaviour and emotional state in ACC, their geometry, and functional insights into this modulation by context in Chapter 4: a combined technical exploration of novel analysis and a research paper detailing the results of its application. As the story of emotional modulation in the ACC develops through these chapters, it will be necessary to revisit some topics and recontextualize in light of the pertinent details of each study. While each of the chapters presents a stand-alone account of a tool or study, each contributes to the through-line of exploring the neural representations of behaviour and emotion and how they relate in ACC. Bridging the fields of machine learning and neuroscience As a final note before delving into the details of specific work, I would like to offer some additional insight into my motivation for undertaking these works. In research, the answers we can find through experimentation and analysis are only as good as the questions we ask. The questions we can ask, are directly determined by the tools at our disposal. There is a vast repository of analysis techniques and expertise spread across the scientific community, but as individual scientists we are limited by our own experience, our own bandwidth for the appreciation and understanding of innovation. This causes there to be a latency in the adoption of tools and techniques from other fields. The field of artificial intelligence and machine learning is one that has undergone enormous change in recent years; progress is being made by leaps and bounds. This progress has applications with considerable overlap with neuroscience, as I will attempt to demonstrate through the work presented here. That this overlap exists should come as no surprise, as the origins of AI lie in efforts to understand and replicate the biological brain and its function. Since those early days the field has expanded considerably, with applications and techniques well beyond those biological underpinnings. However, as the field has expanded, particularly in recent years, this relatedness has re-emerged, both in form and function. With 16 artificial neural networks proving useful in their form, as approximations of biological networks, as well as the functions they can perform as part of data analysis. As someone with a foot in multiple camps, with a background in both biology and computer science, it seems a natural progression to facilitate, or accelerate the dissemination of techniques across the fields. The adaptation and application of tools from machine learning has allowed us to ask new questions, and gain new value from experimental results. As a cautionary note, I add this. Given that there is a limit to our own experience as scientists, and our capacity to learn and apply skills in a research setting, it can be tempting to pursue the best performing, or most universal tool at the exclusion of others. This is not always a fruitful pursuit, as often what is most valuable is a tool or technique that lets us ask a specific question that we have not been able ask before. A case study in applied machine learning In the chapters that follow I focus on the use of particular tools and analyses, adapted, built up and modified from across a variety of fields on this specific case, the emotional modulation of behaviour in the anterior cingulate. The properties and complexities of the underlying representations, and understanding them through electrophysiology in many ways paves the route to this analysis pipeline and the variety of applied machine learning techniques used therein. But I hope by the end you will agree that this collection of studies is, at its heart, a template for applied machine learning in this field. Both AI/ML and neuroscience are constantly progressing. The specific techniques and their applications are changing, and there is a burden of work in demonstrating the appropriateness of a given technique and the kinds of questions that can be asked with it. However, progress is found in making connections, in seeing concepts and principles emerge across multiple applications and fields. This is by no means a revolutionary statement, nor is it one that I expect will generate much resistance. But I feel it is worth 17 stating; There is enormous value in bridging the fields and trying out new techniques, new analysis, new insights from across the scientific community. 18 Figure 1-1 Figure 1-1. Exploring Representations of Emotion and Behaviour in ACC. Schematic overview of the flow of data through the tools and analysis in this group of studies. Data input comes in the form of video (stacked two-camera images), task markers, and multi-electrode recordings. A) HUB-DT: Hierarchical unsupervised behavioural discovery tool. An unsupervised method for complete behavioural annotation from video. B) Reconfiguration of behavioural signals in the ACC based on emotional state. Collection of single neuron and ensemble analyses conducted using combined datasets of ACC electrophysiology recordings, experimental and behavioural labels. C) The neural trajectory point net. A geometric neural network model and accompanying topological data analyses to characterize the common and functional properties of emotion and behaviour representations in ACC across experimental sessions and subjects. 19 Summary of Research Goals: We posit that information, in the form of neural representations, in ACC is primarily organized according to emotional state, and furthermore, this state determines how any given cue, action, or behaviour is encoded. We hypothesize that this feature of encoding serves the proposed purpose of the ACC, the emotional modulation of behavioural output. 1.) Build a behavioural annotation tool that detects and identifies behaviours in an unsupervised and unbiased manner, and facilitates comparison with manually defined behaviour and electrophysiology data. 2.) Disentangle and compare, at the level of single neurons and ensembles, the neural states associated with behaviours emerging within and between different emotional contexts. 3.) Discover the common features of neural representations in ACC that are informative of emotional context and behaviour, their geometry, spatial, and temporal dynamics in order to gain functional insight into contextual modulation. 20 Chapter 2: HUB-DT: A tool for unsupervised behavioural discovery and analysis Introduction While unsupervised behavioural categorisation is relatively recent to the field of neuroscience, there is a rapidly growing body of tools and techniques to use. As a first step, DeepLabCut (Mathis et al, 2018) is now commonly used to define the positions of body parts of interest in each frame of a video, providing straightforward and reliable limb tracking through time. While the resulting output from DeepLabCut, a set of limb coordinates for each frame of video, is not behaviour, various tools have been developed to translate limb positions through time into behavioural categories. These include: DeepBehavior: Automated Analysis of Behavioural Kinematics (Arac et al 2019). VAME: Segmenting behaviour using latent space representations and a HMM (Luxem et al 2020). MoSeq: Mapping sub-second structure in mouse behaviour (Wiltschko et al 2015). B-soid: Unsupervised behaviour identification (Hsu et al 2021), and Motion Mapper: Mapping stereotyped behavior in fruit flies (Berman et al 2014), to name just a few. Each approach has advantages and disadvantages, explored in more detail below, that the user must consider with regards to their specific application and question. ‘Behaviour’ in this context is often treated in a general and nonspecific manner, and what defines a behaviour can depend on the particulars of the approach. We would advocate for an approach that leverages the power of machine learning to exhaustively characterize all the fine motor movements produced under various, closely-related conditions. One drawback is that this is only possible by tracking 21 the fine movements of multiple limbs, which necessitates either incorporating inputs from multiple camera views to avoid occlusions of a limb in any given frame, utilizing 3D depth imaging or motion capture, or using a model to infer the occluded features. Even in cases where an existing tool or method is a good fit for analysis on a task, there is always tuning and parameterization required. This can be significant in terms of time investment. Indeed, in practical terms, the importance of usability, modifiability, and computational cost and efficiency in the design and adoption of a particular tool or technique cannot be overstated. It is important to tailor the analysis methods to the needs of the user and the goals of the study. An additional concern is how to balance the desire for ‘a priori free’ behavioral detection with interpretability of the detected behaviors. To address this issue, one should be able to directly compare automated behavioral labels with human curated behavioural labels in a common space or frame of reference. But, even if automated and human curated behavioral labels agree, the behavior may not be what it appears. Consider for example the case of fear conditioning, a commonly used task used to assess fear memory in rodents (Guistino and Maren, 2015; Jhang et al, 2018; Quinn et al, 2008). Freezing in response to a conditioned cue is evidence of fear learning. But from the perspective of observing behaviour without additional context, there is ambiguity between specific fear cued freezing and simple lack of movement. One must therefore consider whether the behavior is actually biologically relevant to the animal. One route to assess whether the animal may view a detected behavior as discrete or meaningful would be to check whether a specific pattern of neural activity emerges whenever the labelled behaviour is detected. To facilitate this type of comparative analysis, one should also be able to directly compare behavioral labels with neural data in a common frame of reference. As mentioned, our novel behavioural discovery pipeline, HUB-DT, was built to provide unsupervised behavioural classification in light of the constraints discussed above. It was also designed to address our 22 specific use cases that typically involve rats performing free-ranging behaviours in relatively unconstrained environments while we record the activity of tens to hundreds of neurons in the frontal cortex. One challenge that is notable in the frontal cortex is that these neurons are extraordinarily multi-modal and flexible in terms of how they encode seemingly static events in the world (Seamans and Floresco, 2022; Ma et al, 2013; Caracheo et al, 2018; Sachuriga et al, 2021; Fusi et al, 2013). As a result, HUB-DT was designed to provide extreme flexibility in the way behaviours are discovered while also incorporating some basic analysis techniques that we have found to be effective in connecting free-ranging behaviors to the neural ensemble activity. HUB-DT allows traditional behavioural annotation, through manual viewing of video, alongside ‘parameter-free’ (without the need for pre-defined behaviours or time-periods of interest) behavioural discovery in discrete steps, maintaining the connection to human-sensible categories and interpretability. It applies the same basic approach utilized by Motion Mapper (Berman et al, 2014), fitting wavelets to the frequency components of individual limb movements. It then employs various clustering techniques (shared across several of the discussed tools) to find the unique constellations of limb movement frequencies that consistently arose within a session (i.e. “behaviours”). This tool enables us to discover and label behaviours in our experimental tasks, and to perform comparative analysis with manually annotated behaviours as well as simultaneously recorded electrophysiology data. HUB-DT: Motivating this Report HUB-DT is a complex piece of software, that implements a number of analysis techniques ranging from simple statistical methods to neural network approaches. We present this report in an effort to provide sufficient technical detail of the tool’s design and function for those interested, outside of its detailed application to neuroscience data and questions in our lab which is explored in subsequent publications. What follows is a technical breakdown of the construction and function of the HUB-DT tool, as well as a 23 brief exploration of the motivation behind its features and development. We will briefly describe how to manually track annotated behaviours and how it can be used for unsupervised behavioral discovery. HUB-DT allows the user to discover behaviours at varying levels of granularity and to compare discovered behaviours to manually labelled behaviours in a common space. We will highlight how the unsupervised behavioural discovery process is able to detect subtle differences in behaviours that are unfeasible for human observers to reliably annotate, and how the model and parameters can be adjusted to provide the best correspondence between neural activity and discovered behaviours. We will also discuss the in-built methods for interrogating the behaviours detected by HUB-DT, as well as methods for comparative analysis with neural data. We will also provide a brief overview of the tool’s graphical user interface, its features as well as a summary of its use and practical considerations. A more complete user guide will be available accompanying the HUB-DT Git repository (https://github.com/Loken85/HUB_DT). To provide practical illustrations of how HUB-DT works, we will describe how it was used to identify the behaviours of rats engaged in a conditioned-outcome task where outcomes were either appetitive, aversive or neutral in different blocks of trials (Caracheo et al 2018; Lindsay et al 2018; 2024). HUB-DT was able to detect block-specific behaviors and to divide neuronal activity into the portions related to discovered behaviors and the portions putatively related to the affective states evoked in each block of trials. We will also describe how HUB-DT was used to discover unique sets of behaviours expressed by rats as they transitioned through a morphine administration and withdrawal procedure. The results showed that some of the drug-associated behaviours detected by HUB-DT were those commonly used by human observers to define the various stages of addiction as well as other behaviours not previously described in the literature. 24 A rich ecosystem of existing tools and techniques There are a plethora of similarly motivated tools (detailed below) designed and built to extract and label behaviour, which at a surface level, pursue the same goal: automated behavioural annotation for use in experimental analysis. However, these tools are all implemented differently, have significant differences in function and scope, and as a result are optimal for the specific use cases for which they were designed. Here, as a review of the current state of the field and as motivation for the development of a tool for our specific use case, we include a brief survey of some of the existing methods, the basics of how they approach and achieve behavioural classification, and some use cases and observations. DEEPBEHAVIOUR (Arac et al 2019) is an end-to-end kinematic analysis pipeline, and represents an early approach in the field to using applied machine learning to extract behavioural data. Input comes from a multi-camera setup with high framerate and precise alignment, and a trained neural network (specifically a Convolutional neural network or long-short-term memory recurrent neural network) is used to provide markerless tracking of features from the input video. Features in this context are bounding boxes for limbs or digits of interest. These tracked features are then transformed into trajectories, which are clustered using a technique called dynamic time alignment kernels. This allows for flexible clustering, both supervised and unsupervised. DEEPBEHAVIOUR represents a combined computer vision approach, using different neural network architectures for analysis of different tasks and species. The framework enables in-depth trajectory analysis of these specific behaviours, and these identified kinematics provide the basis for downstream clustering/classification. This is a highly task specific approach. While the components can be more generally applicable, their use in an analysis pipeline requires considerable modification and tuning for any given task. In particular, training the Neural Networks and determining an appropriate space and algorithm for clustering/classification can be time and resource consuming. 25 Motion Mapper (Berman et al 2014) is a spectrographic projection-based technique for identifying and analysing behavioural stereotypies, initially in fruit flies, and subsequently applied to some other lab animal species. As originally conceived, input comes in the form of multiple camera views, which are aligned and used to perform postural extraction from raw video. These extracted postures are passed through a series of projection steps, where they are transformed into points in a high-dimensional behavioural space. This projection involves transforming the data into frequency space, and then multiplying the data by a series of Morlet wavelets, resulting in spatial data quantized across a set of temporal ranges. This behavioural space is then reduced in dimension to 2-D (the remarkable degree to which information is preserved in as few as two dimensions is covered at length in Berman et al, 2014) via a dimensionality reduction technique known as t-SNE (explained in greater detail below) (van der Maaten and Hinton, 2008). This reduced behavioural space is then clustered via the watershed transform (Beucher and Meyer, 1993): the 2-d space is treated as a 3-d surface where height is determined by the density of points. This surface is iteratively filled at increasing depth, and the distinct watersheds that result from this filling are labelled as clusters. Spectrographic projection is a key feature of this approach. This enables multi-resolution temporal dynamics to be represented in a combined space, encoding changes in pose segments (roughly equivalent to features as used in other tools) at multiple time scales. The resulting behavioural space is slightly biased towards periodic changes in pose within those frequency ranges selected as wavelets. In the pursuit of behavioural stereotypies, this can be beneficial, as one would expect stereotyped engrams to be at least somewhat periodic. This process of explicit postural extraction combined with spectrographic projection allows for in-depth trajectory analysis of behaviour space, i.e. location within the space through time gives a trajectory of dwelling and transitions between behaviours. Finally, the watershed transform as a means of clustering is essentially non-parametric, allowing for easy and consistent application. However, this can be an issue when the density space is less clearly separated: 26 Specific to our application, fly behaviour is considerably more stereotyped and frequency-locked than rodent behaviour. As a result, when the watershed is applied to clustering the density space of rodent behaviour, the results are often poorly clustered. VAME (Luxem et al 2020) uses variational autoencoders, a specific neural network architecture, to produce a behavioural latent, or embedding, space (such spaces are usually lower-dimensional representations or manifolds of the inputs). These autoencoders are built on recurrent neural networks, which use fixed-length sequences of positional data (from annotated video, marker based tracking, or other means) as input. Autoencoders generate a latent space via a process of constrained representation: the network has limited neurons with which to represent the input space, which trains the network to compress and align the representation to accommodate this limited space. The behavioural space encodings that result from this form a lower dimensional manifold, representing behaviour. VAME then uses a set of Hidden Markov Models (HMMs) to generate state sequences within this behavioural space, which quantizes the dynamical system as a discrete-state continuous-time Markov chain. This process is effective in identifying short behavioural motifs with common transitions such as phases of locomotion, progression in grooming, etc. The approach is appropriate for open-field use where subtle variations in these motif frequencies are of interest: investigating changes in walking patterns for example. VAME is however, relatively computationally expensive. Getting the technique up and running requires training of a set of neural networks and HMMs on any given data set, both of which require significant tuning. There are considerations resulting from the fixed length sequence input: the temporal signal is biased towards short fixed length sequences at both the autoencoder and HMM steps. The latent space is generated from a sizable complex neural network, and the state-sequence outputs are purely probabilistic. This combined complexity can make it difficult to interpret the contents and characteristics of a given output state. 27 B-SOID (Hsu et al 2021) is a ‘frame-difference’ based unsupervised behavioural categorization tool designed to be used with rodents in open field experiments. The input space is generated from frame-difference measures applied to annotated video: the derivatives of position, angle, and relative pose (arrangement of tracked features) distance. This input set is generally fixed, selected by extensive information measure testing for the intended use case. This set of feature derivatives is then embedded in a reduced dimension space via the UMAP algorithm (McInnes et al, 2020; covered in greater detail below), reducing it to two dimensions to allow the application of density-based clustering. A hierarchical density-based clustering algorithm called HDBSCAN (McInnes et al, 2017; also explained in greater detail below) is then used to perform unsupervised clustering on this density space, resulting in a set of clusters as putative behaviours. The tool is, by default, setup for use with a single bottom-up view camera, but this is modifiable. The critical component of this technique is the use of frame difference measures (the derivatives of position, angle, and relative pose) as the full input space. This enables the direct readout of kinematics from the output clusters, but means the clusters are defined across only a single fixed timescale. This timescale is dependent on framerate and the parameters of the ‘frameshift’ operation performed by the tool, and the resulting performance can be impacted by noise and by slow framerates (by default, this is set for 50 fps). For reference, our use cases involve video at a range of framerates from 15 to 60 fps. The choice of input space and framerate tends to bias B-SOID towards short-sequence based behaviours: this is useful for data sets with large numbers of repeated sequences, as is common in many open-field applications, but less well suited for small datasets with high diversity where local structure may be more important. This can impact downstream behavioural selection, and may necessitate extensive modification if the input data is less suited to the design parameters. An additional feature of the tool is propagating labelled behaviour across datasets. The creators of B-SOID demonstrated that training a Random Forest (Hastie et al, 2011) to reproduce clustering labels 28 works well (this is also true of our approach, and we have adopted a similar procedure for propagating our discovered behaviours across datasets). MoSeq (Wiltschko et al 2015) is an unsupervised method designed to parse mouse behaviour into a set of behavioural syllables (usually sub-second behavioural motifs). Unique among the approaches mentioned here, MoSeq takes as input 3-D depth images/video, providing direct 3-D tracking without the need for multiple cameras. Subjects are extracted from the background, resulting in location agnostic 3-D models of single or even multiple mice. Similar to Motion Mapper, and indeed to our own tool, MoSeq utilizes wavelet projection to quantize behaviour across a set of temporal scales. MoSeq then uses a probabilistic time-series model, called an ‘autoregressive hidden Markov model’, or AR-HMM to segment behaviour into a set of behavioural motifs. In use, MoSeq provides a means to extract and label behavioural syllables, as well as extensive tools for analysing the transitions between behaviours which was the focus of the research which motivated the creation of the tool. Like all the techniques covered in this brief summary, there are some caveats and considerations to take into account with its use. Working with 3-D depth directly removes the need for calibration of multiple cameras, but does impose some limitations on the experimental space and data collection, particularly if electrophysiology or other data is being simultaneously collected. The AR-HMM approach taken by MoSeq is relatively computationally expensive and parameter dependent, and like any of these techniques will require adaptation and tuning for individual use cases. Fundamentally, by its design, MoSeq provides an alternate approach to the extraction of behaviours, defining putative behaviours directly from the state transitions modelled by the HMM rather than from the structure of the behavioural space. 29 Discovering Behaviour for Comparative Neural Analysis As discussed, HUB-DT is built on a foundation of elements drawn from these existing tools. In this section, we will provide a detailed explanation step-by-step of how HUB-DT generates discovered behaviours from input data and enables comparative analysis with neural data, as well as our motivations for using the specific algorithms and techniques that make up the tool. Extracting Pose: Annotating limb position from multi-camera recordings The pipeline, which is illustrated in Figures 2-1, 2-2, 2-3, 2-4, begins with data collection to provide input for behavioural discovery. We utilize video cameras for this input which, with appropriate timing, allow simultaneous electrophysiology recording. In our case, the video and electrode signals are jointly recorded through a single source giving precise alignment, but any alignment within the tolerance of the video framerate is sufficient. This raw video is then pre-processed by DeepLabCut (Mathis et al 2018): a supervised method for markerless tracking of lab animal features of interest from video (Figure 2-1: A-B) resulting in a set of feature positions for each frame of video. As noted, single or multi video camera approaches are common across many of the tools in the field. Alternatives are depth cameras (or other depth measuring devices such as multiple infrared beams) or physical tracking where some sensor is placed on the animal. Each recording modality presents its own practical concerns in terms of experimental procedure and enclosure design. 30 Figure 2-1 Figure 2-1. The HUB-DT Pipeline, Steps A-C. A) Camera placement for an example setup. Markerless tracking requires consistent lighting and minimal occlusion. Here, two cameras are use to provide pseudo-3-D for more accurate tracking. B) Feature Tracking. The video streams are stacked and passed to DeepLabCut (DLC) for feature annotation. The location of each feature of interest (body part) is shown in the example frame by the coloured dots. C) Output. Tracking for a set of 50 frames for a single feature of interest. Absolute location is subtracted out, and each coordinate (X, Y, Z) shows the features change in position relative to the animal’s centre of mass. 31 Behavioural Space: Projecting extracted pose into a spatiotemporal manifold The output of DeepLabCut provides frame-by-frame positions (in 3-D) for our features of interest (Figure 2-1: C). As previously discussed, instantaneous body part locations (often collectively referred to as pose) does not in and of itself constitute behaviour. Rather, by our definition, behaviour is changes in pose that evolve over a range of timescales. Therefor, in order to capture behaviour both position and time components are necessary, specifically time components at multiple scales. Traditional fixed time period methods (like those used in many of existing tools in the field) have several key shortcomings. This is discussed at length by Berman et al (2014), in their Motion Mapper paper, but here we will cover them briefly. Notably, fixed time period inputs restrict temporal information to a specific scale. This discards multi-scale interactions across and within features that are present in many ‘typical’ behaviours. For example, rodent grooming behaviour is often indicated by paired high-frequency movements in the forelimbs, while the positions of the hindlimbs and other body parts like the snout and nose evolve more slowly. To completely describe these interactions, temporal information needs to be captured at multiple scales. This does not imply that fixed temporal scale methods are unable to categorize behaviours like grooming, but rather that the descriptions those tools generate of those behaviours may be incomplete. To capture motion at multiple temporal scales HUB-DT uses spectrographic projection via Morlet wavelets to capture and discretize spatial and temporal features together in an expanded behaviour space, similar to Motion Mapper (Figure 2-2: D). Morlets, which are complex gaussians in the frequency domain, bias the space towards periodic movements, like those found in many expected behaviours such as locomotion, grooming, etc. 32 Figure 2-2 Figure 2-2. The HUB-DT Pipeline, Steps C-E. C) Inputs. Example tracked feature, ready for wavelet projection. D) Wavelet Projection. The feature is transformed from the temporal domain to the frequency domain by applying the Fast Fourier Transform (FFT). The transformed feature is then convolved with a series of Morlet wavelets, at widths set by the frequencies over which we are attempting to capture behaviour (these frequencies are adjustable). The real component of the convolution (the amplitude of response to the wavelets) is then transformed back to the temporal domain by the inverse Fast Fourier Transform (IFFT), resulting in a set of wavelet amplitudes. E) The ‘Behavioural Space’. Performing wavelet projection on the whole set of features produces a full set of wavelet responses (wavelet amplitudes). Together, these form the behavioural space, with each point (corresponding to a single frame of the input) having a coordinate for each dimension (features * XYZ * wavelets) of the space. 33 The end result of wavelet projection is a dataset where each point, associated with a single frame of video, is embedded in a high dimensional spatiotemporal manifold. The dimensions of this manifold are the response amplitudes of each of the features (and each of their 3 coordinates) to each of the wavelets used in the projection. The exact dimensions depend on the number of features (tracked body parts) and wavelets chosen, but for the pictured example the resulting manifold is 5 (wavelet frequencies) by 9 (features of interest) by 3 (1 for each dimension of the tracked coordinates of each feature, ie X Y Z) (Figure 2-2: E). This space provides a complete description of the motion of tracked features, but its high number of dimensions renders it unsuitable for the application of many unsupervised clustering methods: this is due to both computational efficiency concerns, as well as to the ‘curse of dimensionality” which reduces algorithmic efficacy due to the burden of representing possibly uninformative dimensions during learning (Hastie et al, 2011). Complex learning algorithms like neural networks partially overcome this shortcoming by learning latent space representations of the data within the hidden layers, but in the interest of interpretability and computational resources we opted to perform dimensionality reduction prior to performing clustering. Dimensionality Reduction and Density Maps Dimensionality reduction is often carried out as a first pass in data pre-processing via Principal component analysis which yields a sequence of uncorrelated projections (linear approximations) of input data ordered by variance. A top subset of these projections can be used as a lower dimension approximation of the data preserving the bulk of the information. This reduced space is useful in identifying global attributes and trends in the data, but is not necessarily appropriate for cases where the information of interest is contained in local distributions of variable density, as is the case for our 34 behavioural space data. There are a number of dimensionality reduction methods that are good candidates for preserving the information in the behavioural space, and here we cover a few that are implemented in our pipeline. t-SNE: An alternative to simple component analysis is to use an embedding method like t-distributed stochastic neighbourhood estimation (t-SNE) (van der Maaten and Hinton, 2008). t-SNE produces a lower dimensional (often as low as 2 or 3) embedding of the original data preserving proximity in the reduced space. This is achieved via modeling similarities in the input and output spaces as probability distributions (a series of gaussians in the input, and a t-distribution in the output). The distribution choice biases the embedding to preserve local structure (density, multiple scale relationships, manifold membership) in the data at the expense of global verisimilitude (as compared to other embedding methods that bias the resulting embedding in other ways). Base t-SNE is parameterized by a single parameter, perplexity (a continuous analog to k nearest neighbours) which defines the set of points over which the algorithm will attempt to preserve distances. t-SNE’s suitability to producing low dimension embeddings of behavioural space is explored at length by Berman et al, in their Motion Mapper paper (Berman et al, 2014). Application on our rodent data was similarly successful, although there are some drawbacks with its use as part of a data processing pipeline. It is relatively computationally expensive (even on a modest data set) and is transductive, meaning it cannot be used to project new data into an already calculated embedding. Much work has been done on improving t-SNE in recent years (van der Maaten et al, 2014; Linderman et al, 2017), and here we use the openTSNE package that utilises approximate neighbourhood calculations, interpolation, and multi-phase optimisation to greatly improve its performance, as well as providing a means for embedding new data. The structure of the embedding is visualised via a density map, showing the distribution of data in the reduced space. 35 UMAP: Uniform manifold approximation and projection (UMAP) (McInnes et al, 2020) is another embedding method which we can use to produce a lower dimensional (again for our purposes, as low as 2 or 3) embedding of the original data, as is demonstrated by Hsu et al, in their work on B-SoiD (2021). UMAPs’ approach shares some similarities with that taken by t-SNE, but follows a different path to optimize the match in structure between the data and its low dimensional representation. UMAP first constructs a ‘fuzzy topological representation’ of the input data, and this topology codifies the local structure of the data in its native high-dimensional form. Note, this summary statement conceals a swathe of algebraic topology methods which are used to justify and perform the construction of this representation (those interested in the process should refer to the UMAP publication: McInnes et al, 2020). Then UMAP attempts to optimize the fit (by cross-entropy) between a low-dimensional approximation of the topology with its high-dimensional original. Again, in practice UMAP utilizes a number of approximation techniques, and optimised initialisation steps to render the process computationally tractable. Similar to t-SNE, UMAP is parameterized by the number of neighbours used to calculate local structure. Adjusting this value changes the locality of the implied topology, essentially biasing the output to preserve structure at a particular scale. UMAP also allows control of the local density of the low-dimensional approximation via a minimum distance parameter. This has implications for downstream clustering, and allows for further fine-tuning of the output space. The UMAP package provides a scalable and relatively fast implementation, and again its output can be visualised via a density map of the data in the reduced space. For practical purposes in constructing an analysis pipeline these two methods are often interchangeable, although care should be taken to account for each methods’ in-built biases, as mentioned above. In HUB-DT, the high-dimensional behavioural space data can be projected via either technique (or indeed other dimensionality reduction techniques) before being passed to further processing (Figure 2-3: F). 36 Figure 2-3 Figure 2-3. The HUB-DT Pipeline, Steps E-G. E) The full behavioural space. Output from the wavelet projection is embedded into a lower dimensional space to make it more suitable for unsupervised clustering. F) Embedding into Lower Dimensions. Dimensionality reduction is applied to the behavioural space data to create a low dimension embedding. The different methods (pictured) produce different embedding, which may affect downstream clustering. A combination of method selection and parameter tuning are use to generate an appropriate embedding for a given dataset. G) Density Map. The output from dimensionality reduction is a 2-D embedding, which is visualised here as a density map (This density map is a gaussian kernel density estimate over a uniform mesh of size: sqrt points / 2). Colour in the map indicates the relative density of points in the embedded space (Bright yellow corresponds to the areas of highest density). 37 Hierarchical Unsupervised Clustering The resulting density maps from performing dimensionality reduction on the behavioural space are useful for visualising the structure of behaviour across the whole dataset (Figure 2-3: G). Areas of high density show patterns of motion that occur frequently, and/or have low variance, ie motions that are highly stereotyped. Conversely, areas of low density correspond to motion patterns that occur infrequently, or have very high variance. We use this density landscape to extract structure from our data, segmenting the density map into clusters. This divides our data into a set of putative behaviours in an unsupervised way. DBSCAN: Density-based spatial clustering with applications of noise (DBSCAN) (Campello et al, 2013) is a flexible clustering technique that does not restrict clusters to be of any particular shape or distribution, rather clusters are separated from each other and from non-clusters via the concept of core samples (neighbourhoods of points in high density areas). Core samples form the core of clusters, and non-core samples that are within a given distance of a core sample form cluster fringes (distance here is a measure of relative density, defined as mutual reachability distance). Points further away are considered noise. Canonically, DBSCAN enforces clustering at a single density cut-off, the parameter epsilon, but by using a hierarchical approach DBSCAN can be extended to provide more complete and flexible cluster assignments. HDBSCAN: A hierarchical extension of DBSCAN, as proposed by Campello et al (Campello et al, 2013). We use the HDBSCAN package (McInnes et al 2017) which modifies DBSCAN by constructing a minimum-spanning tree of reachability distances. This tree is converted into a hierarchy of connected points by iteratively merging points based on that reachability distance, producing a single linkage tree of the dataset. As opposed to a technique like DBSCAN, which slices this linkage at a flat value to produce a cluster labelling (any lone points above this value are labelled as noise), HDBSCAN condenses 38 this tree with the use of a minimum cluster size threshold. Cluster splits that result in clusters containing fewer points than this threshold are treated instead as points ‘falling out’ of the parent cluster, ie labelled as noise. The result is a much-condensed tree, with clusters showing the persistence of structure in the data: clusters in the tree thin as points fall out and only split for sufficiently sized child clusters. This cluster persistence allows for the selection of clusters at variable density by working up the tree and selecting clusters of maximal stability to produce the final labelling. Of note, while HDBSCAN has the tendency to produce more clusters in the final labelling than most applications of DBSCAN, child-clusters are only selected if the sum of their stability/persistence is greater than that of their parent cluster, ensuring labelled clusters represent meaningful structure in the density landscape. Using HDBSCAN enables us to examine the hierarchy of clusters and gain some insight into the evolution of these clusters as we change the parameters of the algorithm. 39 Figure 2-4 Figure 2-4. The HUB-DT Pipeline, Steps G-I. G) Finding Neighbourhoods. The unsupervised clustering algorithm, HDBSCAN, uses the relative density of the input space (the 2-D density map) to organize points by their mutual reachability distance. H) Building a Hierarchy. The hierarchy of clusters is built and illustrated by a condensed hierarchy (linkage) tree. This condensed linkage tree shows points falling out of clusters (gradually thinning vertical lines) as neighbourhoods are iteratively trimmed by reducing the threshold of mutual reachability. Cluster splits are indicated by branching horizontal lines. Maximally stable clusters within the condensed tree are selected to produce a flat labelling of clusters at variable density. I) Extracting Cluster Labels. Labelled clusters can be visualised by colour coded plots of the embedding space. Each colour indicates a separate cluster, corresponding to a putative behaviour. 40 Figure 2-5 Figure 2-5. HDBSCAN. Hierarchical clustering at variable density. A) A single linkage tree for a set of points, generated by calculating the mutual reachability distance between points in the input. B) The corresponding condensed tree, showing the evolution of clusters as mutual reachability distances change. Clusters split, and have points ‘fall out’ into noise moving down the density gradient. C) Finally, clusters of maximal stability are selected to produce a flat cluster labelling containing a set of clusters of variable density. 41 Figure 2-6 Figure 2-6. Clusters in Behavioural Space. What do clusters represent? Each cluster in the label set corresponds to a single discovered behaviour. The pose kinematics of that behaviour can be visualised by plotting the mean wavelet amplitudes for points in the cluster. This is the averaged wavelet response for each feature, and together shows the changes in pose across the range of selected frequencies that characterize that behaviour. 42 Connecting Unsupervised Behavioural Discovery to Manual Behavioural Labels In an effort to make our unsupervised behavioural discovery more interpretable and relate it to manual behavioural annotation, we performed a series of supervised learning comparisons using the same behavioural space as defined above. Using our full spatiotemporal projection as input, we trained a series of ensemble models (see below) to reproduce the manual labelling of specified behaviours such as locomotion, rearing, grooming, etc. To learn the human-annotated behavioral labels, Random Forests (RF’s) were trained on a set of manually defined behavioural categories: inputs were samples from the full, high-dimensional behavioural space, and outputs were a set of binary vectors for each category (behaviour). Each forest consisted of 100 trees, each built on a random subset of input dimensions (to a maximum of the square root of the total input dimensions) and on a bootstrapped sample of data. Split criteria in constructing each tree were based on maximising information gain amongst the given set of inputs, and outputs were calculated as an average of probabilities across the forest. The trees were optimised and evaluated using unseen training data from outside the sample (referred to as “out-of-bag” error). In this case, the RF’s trained on manual behavioural labels were evaluated not just for their performance (accuracy in RFs: Random Forests (RFs) are a popular ensemble method for regression and classification problems. A large collection of de-correlated decision trees is constructed and trained, and their average output is used as a predictor. Trees are able to capture complex interactions between many correlated inputs, and benefit greatly from averaging to reduce instability and reduce variance. As such, random forests have a number of key advantages, notably low bias on high variance inputs, and are particularly useful in large dimension data sets with (relatively) a low number of samples like our behavioural space data (Hastie et al. 2011). 43 predicting held out or novel data) but also for the subset of input dimensions, or features, from the full behavioural space that were most informative in categorising behaviours. Feature Importance: The relative importance of a given feature in prediction can be evaluated within a random forest by looking at the expected proportion of samples it contributes to in each tree and then averaging those results, giving us a mean decrease in impurity measure, or ‘feature importance’ measure. These feature importances are easily calculable (via the mutual information measure used to define splits in the trees) but suffer from two key issues: they are based on training data statistics only, and are biased towards features with higher cardinality (more unique values). These can be mitigated by instead using a permutation-based importance measure, calculated on a held-out test set. Each feature is in turn permuted and the accuracy on this held-out set is compared between raw and permuted features. While permutation importance addresses the key flaws of impurity-based measures of importance, it unfortunately does not overcome underlying biases stemming from tree/forest construction: namely, a preference for strongly correlated features (Strobl et al., 2007). These biases can again be mitigated by building conditional permutation importance measures, but this is a rigorous and computationally intensive prospect. Shapley Values and Universal Explainers: An alternative is to evaluate feature importance with a model agnostic method, by building a universal explainer; defined by Lundberg and Lee, (2017) as an interpretable approximation of the original, complex model. If constructed and defined following the procedure laid out by Lundberg and Lee, (2017), the resulting explainer model can evaluate the contribution of features to a given output efficiently and agnostic of a given model’s particulars. The theoretical particulars are quite involved, but essentially a set of additive feature explainers is built to approximate the contribution of each feature for each input to the model, approximating the impact of a given feature on each possible output. This explainer can be used to calculate Shapley (SHAP) values as a measure of feature importance, again by a process of conditionally permuting the input and output 44 space of the original model. Here we used the set of calculated SHAP values to extract the features of the full behavioural space that were important in our trained forests’ predictions of manually defined behavioural classes. This set of ‘important’ features of the behavioural space defines a ‘human annotation’ manifold within the full behavioural space. By running our behavioural discovery process on this manifold, we can more directly compare discovered behaviours to manually defined ones. In the restricted subset of dimensions, we made two key observations. First, that there are subsets of discovered behaviours that roughly align with manual behavioural labels, and second that manual behavioural labels typically align with multiple discovered behaviours, ie that the hierarchical clustering identifies structure within motion patterns associated with a manual behavioural label and breaks them down further into a set of related behaviours, or variations of the parent behaviour. By alignment, we are referring to similar structure in the density map, as defined by measures of comparative purity and cluster distance, which in turn indicates similar kinematics as measured by the average mean wavelet amplitudes of manual and discovered clusters. Critically, when we expand the input to the behavioural discovery process to the full behavioural space, both of these observations remain true. HUB-DT is able to discover subsets of behaviours, amongst the full set of discovered behaviours, which are related to manual behavioural labels, but subdivides those manual categories. These similarities were assessed by the measures listed above, and additionally assessed qualitatively, by viewing video examples generated from the cluster labels. This subdivision separates out behavioral variations that are unlikely to be reliably recorded by a human observer, and in application have been found to be a more informative match for experimental conditions and neural data (this is discussed in more detail in the specific use cases). 45 Figure 2-7 46 Figure 2-7. Characterizing Manual Behaviours. A) Plotting SHAPley values. Querying Random Forests (RFs) trained to categorize manually defined behaviours with a universal explainer model yields a set of SHAP values. These values indicate the impact of a given feature (A feature here corresponds to one dimension in our high dimensional behavioural space: recall that this space’s dimension is tracked body part * XYZ * wavelets) on the RFs decisions: values further from zero indicating increasing impact (SHAP value of zero is indicated by the vertical line). Visualising the top SHAP values via a violin plot shows the variable impact features can have based on the value of that feature. High or low feature value (wavelet response amplitude) may be more or less informative depending on the particular behaviour. Selecting a set of top SHAP valued features across behaviours yields a reduced behavioural space, containing the most informative features for characterizing those behaviours. B) Plotting ‘mean wavelet amplitudes.’ Once a set of informative features is selected via their SHAP values, we can use those select features to visualise the kinematics of that behaviour. The mean wavelet response amplitudes for those features form the characteristic profile of that behaviour in the reduced space. C) Behavioural discovery at a matching scale. A set of automatically discovered behaviours are plotted as coloured clusters in the 2-D embedding space. By adjusting the depth of cluster selection, we extract a cluster labelling at roughly the same scale as our set of manually defined behaviours. D) Behavioural Overlays. Here we plot direct comparisons between manual behaviours and the set of discovered behaviours in the 2-D embedding space. In each plot, the manual behaviour is indicated by a set of black ‘x’s, and is overlayed on the discovered clusters (coloured points). The structural similarities between manually defined behaviours and those discovered by HUB-DT at this scale are evident in the embedding space, as well as via their characteristic mean wavelet responses. A, B, D plot SHAP values, mean wavelet response, and embedding space overlay for two example manually defined behaviours, grooming (left) and rearing (right). 47 Figure 2-8 48 Figure 2-8. The Hierarchy of Behavioural Clusters. A) (Left) A full set of variable density clusters labels (by colour) generated from a hierarchical clustering of a single experimental session by HDBSCAN. (Mid) We plot this hierarchy as a condensed tree, and follow one segment of this tree (Right) to highlight how slicing the tree at fixed density produces alternate flat cluster labellings from the same hierarchy. B-D) We follow this segment and the associated clusters through progressively deeper slices of the tree. (Left) The clusters (in colour) of this specific segment. (Right) The labelled tree, showing the line of fixed density (red) and the selected clusters. Here we show a shallow fixed density selection (B), a deeper slice (C), and finally the full variable density selection (D). Exploring the Hierarchy As discussed, an advantage of a hierarchy-based clustering method is the ability to navigate that hierarchy and explore the structure and evolution of the behavioural clusters. By design, HDBSCAN assigns labels at variable density based on stable structures, but using the condensed tree we can also take fixed density slices to produce flat cluster labels at a variety of density thresholds. These slices help visualize how the specificity of behavioural labels evolves as we move deeper into the tree. Sufficiently shallow slices provide only a rough separation of the behavioural space, and cluster structure can be as basic as simply separating locomotive behaviours from non-locomotive. Increasing depth in the tree is accompanied by increasingly specific behavioural clusters. This property means the cluster labelling, and therefor the selected behaviours, can be tuned to a desired granularity; for example, to match the scale and specificity of a set of manually selected behaviours. Or, can be left as a variable density labelling, to provide a completely unsupervised set of behaviours. Evaluating discovered behaviour Hierarchical clustering yields a set of defined clusters and a complete labelling of the set of frames into those clusters or un-clustered noise. The quality of the behavioural clusters identified are evaluated via a series of cluster metrics built in to HUB-DT. This includes direct cluster metrics: cluster membership 49 confidence, dwell time (consecutive time spent in a given behaviour), and behaviour transition frequencies (between adjacent time bins) as well as behavioural measures such as mean wavelet amplitudes and variance within and across each cluster. Adjusted Mutual Information and RAND Index: Mutual Information and the RAND index (Rand, 1971) provide two statistical measures for comparing the fits between sets of labels. Mutual information is the measure of dependence between two variables, ie how informative one variable is of another. In comparing clusters, standard mutual information needs to be adjusted to account for differences in the size and number of clusters in the two sets, achieved by correcting the information measure for chance agreement. Similarly, the RAND index is a measure of the agreement between two sets of clusters. In essence it represents the frequency of occurrence of agreements over the sets of clusters, or equivalently the probability that a randomly chosen pair of points in one set of clusters will agree with the same pair in the other cluster set. The RAND index must also be corrected to account for differences in cluster size and number, by correcting by the expected similarity using a random model as comparison. Split-Join Distance (van Dongen Metric) (van Dongen, 2000): This distance is defined on the space of partitions (roughly equivalent to clustering) of a given set. It is the sum of the projection distance from one partition to another, and vice versa. Equivalently, it can be thought of as the number of steps required to rearrange one set of clusters into another, which each step being the relocation/relabelling of a single point. This measure is asymmetric, and so must be calculated for each direction. The van Dongen metric provides a measure of the structural similarity of two sets of clusters, and as such may be more informative of good clustering fits on hierarchies, or other highly structured partitions compared to simpler measures of mutual information or precision/recall. 50 Fowlkes-Mallow Index (FMI): the FMI (Fowlkes and Mallow, 1983) is a score used to compare the quality of a match between two sets of labels. The index is defined as the geometric mean of pairwise recall and precision between the two sets. Values range from 0 to 1, with 1 being a perfect match between labels. In practice, it is often used to compare clustering generated labels to ‘ground truth’, but it is also useful for comparing hierarchical clusters with different structure. Purity Measures: Cluster agreement can also be measured by a simple two-way cluster purity measure, calculated between two sets of labelled clusters. For example, if one set of cluster labels was for HUB-DT generated behaviours, and the other was for an experimental task factor. The purity measure would be the ratio between the proportion of a given behavioral cluster that was contained within a particular task factor cluster versus the proportion of the task factor cluster that was accounted for by the behavioral cluster. This purity measure is preferable to more complex statistical measures when the two sets of labels are expected to possess significantly different structure, or are incomplete, as in the given example. The labelled clusters are further evaluated visually by inspecting frames and video of the putative behaviour. HUB-DT extracts the frames associated with each cluster and produces short videos of each behaviour. This aids in the interpretability of the discovered behaviours, as well as allowing for comparison between the statistical measures of cluster quality and the visual appearance of the behaviour. 51 Figure 2-9 Figure 2-9. Visually Evaluating Behavioural Clusters. Clusters can be visually inspected by viewing the associated frames of the input video. This is beneficial in assessing cluster quality, as well as in assigning ‘sensical’ names to putative behaviours. Pictured are four example frames taken from four putative behaviour clusters (black lines indicate the corresponding clusters) from a single session. This set of putative discovered behaviours can be propagated across additional datasets by the use of a trained supervised learning model. We use a Random Forest to learn the relationships between the full behavioural input space and cluster labels, and this trained model is then used to predict behavioural labels for new data, given the new data’s behavioural space as input. 52 Comparative Analysis and Discovering Relevant Behaviour We now have a set of putative discovered behaviours applied as labels to an accompanying set of frames. It is worth, at this juncture, restating our operational definition of behaviour: sequences of pose over a range of timescales (this range is determined by the set of wavelets used in the spectrographic projection). These behaviours are not defined according to the animal’s goals, and may transition in timescales that are independent of the framerate at which the labels are set. While each frame is assigned a behavioural label, behaviours are not defined as transitions between poses in adjacent frames. Each instance of a given behaviour corresponds to a single point within that behaviour’s cluster that is defined across the whole range of timescales. This also means that each labelled frame contains information about changes in pose beyond the length of that single frame. This labelled set of frames can now be used in comparative analysis with neural data which in turn can be used to evaluate the quality and relevance to neural signals of discovered behaviour. In evaluating the efficacy of HUB-DT, we used paired neural data: electrophysiology data, recordings of multiple single neurons, binned at a matching framerate to the behavioural labels in a series of comparisons. In addition to utilizing the cluster metrics discussed above to evaluate neural clusters, unsupervised or defined by experimental factors, as compared to behavioural clusters, we also built statistical models 53 such as the GLM (Generalized linear method) (see below) to directly evaluate the relationship between neural data and discovered behaviour. Comparative analysis can be performed with a whole range of statistical methods and machine learning models built into HUB-DT. These labels can also be exported for alternate analysis. The full scope of comparative analysis is covered in more detail in the use cases below, as well as in the referenced publications. As discussed above, comparative analysis is critical in evaluating appropriate behavioural clustering. The behavioural discovery process is iterative, using neural data to provide feedback for parameterization, adjusting the specifics of projection, dimensionality, and depth without the need for a priori definitions. Ultimately, this paired analysis yields a set of labelled behaviours with a measurable relevance to areas of interest within the brain. GLMs: The generalized linear models (GLM) used in HUB-DT take as input either neural data (usually time-binned recorded firing) as a Poisson sequence or behavioural space input with a selectable link function to a set of labels (such as HUB-DT generated behavioural labels, or imported task factors). GLMs can be single or multi-factor models, modelling the relationship between inputs and categorical factors. The strength of the relationship between a factor and input in the model is measured by the r2 (coefficient of determination) value, the proportion of variance explained by a particular factor. 54 HUB-DT: Hierarchical Unsupervised Behavioural Discovery Tool HUB-DT has been built into a python package for integrated behavioural discovery and neural analysis. The package is available on GitHub: https://github.com/Loken85/HUB_DT/ The tool includes a GUI built using Streamlit (https://streamlit.io/). This GUI allows for interactive data exploration and analysis inside the browser, making it compatible for any operating system. Analysis is performed in real-time, and runtimes are reasonable even on low-end systems. A full run of behavioural discovery including computation should take no more than ~10 minutes, even for long (hours) experiments. More computationally intense operations, like training supervised learning models, can take longer, but these models can be saved and exported/imported for re-use. We have included a quick user guide for the HUD-DT application in the appendix. This guide covers the basic layout of the GUI, and provides an example workflow for running behavioural discovery and some basic combined analysis using HUB-DT. 55 HUB-DT Use Cases: In the following section we have compiled some brief use cases for HUB-DT from work in our own lab. These cases highlight the utility of the analysis pipeline across a variety of applications in our work, and represent a body of both published and in-progress studies. We will attempt to provide some context for the application of HUB-DT in each case, and briefly cover some insights that our analysis revealed. Investigating the characteristics of neural activity related to behaviors versus other task events Our work is focused on the function of the frontal cortex, and in particular the anterior cingulate cortex (ACC). ACC neurons can flexibly multiplex a staggering array of information, which makes it incredibly challenging to understand what is driving any given neural response. In an effort to understand how the neural representation of behaviours in the ACC was modified or modulated by changing emotional state, we applied HUB-DT to identify and categorize spontaneous behaviours during a task designed to elicit distinct ‘emotional contexts,’ and performed a series of neural activity analyses to identify and separate neural signals associated with behaviour and those emotional contexts (Lindsay et al, 2024). The data were collected as rats performed our ‘3-valence’ task (Caracheo et al 2018), where tones were paired with outcomes having a different emotional valence. The task was structured into 3 blocks with each block being dedicated to trials to outcomes of a specific valence (food, foot shock, and neutral or no outcome). Each block was treated as a unique ‘emotional context’. We have observed that each of these emotional contexts is associated with a unique ensemble activity state pattern in the ACC that persists throughout the entirety of the block (Caracheo et al, 2018; Lindsay et al, 2024). 56 Figure 2-10 Figure 2-10. Identifying Emotional Context Specific Behaviours. The inner subpanel shows a set of labelled clusters produced by HUB-DT from a single session. Six clusters have been selected, and their associated behaviour is shown in greater detail in the outer subpanels. A single example frame of each behaviour is shown, alongside the associated behavioural prototype: the plot of ‘mean wavelet amplitudes’ for that behavioural cluster. These behaviours have been given names based on closest observable equivalence. Here, the three behaviours on the left were specific to the shock context, and the three on the right to the food context, but this information was not used by HUB-DT to differentiate them. 57 A possible issue with assigning emotional context dependent states is that as ACC neurons also encode actions and behaviors, the unique patterns we observed could have arisen not because the ensembles were tracking emotional states per se but because they were tracking the unique behaviors that are emitted whenever rats enter one of these emotional states. In Lindsay et al (2024) HUB-DT was utilized to discover a large set of behaviours present during the task, including both some behaviours that were unique to specific emotional contexts, as well as behaviours that occurred across multiple contexts, and to separate neural signals related to behaviour versus the emotional context in which they are embedded. Many of these discovered behaviours were easily identifiable to human observers, and included expected contextually appropriate behaviours (such as freezing in the shock block and foraging behaviour in the food block) even though the behavioural discovery process was agnostic to the contexts and other task specifics (Figure 2-10). By applying paired analysis of this discovered behaviour with our electrophysiology data, we were able to identify the proportions of recorded neurons that were responsive to behaviour, and context, and highlight the distribution of multi-selectivity within the population (Figure 2-11). We demonstrated that roughly 10 times as many neurons responded to behaviours in a contextually dependent versus fixed manner, and that those behavioural representations appear to be embedded within the overall context (Lindsay et al, 2024). These context representations form distinct clusters in neural space, but despite the dramatic shifts between contexts the representations of individual behaviours remain identifiable (Figure 2-11). 58 Figure 2-11 59 Figure 2-11. Neural Representation of Behaviour Across Emotional Contexts. (A) Proportions of responsive and non-responsive neurons as measured by the coefficient of determination (r²) from a trained GLM. (B) Responsive neurons plotted as a Venn diagram, highlighting the distribution of multi-selectivity in the population. Representations of the three (A, B, C) most frequently occurring behaviours in all emotional contexts. (Left subpanels) Spike counts of each neuron from a single session were collapsed to 3-D using maximally-collapsing metric learning (MCML). Large dots are time bins when the behaviour occurred, small dots are all other time bins, and all are coloured by context (Neutral=Blue, Food=Green, Shock=Red). (Right subpanels) Average spike count across all bins for the given behaviour. Neurons were sorted according to their response magnitude in the food context, and sorting was maintained across contexts. Discovering the behaviours of addiction and withdrawal Identifying behaviors evoked in rats by a specific drug of abuse or stage of addiction have traditionally been based on the impressions of human observers. For instance, the behaviors that are typically associated with opioid exposure include: frozen postures, sniffing-up, grooming, rearing, confined gnawing, Straub tail and licking whereas the behaviors associated with opioid withdrawal include: jumping, rearing, paw flutters, wet dog shakes, abdominal constrictions, hunched posture, and teeth chattering (Gellert and Holtzman 1978; Maldonado et al. 1992; Maldonado and Koob 1993; Belozertseva et al 2016). There are some clear issues with this approach. First, while some of these behaviors, like Straub tail (prolonged tonic dorsal extension of the tail) are morphine-specific, many are not. Second, the presence or absence of any of these behaviors is at the discretion of the rater and their skill level. Third, even if a rater is highly skilled, the process is extremely time-consuming as the rater must advance through the video and score frame(s) manually. Automated behavioural detection and discovery alleviates many of these issues, and enables the labelling of potentially undefined behaviours that human observers would likely miss. Here we applied HUB-DT to behavioural analysis in a morphine use and withdrawal study, with the goal of being able to reliably detect behaviours specific to drug states. For this study, rats received morphine 60 on a ‘5 days on’, ‘2 days off’ injection schedule. Each day they were placed in an open field box for 30 minutes and were recorded with 2 cameras, mounted below and to the side of the enclosure. DeepLabCut was applied to provide pseudo-3-D tracking. 61 Figure 2-12 62 Figure 2-12. Extracting Morphine-Specific Behaviours. (A, B) Plots of labelled clusters over the 2-D embedding for two experimental conditions in the same animal. Each cluster corresponds to a putative behaviour. Arrows indicate examples of several morphine-specific behaviours identified by HUB-DT from open field video. (C) The mean wavelet amplitudes for a selected, example morphine-specific behaviour. Together these wavelet responses form a behavioural prototype for the given behaviour. (D) A single frame of video from an instance of the example behaviour. The tonic dorsal extension of the tail indicative of morphine-induced ‘Straub’ behaviour is clearly visible. This common morphine related behavioural marker was identified without supervision by HUB-DT. HUB-DT was able to reliably identify several morphine-specific behaviours. These drug-state dependent behaviours were extracted purely from the spatiotemporal projection and hierarchical clustering utilized by HUB-DT, without the need for a priori definitions or supervision. Examination of these discovered behaviours, by inspection of the behavioural prototypes, as well as labelled video generated by the tool showed that they included consistently observed and commonly used markers of morphine related behaviour in rodents, such as morphine-induced Straub tail (Belozertseva et al 2016). 63 Chapter 3: Reconfiguration of behavioural signals in the anterior cingulate cortex based on emotional state Introduction Performance on any task can be influenced by a number of factors that are not directly related to the task itself, including the level of hunger or thirst, stress, fatigue or frustration. This occurs because emotional states (Kragel and LaBar, 2016) and basic autonomic functions (Tu & Zhang 2022) are not isolated to particular brain regions but are propagated to influence activity patterns throughout the brain. It is not clear exactly how this occurs at a cellular level, but a recent study by Cowley et al (2020) showed that changes in internal state variables were reflected as a ‘slow neural drift’ in the activity of neurons in the primate prefrontal cortex that in turn affected how these neurons processed task-relevant information on a decision-making task. In the last 10 years that there has also been accumulating evidence that behaviors are tracked by widespread brain regions, including areas that have no obvious role in movement (Kaplan and Zimmer 2020). The reason why brain regions that do not directly control emotion, autonomic tone or actions have access to all this information is not entirely clear. However, it does suggest that the brain tends to create holistic representations of experiences rather than operating as a series of highly specialized regions, each processing information within a singular domain. Nowhere is the integrated view of information processing more evident than the frontal cortices. Here neurons exhibit the most extreme form of mixed-selectivity (Fusi et al, 2016), as they simultaneously represent information across many domains and dynamically re-weight these representations in order to adapt to changing task demands (Rigotti et al, 2013; Barak et al, 2013; Stringer et al 2019; Kira et al 64 2023). This takes different forms in different subregions of the frontal cortex. Anatomical and electrophysiological data suggest that lateral areas of prefrontal cortices may prioritize cognitive and sensory streams of information whereas more medial regions such as the anterior cingulate cortex (ACC) place a greater emphasis on processing information related to emotional/autonomic states and action. This dichotomy is highlighted by the effects of localized lesions of anatomically equivalent regions in both humans and animals, as damage localized to lateral PFC, tends to produce deficits in cognition and executive functions whereas more medial lesions centered on the ACC, result in changes in emotion, autonomic control and behavioral output (Devinsky et al, 1995; Rudebeck et al, 2006; Brotis et al, 2009). Of note in this regard, surgically precise lesions of the ACC have been shown over the last 70 years to provide relief to patients suffering from diseases where an emotional or autonomic state exerts a pathological level of control over the patient’s thoughts and behaviors as in obsessive-compulsive disorder (OCD) and chronic pain conditions. Studying the multiplexing of emotional and behavioral information by ACC neurons may offer a unique window into how the brain creates holistic representations and how these representations may be altered in certain disease states. In order to study how ACC neurons multiplex information about emotion and behavior, we must be able to accurately identify behaviors performed in different emotional states while also being able to disambiguate the neural correlates associated with the emotional state from the neural correlates associated with the behavior. As a first step towards addressing this challenge, Lindsay et al. (2018) used various machine learning approaches to precisely quantify the motions of individual limbs from video taken above and to the side of rats in a small transparent enclosure. In that study, ACC neurons were found to encode individual limb movements and positions as well as the animal’s allocentric location, even though the animals were not required to perform any task and were simply moving around freely in the enclosure. The present study builds on that work, progressing from the quantification of the 65 neural correlates of individual limb movements to the quantification of the neural correlates of behaviors. Unsupervised detection and annotation of behaviour As discussed at length in Chapter 2, in recent years, several methods have been developed to categorize temporal sequences of limb movements as distinct behaviours (Arac et al 2019; Luxem et al 2020). One factor that limits their utility for our purposes is that they typically define behaviours across a very specific temporal window. In contrast, we were interested in behaviours that evolve over variable and often unknown timescales. Another limitation of currently available techniques is that while they all effectively parse movements into behavioural clusters (i.e. unique constellations of limb movements), it can be unclear as to what these clusters represent or mean in functional terms. Finally, many of these approaches are not designed to seamlessly relate discovered behaviours to neural activity patterns. To summarize what was previously discussed, in response to these challenges, we developed a pipeline of machine learning techniques built on work in fruit flies (Berman et al 2014; Günel et al 2019), rodents (Hsu and Yttri, 2021), and humans (Mehta et al, 2020), that allowed us to categorize or classify unique sequences of individual limb movements across variable timescales. We termed this tool ‘Hierarchical Unsupervised Behavioural Discovery Tool’ (HUB-DT; Lindsay and Seamans, 2024) (Chapter 2). This tool enabled us to compare automatically discovered behaviours with manually selected behaviours in a shared behavioural space, which helped to facilitate the interpretability of discovered behaviours, and includes various machine learning techniques to find links between discovered behaviours and neural activity patterns. Here we apply HUB-DT as an integral component in the combined analysis of the neural representations of behaviour in ACC. 66 Representations of behaviour across distinct emotional contexts We used HUB-DT to detect the specific behaviors expressed during our ‘3-valence task’ (Caracheo et al, 2018). In this task, 3 outcomes that differed in emotional valence were delivered to rats in separate blocks of trials with each block of trials involving outcomes of a single valence type. As a result, each block of trials was considered to form a unique ‘emotional context’ and was associated with a statistically separable ensemble activity-state pattern in the ACC that persisted throughout the entirety of the block, including the ~50s inter-trial intervals where no cues or outcomes were presented (Caracheo et al 2018). HUB-DT was not only able to identify a large number of putative behaviours, but some of these behaviors were unique to a specific emotional context. It was also able disambiguate neural signals related to behaviors from the neural signals related to emotional context. Overall, we found that the majority of ACC neurons responded to actions in a contextually dependent manner. This modulation provides a potential mechanism for emotional regulation of behavioral output. Methods Experimental Subjects: Four male Long-Evans rats (Charles River Laboratories, Montreal) weighing between 400 and 470 g were used. They were housed in an inverted 12-h day/12-h night cycle and were food restricted to 90% of their free-feeding weight but given unlimited access to water. Tetrode array implant surgery was performed before any behavioral training began. All procedures were conducted in accordance with the Canadian Council of Animal Care and approved by the Animal Care Committee of the University of British Columbia. 67 Behavior: Recording and training sessions took place inside a custom-made behavioral chamber (30 cm x 25 cm x 60 cm) with a pellet dispenser that dispensed 45 mg sweet dustless precision pellets (BioServ) into a magazine cup, a shock grid and a tone emitting speaker that were all connected to a Med Associates (St. Albans, VT) control box and to a PC workstation running Med-PC software (St. Albans, VT). Before training began, rats were habituated to the chamber and accustomed to eating food from the magazine cup. They were also exposed to foot shocks in order to determine the intensity of the shocks for the experiments. The shock duration was 500 ms and the intensity was varied between 0.5 - 0.7 mA and was chosen based on the minimum level required to elicit a noticeable behavioral response. After rats had initial exposure to the chamber and to the two outcomes, tone conditioning began. Three distinct frequency (4,6,8 kHz) tones were assigned to three possible outcomes: food, shock or nothing. Prior to conditioning, the tones evoked no noticeable behavioral reactions. Tones were randomly assigned to an outcome for each rat, but once conditioning began, tone-outcome contingencies remained unchanged for the duration of the experiments. During the initial training period, tone-food pairings were conducted for 5 days, followed by 2-3 days of tone-shock and tone – no outcome pairings. Rats were exposed to at least 3 sessions where they received all three contingencies in consecutive blocks before any of the recordings used in this study took place. A session consisted of 3 blocks with the order randomly selected from all possible combinations. Each block consisted of 30 trials where the tone was presented for 5 seconds and the outcome was delivered immediately thereafter. The average ITI was 49s (range 25-85s). The data set was constructed from 5 selected recording sessions from 4 animals with varied block orders. The animal’s behavior in each block was video recorded using a dual camera set up that captured side and bottom-up views. Surgery and Data Acquisition: The electrophysiological recording data have been published in Caracheo et al (2018), using a different series of analyses. Rats were surgically implanted with custom built 16 tetrode hyperdrive arrays. They were anesthetized under iso-flurane gas, their skull was surgically 68 exposed and a 4 mm x 3 mm hole was drilled. The dura was removed to expose the brain around coordinates +3.0 mm from Bregma and ±0.5 mm from the midline. The implant was positioned over the area and fixed to the skull with 11 skull screws and dental acrylic. Two additional screws used as ground wires were placed in the posterior skull. Tetrodes were lowered ~1000 μm on the day of surgery and then the rats were given 1–2 weeks of recovery. Tetrodes were advanced up to 1000 μm more to their target prior to the first recording session. In between sessions, tetrode drives were turned between 20 – 50 μm to maximize the units recorded and obtain different populations. When the experiments ended, rats were perfused and their brains collected and sliced on a cryostat. Slices were mounted on slides and viewed under a microscope to confirm the anatomical locations of tetrode tracts. Based on tetrode advancement records, the positions were estimated to have been mostly in the medial wall, within the ACC up to the border of the prelimbic cortex (PL). Tetrodes were attached to EIB-36TT boards, plugged into two HS-36 headstages and connected via tether cables to a Digital Lynx 64-channel system and then to a PC workstation. Electrophysiological data and behavioral events were captured using Cheetah 5.0. Files were exported into Offline Sorter (Plexon, Inc.) and were manually sorted based on three-dimensional projections of wave form peaks, valleys and principal components. Once cells had been sorted, they were exported to Neuroexplorer 4 (Nex Technologies) and then to Matlab or Python for further analysis. Video Data Collection: Subjects were recorded by a custom setup of two synchronized colour video cameras, one camera side-on to the enclosure and another camera below. Automated feature tracking was performed on combined videos using DeepLabCut (Mathis et al., 2018). The resulting two sets (one for each camera angle) of 2-D tracking were combined into a single 3-D tracking. The central point of the skeleton was set to the centre point of the rat’s body. The x-y-z location of this point gave the spatial location of the animal at each time bin. The positions of 9 body parts (head, mid-shoulder, front left limb, front right limb, pelvis, rear left limb, rear right limb, base of the tail, mid-point of tail) were 69 calculated relative to the centre point of the body. The frame rate of the video (5Hz) and the neural data (200ms bins) were synchronized. The alignment was set by paired pulses to the video and electrophysiology recording rigs, matching the timing to within 1ms. A set of human labelled behaviours was generated by manual annotation. These annotated behaviours were a set of standard behaviours scored from video. Behavior in each time bin was categorized as belong to one or more of the following; locomotion, rearing, grooming, foraging/feeding, sniffing (i.e. interacting with the environment through head, whisker movements), and resting. A human observer fully annotated 2 of the 5 total sessions used in this analysis. The human observer-generated labels were propagated across the remaining sessions by a trained Random Forest (see below for details). Since one of the human-annotated behaviours, feeding, was by definition context specific, it was omitted from context purity comparisons. HUB-DT (Lindsay and Seamans, 2024): 3-d tracking data from DeepLabCut was post-processed by subtracting out the location of the animals’ centre of mass. This resulted in a set of tracking data where all body parts had coordinates relative to the animals’ centre of mass and therefor the data was agnostic about location in the enclosure as well as the direction or orientation of the animal in the enclosure. HUB-DT quantified behaviors based on an approach similar to that used in Motion Mapper (Berman et al., 2014). Specifically, a spectrographic projection via Morlet wavelets was used to discretize spatial and temporal features together into an expanded behavioural space. This involved first performing a Fast Fourier Transform on the xyz coordinates of each of the nine body parts and then separately convolving these with 5 logarithmically distributed frequency Morlets (ranging from 5Hz to 0.5Hz). This resulted in a full behavioural space of 9x3x5 (135) dimensions that quantized the changes in the relative positions of each body part across the 5 selected timescales. 70 HUB-DT then applied dimensionality reduction to the full behavioural space as an aid to visualization and as preparation for clustering. t-SNE (t-distributed stochastic neighbourhood estimation, van der Maaten and Hinton, 2008) was used in order to maximally preserve local structure in the reduced space. As an improvement on vanilla t-SNE, we used the openTSNE python package that utilizes approximate neighbourhood calculations, interpolation, and multi-phase optimisation to greatly improve performance and reduce computation resources. This resulted in the data being embedded in a reduced two-dimensional manifold, which we visualized via a density map showing the distribution of the data in the reduced space. This dimensionality reduction step has minimal impact on informative clusters as highlighted by Berman et al. (2014). The reduced dimensionality projection by t-SNE was used as input to the clustering algorithm, HDBSCAN. This density-based clustering algorithm was used to divide our data into a set of putative behaviours in an unsupervised way. Density-based clustering separates points via neighbourhoods of local density (calculated as reachability distance), resulting in a set of clusters without prior definition of cluster shape or number. The HDBSCAN package (McInnes et al 2017) modifies canonical DBSCAN by constructing a minimum-spanning tree of reachability distances to assign points to clusters of variable density via a hierarchy of density values. This hierarchy was used to produce cluster assignments of variable depth in the spanning tree, resulting in behavioural discriminations at different levels of granularity. Behavioral word analyses: For each session, the 10 most frequently expressed behaviors detected by HUB-DT across all 3 contexts were identified (i.e. the target behaviors). The behavioral labels in the 5 x 0.2s bins preceding and the 5 x 0.2s bins following each instance of a target behavior were then extracted. When the center bin containing the target behavior was included, this yielded a vector of 11 bin labels that we referred to as a behavioral ‘word’. Ten instances of behavioral words surrounding a target behavior were selected randomly from each context, yielding a behavioral word matrix containing 330 values (11bins/word, 10 word instances/3 contexts). In total across all sessions, there were 25 71 unique behavioral labels that were translated into 25 unique colors by the image command in Matlab. To perform the correlations of behavioral words, for each behavioral word, correlations between the sets of labels across the 10 instances within each context (N, F and S) as well as across all pairs of 2 contexts (N vs F, N vs S, F vs S) were calculated, yielding 6 correlation values/behavioral word. As noted above, each behavioral word matrix had 330 values and there were 10 behavioral words chosen for each of the 5 sessions. For the bootstrap correlation analysis, matrices of identical dimensions were created using the ‘randperm’ command in Matlab, based on 25 unique behavioral words. The identical sets of correlations were performed on these bootstrap matrices as described above for the actual behavioral word matrices. This was repeated 50x and the results averaged. However, rather than reporting the average across the 6 comparisons as for the real data, the 6 average correlation values were averaged into a single value and plotted. In all cases, the correlations were converted to absolute values. The absolute correlation values were compared using a one-way ANOVA and post-hoc multiple comparisons with critical values derived using Tukey’s honestly significant difference procedure. GLMs for single unit statistics: The generalized linear models (GLMs) used here treated recorded firing in each time bin as a Poisson sequence with a logarithmic link function to the factors. The GLMs were set up as multi-factor predictors, thus modelling the relationship between binned neuron firing and sets of categorical factors. These factors were one-hot encoded (i.e. each factor is a binary vector) sets of categories which translated the 3 emotional blocks (S-context, F-context, N-context), 3 tone categories (Shock-tone, Food-tone, Neutral tone) or behavioral categories identified by HUB-DT, into a series of binary vectors. The strength of the relationship between a factor and firing in the model was measured by the r2 (coefficient of determination) value. ‘Responsive’ neurons were selected by thresholding r2 values; the thresholds were set to 0.01 (i.e. 1% of firing, and 0.9 or 90% of firing based on outlier analysis). As separate GLMs were used for each factor, any overlap in the responses to multiple factors was based on post-hoc evaluation. 72 Purity Measures: The context specificity of sets of (behavioural) labels was measured by a two-way cluster purity measure, which was calculated between two sets of labelled clusters. In this case, one set of cluster labels was for the behaviours, and the other was for the emotional context. The purity measure was the ratio between the proportion of a given behavioral cluster that was contained within a particular emotional context cluster versus the proportion of the emotional context cluster that was accounted for by the behavioral cluster. Responsiveness Ratio: The responsiveness ratio was the proportion of single neurons responsive to a given factor as measured by a fit GLM. Specifically, here, the ratio gives the proportion of responsive neurons in the population to different sets of behavioural labels. Random Forests: A set of Random Forests (RFs) was used to decode emotional context, and behavioural labels from ensemble firing. These forests were built and trained using the Scikit-learn python package (Pedregosa et al 2011). Forests were tuned for size and subset split parameters using ‘out-of-bag’, or OOB error. Each tree in the RF was trained on a subset, or bag, of the training data and then validated on samples from outside this subset. The average of this error across all trees in the forest is the OOB error. Forests of 100 trees provided the best average results across classification tasks in this study. For raw firing decoding, each forest took as input an N item spike count (0.2s bins) vector (N = number of neurons) of ensemble firing, and predicted emotional context, or behavioural category as output. Residual firing models instead took residual firing (as generated from our GLM regression models) as input to predict emotional context. Model performance was evaluated on cross-validated folds to control for evolving patterns in the data. Reported results for all of the RF models were average performance across all folds. A similar approach was taken for training RF models to propagate manual behavioural annotations across sessions. Here the RF models took points in the full behavioural space as 73 input, which were 9x3x5 (features by xyz by wavelet frequency) item vectors, and learned the associated manual behaviour labels as output. Maximally Collapsing Metric Learning (MCML): Time-binned spike count matrices for each session were submitted to MCML from the Dimensionality Reduction toolbox (Globerson & Roweis 2005; van der Maaten et al 2009; https://lvdmaaten.github.io/drtoolbox/) with the HUB-DT generated behavioural labels as class labels. Occurrences, target behaviors and behavioral responsivity: For each behavior detected by HUB-DT, a 10s sliding window was moved across all the time bins within a session. An ‘occurrence’ was registered whenever a behavior was present in at least 5 bins within a 10s window. Behaviors with at least 5 occurrences in each of the 3 contexts were identified and from this subset, the behavior with the most occurrences overall was taken to be the ‘target’, behavior. For all analyses, each occurrence included only those bins where the behavior was actually present. Behavioral responsivity was determined for each neuron by regressing the spike counts associated with all occurrences of the target behavior (within each context) with spike counts from all bins throughout the entire session that excluded the occurrences. The resulting coefficients of determination were evaluated using their p-values: If the p-value was less than the critical p-value (p-crit= 0.05/(263/√n)), for any context, the neuron was classified as being significantly responsive to the target behavior. Comparing occurrences of the target behavior; Single neurons: For each of the responsive neurons, the spike counts were compared across all pairs of occurrences of the target behavior using a one-way ANOVA followed by post-hoc testing (using multicompare in Matlab, with Tukey-Kramer hsd as the corrected critical p-value). For instance, if there were 3 occurrences of the target behavior in each context, the analysis would involve 36 (i.e. 9 74 occurrences taken 2 at a time) comparisons. This yielded a vector of binary values for each neuron that denoted whether the spike counts associated with every pair of occurrences differed significantly from each other (scored as 1s) or not (scored as 0s). These binary scores were then separated based on whether the comparison involved occurrences within or between contexts, as well as the specific types of contexts. The binary vectors from all individual neurons were combined and the relative proportions of 1s and 0s for each of the relevant comparisons were evaluated using the 2 statistic. Ensembles: The spike counts of all behaviorally responsive neurons were combined into a single matrix for each session. The spike counts for each neuron were plotted on a separate axis of an n-dimensional space, where each point in the space represented the spike counts of all neurons during a single time bin. The regularized Mahalanobis distance (DMahR) was then calculated between the points associated with occurrences of the target behavior within and across contexts. In order to compare distances on equal grounds, both the number of neurons and number of occurrences were held constant. To do this, bootstraps were created by first choosing 13 neurons at random and second by randomly splitting all occurrences of the behavior within a context into 2 equal halves. The DMahR was then calculated between points associated with the 2 subsets of occurrences within each context as well as between subsets derived from 2 different contexts. This was repeated 100x/session and the results averaged. This yielded 3 average DMah values for within-context occurrences and 3 average DMah values for between-context occurrences for each session. These values were combined across sessions and the results compared using a one-way ANOVA and post-hoc testing. Behavioural variance by emotional context: The time bins associated with the 5 most common behaviors across the 3 contexts were extracted for each session. For each behavior, regularized linear discrimination (LDA; fitcdiscr in Matlab) was performed using the context as the class variable and the behavioral coordinates (i.e. limbs x wavelets) in the reduced HUB-DT space associated with all time bins when the behavior was performed, as predictor data. A bootstrapping procedure was employed where, 75 for each bootstrap, 80% of randomly chosen trials were used for training and the remaining 20% for testing. For each bootstrap, training and test sets had to have at least 2 trials/context and neurons must have non-zero variance in their spike counts for both the training and test sets. Decoding accuracy was defined as the percentage of test trials in which the context was correctly predicted. The entire process was then repeated but using shuffled class labels. The average accuracy across the 100 bootstraps/session and across sessions for each behavior for the real versus shuffled labels was calculated and compared using a repeated measures ANOVA (fitrm in Matlab). The identical procedure was then repeated but instead of using the HUB-DT behavioral coordinates, the spike counts/neuron associated with these behaviors were used as the predictor variables. Results All experiments involved the 3-valence task (see Caracheo et al 2018) which was performed in a single physical enclosure (Figure 3-1). On each session, rats were given a tone stimulus paired with different, motivationally-specific outcome in blocks of 30 trials. Each block contained trials with a single tone/outcome pairing and was referred to as a unique ‘emotional context’. In one emotional context, a tone preceded an aversive outcome in the form of a mild foot shock (the S-context), in another emotional context, a different tone preceded an appetitive outcome in the form of food pellet delivery (the F-context), and a third emotional context block, a 3rd tone preceded a neutral outcome (no outcome, the N-context). The trials were separated by an average inter-trial interval of 51s and there were no additional time gaps between contexts. 76 Figure 3-1 Figure 3-1. Recording sites and task schematic. A) Tetrodes were slowly advanced through the dorsal ACC (Cg1) to the level of the prelimbic cortex (PrL) across sessions. B) A schematic of the 3-valence task. Rats were placed in a single transparent enclosure equipped with a grid floor to deliver footshocks, a speaker to deliver tones and a port to deliver food pellets. A unique tone was followed by a footshock (S-context), the delivery of a food pellet (F-context) or by no outcome (N-context). Each tone outcome pairing was delivered in a dedicated block of 30 trials that is referred to as an emotional context. Hierarchical Unsupervised Behavioural Discovery Tool The Hierarchical Unsupervised Behavioural Discovery tool (HUB-DT), was used to automatically detect behaviors evolving across various timescales. Similar to motion mapper (Berman et al, 2014), HUB-DT treated behaviours as a combination of features (i.e. limbs, joints, or body parts) that moved in specific patterns at particular timescales or frequencies. Specifically, HUB-DT transformed 3-d body tracking data from DeepLabCut (Mathis et al 2018) by wavelet projection with multiscale Morlets to embed each pose (i.e. the constellation of limb positions at a single point in time) into a spatiotemporal high-dimensional space, where the axes were the responses of a particular limb moving at a particular frequency (Figure 77 3-2: A-C). This space was then reduced in dimensionality using t-SNE (van der Maaten and Hinton, 2008), and points in this low-dimensional projection were clustered using Hierarchical Density-based Spatial Clustering of Applications with Noise (McInnes et al 2017: HDBSCAN). Each cluster of points in this space was considered to be a distinct, putative behaviour. To give a concrete example, if there were multiple occasions where the right forelimb was moving at 0.2Hz, the left hindlimb at 1Hz and the head at 0.5Hz, these points would form a cluster in the high dimensional limb x wavelet space and as such would be considered a behavior. The characteristics of a given cluster could then be evaluated by generating a ‘behavioural prototype’ which was the set of average responses for the cluster (Figure 3-2F). 78 Figure 3-2 Figure 3-2. A schematic description of the HUB-DT process. A) Video was collected by cameras placed underneath and to one side of the transparent enclosure. B) (Left) The positions of 9 parts of the animal’s body were tracked using DeepLabCut (all positions were normalized relative to the rat’s center of mass). (Right) The x,y,z coordinates of each body part were then convolved with 5 logarithmically-distributed frequency Morlets (ranging from 5Hz to 0.5Hz). C) This resulted in a behavioural space of 135 dimensions (‘9’ body parts x ‘3 x,y,z’ coordinates x ‘5’ Morlets). D) The 135-dimensional space was projected down to 2 dimensions using t-SNE to produce a density map. E) HDBSCAN was applied to the density map to 79 provide unsupervised clustering: each cluster represents a distinct behavior. F) Each cluster can be characterized by a prototypical or average set of wavelet responses corresponding to the multi-timescale movements of body parts in the putative behaviour. In this example, the behavior was characterized by movement of the nose, right and left forepaws and base of the tail across multiple frequencies with little involvement from the other body parts. Although we often prefer to refrain from assigning a human label for the discovered behaviors, this profile is roughly consistent with what would typically be considered exploration/rearing. 80 Figure 3-3 81 Figure 3-3. Behavioral discovery at different levels of the behavioral cluster hierarchy. A) (Left) A set of clusters (labelled by colour) generated by HUB-DT plotted over the 2-D density map. (Mid) Behavioral cluster hierarchy as a dendrogram, with the width and color of each branch representing the number of points in the cluster at that level. Unlike a standard hierarchical tree where a cluster splits into two new clusters at each level, HDBSCAN generates a condensed reachability tree tracking persistent clusters that are continuously shedding points while moving downward along the density gradient. This is depicted by the fading/narrowing of each line. The box (Right) draws attention to one segment of the tree. B-D We follow this segment and the associated clusters through progressively deeper slices of the tree. (Left) The clusters with this specific segment. (Right) The tree segment showing a line of fixed density (red) that can be drawn through the tree to extract cluster labels at a certain level. Shallow (B), or deeper (C), or at full depth (D) increasing the granularity of the labelled behaviours. Cluster separation and membership is based on neighbourhoods in the density map resulting from differences in limb kinematics. Discovering Behaviour at Variable Granularities A feature of hierarchical density-based clustering is its ability to assign cluster labels at variable densities. Within HUB-DT, clusters were created within the behavioural space based on the relative distance of points to other points in the local neighborhood, specified as a ‘reachability distance’. This distance relationship was then expressed within a reachability tree, that described the hierarchy of clusters. The tree could be ‘sliced’ (i.e. extraction of cluster labels at a fixed depth in the tree) at various levels, which would be functionally equivalent to the fixed density clustering implemented by the standard DBSCAN algorithm. This made it possible to generate clusters at specific neighbourhood density thresholds, in-effect allowing us to control the granularity of the discovered behaviours (Figure 3-4). Shallower slices (higher up the tree) resulted in clusters with reduced granularity, as characteristics separating behaviours further down the tree would be merged together. As the fixed-density line descends, more and more clusters emerge, separated by increasingly subtle differences in limb kinematics. At full depth, the algorithm selects clusters adaptively, based on their persistence and relative density. Unless otherwise stated, all analyses below involved behaviors detected at full depth of the hierarchy. 82 Identifying Discovered Behaviours The behaviors detected by HUB-DT did not always fit into categories that could be assigned familiar names. It was nevertheless still possible to understand the detected behaviors based on their defining features. Figure 3-4 shows 6 behaviors identified by HUB-DT. In each panel, the behavioral prototypes (i.e. the average of the behavioral cluster) are shown on the right. Note that these prototypes show differences in behaviour both within and across emotional contexts. In particular, ‘pacing’, ‘exploring’ and ‘foraging’ all involved locomotion but were associated with slight differences in limb kinematics. Likewise, ‘freezing’ and ‘waiting’ appeared by visual inspection to be virtually identical but were differentiated by HUB-DT based mainly on subtle differences in movements of the nose/snout. It is also interesting that these two behaviors were performed in only either the S-context or F-context respectively, even though this information was not used by HUB-DT to differentiate them. Conversely, there were multiple behaviours that were repeated across the 3 contexts, as described in more detail below. 83 Figure 3-4 Figure 3-4. Identifying different behaviors detected in a single session. The inner subpanel shows the clusters of behaviors produced by HUB-DT and the outer subpanels show 6 of these behaviors in greater detail. Each of these behaviors has been assigned an interpretable name based on extracted video snippets. The image on the left inset is a screenshot from an example video when the animal was engaged in the behavior while the right inset panel gives the associated behavioral prototype: The behavioral prototype is the mean of the cluster responses, and gives the average amplitude across the 5 wavelets for each of the body parts. The 3 behaviors on the left were specific to the S-context and the 3 behaviors on the right, to the F-context, but this information was not used by HUB-DT to differentiate them. Comparing Human and Automatically Generated Behavioural Labels Two analyses were used to compare the performance of HUB-DT to that of a human observer scoring behaviours from video. The first focused on the assumption that each emotional context should evoke 84 at least some behaviors that were expressed preferentially in that context. The emotional context specificity of HUB-DT versus human-labelled behaviours was assessed by a two-way cluster purity measure which quantified the proportion of a given behavioral cluster that was contained within a particular emotional context cluster versus the proportion of the emotional context cluster that was accounted for by the behavioral cluster. As a human did not manually annotate all sessions, manual behaviour labels in this case are observer annotations propagated across the remaining datasets via a trained Random Forest (RF) classifier (93.7%±5.1 accuracy) (see Methods). We found a substantial advantage in peak specificity for the HUB-DT discovered behaviours (81%±4.7) as compared to manual behaviour labels (43%±9.2; t=142.4, df=8, p<0.05) (Figure 3-5). This meant that HUB-DT detected behaviors that were more context-specific than typical pre-selected behaviours scored by human observers. The second comparison assessed the responsiveness of single neurons to a given set of labels, if the labels were generated by a human observer versus HUB-DT. This was assessed by multifactor Generalized Linear Models (GLMs) as follows. All time bins within a session had a human-generated behavioural label (generated as noted above) and a HUB-DT generated behavioural label, along with a set of associated firing rates. The GLMs were then trained to relate single neuron firing to human-generated or HUB-DT generated behavioural labels. The strength of these relationships were quantified using the coefficient of determination (r2) and decisions about whether a given neurons was responsive to a given factor were based on threshold criteria (see Methods). This allowed us to compare the ‘responsiveness ratio’ (the ratio of GLM-responsive to GLM-nonresponsive neurons) across the two sets of labels. While the HUB-DT discovered behaviours had a higher overall mean responsiveness ratio (24%±3) than the human behavioural labels (17.8%±5.4), this difference was not significant (F(df)=9, p=0.35; Figure 3-5). Based on these comparisons, we suggest that HUB-DT can discover behaviours that are context-specific without prior knowledge of behaviours of interest, and, as shown in Figure 3-4, 85 contain subtle differences that may be difficult to discern by manual observation. Comparatively, these discovered behaviours are both significantly more context-specific and slightly more representative of ACC firing than human-labelled behaviours. The remainder of the study will focus only on behaviours detected by HUB-DT. Figure 3-5 Figure 3-5. Comparing behavioral labels assigned by a human versus HUB-DT. A) A two-way purity measure showing the context specificity of behaviors. On the left is peak purity for pre-selected human annotated behaviours, averaged across sessions. On the right, peak purity for discovered behaviours averaged across all sessions. The dotted line indicates the approximate value of a behaviour uniformly distributed across an experimental session B) GLMs were used to detect neurons that were significantly responsive to a given behavior. The responsiveness ratio which compared the number of GLM-responsive versus GLM-nonresponsive neurons did not differ significantly for behaviors detected by HUB-DT versus a human observer Disentangling Behaviour and Emotional Context Signals in Single Neurons A similar GLM-based approach was used to determine whether individual neurons were responsive to behaviors, to emotional contexts or some combination of the two. Time bins in each session were assigned three sets of labels, one for the overall emotional context (S-context, F-context, N-context), one for the task-event (S-tone, F-tone, N-tone), and one for the HUB-DT assigned behavioural label (Figure 3-6). A series of multifactor GLMs were then trained to relate single neuron firing to one of the 86 three sets of labels. Multiple GLMs, one for each factor set, were used in order to avoid multicollinearities caused by the non-independence within and across time bins. Single neuron firing rates were predicted by these GLMs, yielding a measure of responsiveness of a neuron to a given factor where responsiveness was the proportional contribution of the neurons’ firing rate to a given GLM factor (with a threshold to address numerical instability and to remove low-likelihood correlations; see Methods). These analyses involved a total of 263 neurons recorded across 5 sessions. Overall, 51.7% of neurons were responsive to an emotional context contrast, with 12.1% being responsive to emotional context contrasts isolated to the tone epochs (Figure 3-6). In addition, 39.1% of neurons were responsive to at least one of the behaviors. However, it is important to emphasize that most neurons were responsive to one or more contexts (inside or outside of the tone epoch), one or more behaviors or some mixture of the two categories (Figure 3-6). In fact, only 28.9% of neurons were responsive to a single emotional context (including the tone epoch) and only 2% to a single behavior. On the other hand, of the 142 neurons responsive to emotional contexts (and tones), 64 (45%) were also responsive to a behavior. This highlights the multi-modal nature of ACC representations, both in terms of inter-mixing different emotional valences as well as inter-mixing emotional and behavioral information. Additionally, although a large proportion of neurons were responsive to at least one of the categories, the magnitude of the association to a given factor (i.e. the r2) was quite small for each neuron, as on average, 4.9 ± 1.5% of a neuron’s firing was related to the encoding of behaviours and 7.5 ±1 % to emotional context. It is possible that some of the emotional context responses may have arisen because the neurons were tracking behaviors that were performed in only a single emotional context (See Figure 3-6). In order to address this potential confound, we again used a GLM approach, but in this case trained a second GLM to predict emotional context labels using the residuals from the GLM above that used behavioral labels as factors. In other words, this second GLM was asked to predict emotional context, after the contribution to behavioural encoding had been removed (Figure 3-7). This residual GLM technique was 87 performed on specific time periods as well as across whole sessions to ensure emotional context specificity could not be attributed to some other factor. Again, the strength of emotional context encoding was quantified using the coefficient of determination (r2). Results showed that there was no change in contextual responsivity for the GLM trained on the behavioral residuals versus a GLM trained on raw firing rates (Figure 3-7; full sessions: t=0.583, df=257, p>0.05). The fact that the results from these two GLM analyses did not differ suggests that even though ACC neurons could be responsive to behaviors in a context-specific manner, this was not the information these neurons used to differentiate the emotional contexts. 88 Figure 3-6 Figure 3-6. Measuring Responsive Neurons across the population. A) A schematic showing the factors for Generalized Linear Model (GLM) analysis. Emotional context (colour coded: Blue=Neutral, Green=Food, Red=Shock, Grey=Inter-context period) labels are applied to each time bin (200ms). Behaviour labels (shown as variable length blocks of assorted colours, one colour corresponding to each behaviour, length corresponding to the number continuous time bins in that instance of the behaviour) are also applied to each time bin. This results in each time bin having an associated label for emotional context, behaviour (from HUB-DT), and other task factors to be applied to a GLM model. B) Proportions of responsive and non-responsive (as measured by the coefficient of determination from a trained GLM) neurons across the population for three sets of factors: Emotional Context, Behaviour, and Tone. C) Responsive neurons plotted as a Venn diagram highlighting the distribution of multi-selectivity in the population. While the bulk of responsive neurons were responsive to emotional context, there was significant overlap with other factors; nearly half of emotional context responsive neurons were also responsive to a behaviour. 89 Figure 3-7 Figure 3-7. The impact of context-specific behaviors on contextual encoding by individual ACC neurons. Multifactor GLMs were trained to relate single neuron firing to a set of labels contrasting the 3 emotional contexts, and to a set of labels for HUB-DT behaviours. The labels denoted every time bin within full sessions A) or the time bins associated with just the conditioned tone epochs B) or the time bins associated with the intertrial intervals C). Each panel shows sorted r2 values that relate spike counts to the factors for all neurons. The Top panels (Blue) give the r2 values when the GLM was trained using raw spike counts on emotional context. The middle panels (Red) when the GLM was trained using raw spike counts on behaviours. The Bottom panels (Orange) give the r2 values when the GLM was performed using spike counts in which the contribution to all behavioral factors had been removed (i.e. the residual spike count matrix from the GLM trained using the detected behaviours as factors). Predictive Decoding from Populations of Neurons As a follow up to the single neuron analyses, we investigated representations of behaviors and contexts at the ensemble level using a predictive decoding framework. Specifically, Random Forest (RF) models 90 were trained to predict behavioural and emotional context labels from ensemble firing using all neurons across a given session. Using these RFs, we found that ensemble firing was able to decode both behaviours (93%±0.5 accuracy averaged across behaviours and sessions) and emotional contexts (82 ± 1.6% accuracy averaged across sessions and contexts) in unseen samples with an accuracy much higher than for any single neuron in isolation (Figure 3-8). Similar to the single-neuron analyses above, we addressed the question of whether context-specific behaviors contributed to the accuracy of context-block separations by testing whether the decoding of emotional context changed when it was performed using raw firing rates versus rates where the contribution of behavioral factors had been removed (i.e. using the residual firing from the single-neuron behavioral label GLM described above). When the residuals from the behavioral label GLM were passed to the RF models, a mean emotional context decoding of 85% ± 1.2 was attained across sessions, as compared to the 82% ± 1.6 reported above when the raw firing rates were used (Figure 3-8). This modest improvement in performance again indicates that ACC ensembles did not differentiate emotional contexts by tracking context-specific behaviors. In fact, in this case behavioral encoding slightly hampered emotional context differentiation. 91 Figure 3-8 Figure 3-8. ACC ensemble encoding of emotional context and the impact of context-specific behaviors. A) Schematic of the RF architecture: Inputs are spike counts and the output is the predicted emotional context. B) Emotional context decoding was performed by RFs using raw firing rates (orange bars) or using the ‘behaviour residuals’ (blue bars) which are the residual spike counts from a GLM trained on HUB-DT labelled behaviors as factors. 92 Figure 3-9 Figure 3-9. Quantifying the magnitude of change in behavioural representations across emotional contexts. A) The number of neurons that were deemed to be significantly responsive to the target behaviour in the Neutral (N), Food (F) and Shock (S) contexts. The proportions did not differ between the N-F, N-S and F-N contexts (2 all p>0.05). Neurons could be significantly responsive in more than one context, but 94 were found to be selective in at least one context. B) Quantification of the proportion of changes in behavioural responses within versus between contexts. For each of the 94 neurons, the spike counts associated with all occurrences of the target behaviour were compared using a one-way ANOVA, yielding a binary vector of 1s and 0s. The proportion of 1s to 0s across all neurons and sessions are plotted. C) The same data as in (B) broken down by context. ** indicates p<0.0001. individual neurons 93 that changed responses to a behaviour. The 10 most commonly performed behaviours were selected, and for each neuron a t-test was used to compare activity when the behaviour was performed within a single context or in 2 different contexts. The proportion of neurons that changed how they responded to at least one of behaviors in two different contexts far exceeded the proportions that changed how they responded to at least one of behaviours within a single context (**, p<0.001). D-E) Quantification of changes at the ensemble level. The same neurons and occurrences as in (A-C) were analyzed by combining the spike counts from all neurons into an n-dimensional space and calculating the DMahR between points associated with all pairs of occurrences of the target behavior within and between contexts. (D) The DMahR between points associated with all pairs of occurrences drawn from multiple contexts were significantly larger than the DMahR between points associated with all occurrences drawn from within a single context (**, p<0.001). DMahRs involving comparisons between points associated with occurrences drawn from the N and F contexts were smaller than DMahRs involving comparisons between points associated with occurrences drawn from the N and S contexts or the F and S contexts (*, p<0.05). The dynamics of changing behavioural representations The ensemble distance measures gave an indication of how much the behavioral representations shifted but said little about the neuronal dynamics causing the shift. To address the question of how many neurons changed and by how much, we extracted the 10 most common behaviors in each session and calculated the proportions of neurons that responded differently to each of the behaviors within a context versus across contexts using a series of paired t-tests. Figure 3-9 plots the proportions of neurons that responded differently to at least one of the behaviors for the comparisons shown. In terms of the within-context comparisons, only a single neuron responded to at least one of the behaviors differently within a single context. In marked contrast, 24% (n=63), 43% (n=113) and 38% (n=100) responded differently across the N versus F, N versus S and F versus S contexts, respectively. Chi2 testing revealed that the proportions of cases where behavioral responses differed was always significantly greater for cross-context comparisons than within-context comparisons (all p<0.001). For the cross-context comparisons in particular, there were significantly more neurons where responses to a given behavior changed between the N versus S than N versus F contexts (2=21, p<0.001) or the F versus S 94 contexts (2=12, p<0.001). Figure 3-9C plots the average magnitudes of the absolute change in spike counts for all cases where a neuron significantly changed its response to a behavior. Although an ANOVA revealed a highly significant overall difference (F(5,1577)=18, p<0.001), this effect was driven by the large differences between all the within- versus cross-context comparisons and post-hoc testing revealed that none of the cross-context comparisons differed significantly from each other (Figure 3-9C). Remapping of behavioral representations by emotional context The remainder of the study was focused on quantifying the shift in behavioral representations across emotional contexts. To provide an overall impression of how ensembles represented the same behavior across contexts, the ensemble activity was reduced to 3 dimensions for visualization purposes. Each dot in the space represents the ensemble activity pattern during a single time bin with the colour of the dot denoting the emotional context from which it was derived (Figure 3-10). The time bins associated with the 3 most common behaviors across the 3 contexts (large dots in the left panels) were coloured based on the context in which they occurred. If the ACC represented behaviors independently of the context, the large dots (behaviours) would have formed coherent, isolated clusters in the neural space. This was not the case, as the large dots (behaviours) were always embedded within a cluster of smaller dots of the same colour. This meant that even though the behaviors were defined by statistical consistencies in limb kinematics (via HUB-DT), the way these behaviors were represented by the ACC depended on the emotional context in which they were performed. However, this does not mean that every neuron changed how it encoded a behavior. The right panels in Figure 3-10 plot the average spike counts during all the time bins in which the behavior occurred in each context. Note that the effect of context on behavioral representations varied across neurons, with some neurons exhibiting a large change while in others, there was no change at all. In this plotted example, the largest shift occurred when going from 95 the F to S context relative to the S to N context, suggesting there may be differences in the degree of remapping for specific contexts. Contextual Shifts in Ensemble Encoding To quantify the magnitude of the contextual shifts on behavioral representations, we compared the similarity of the neural responses to a given behaviour when it was performed multiple times within a single context versus when it was performed in two different contexts. To do this, a ‘target behavior’ was identified for each session, which was the behaviour that had the largest number of occurrences, distributed as equally as possible across the 3 contexts. Individual ‘occurrences’ of the target behaviour were then extracted, where an occurrence was defined as the target behavior being present in at least 5 bins across a 10s period. Based on these considerations, the target behaviors occurred on average 8.8/6.2/9 times in the 1st/2nd/3rd contexts respectively, with each occurrence spanning an average of 2.5/2.5/2 seconds respectively. Even though occurrences were defined based on a sliding 10s window, the analyses below only considered those set of bins within an occurrence where the behaviour was actually detected. Before comparing neural responses across contexts, it was necessary to first establish whether a given neuron was responsive to the target behaviour in at least one of the contexts. Responsivity was again evaluated via a regression, in this case for each neuron by comparing the spike counts associated with all occurrences of the target behaviour with spike counts from all bins that excluded the occurrences (see Methods). Although responsivity was determined separately for each context, no context-specific differences were observed (Figure 3-9A). Of the total 263 neurons, 94 were found to be responsive to the target behaviour in at least one of the 3 contexts. 96 For each of these neurons, the spike counts were compared across all occurrences of the target behaviour within a context and across all pairs of contexts. This yielded a vector of binary values that denoted whether the spike counts associated with every pair of occurrences differed significantly from each other (scored as 1s) or did not (scored as 0s). The relative proportions of 1s and 0s were then compared using the 2 statistic. As shown in Figure 3-9B, the proportion of occurrences where the neural responses changed were much larger if the occurrences were drawn from 2 different contexts versus a single context (2=628, p<0.001). Breaking things down further, the relative proportion of occurrences in which the neural responses changed did not vary within any of the individual contexts (Figure 3-10C; all p>0.05). On the other hand, changes were significantly more likely to occur when moving between the N and S contexts (Figure 3-10B, 2=431, p<0.001) or between the F and S contexts (Figure 3-9C, 2=452, p<0.001) than between the N and F contexts. This indicates that the largest shifts in responses to the target behaviour occurred whenever the S-context was involved. However, it does not necessarily mean that neurons became uniformly more or less behaviourally responsive in the S-context, since directionality was not specified in these analyses. The same basic approach was then applied at the ensemble level. Once again, the cadre of responsive neurons were used, but in this case the spike counts for each neuron were plotted on a separate axis of an n-dimensional space, where each point in the space represented the spike counts of all neurons during a single time bin. The regularized Mahalanobis distance (DMahR) was then calculated between the points associated with pairs of occurrences of the target behaviour. In order to compare distances on equal grounds, both the number of neurons and number of occurrences were held constant. To do this, bootstraps were created by first choosing 13 neurons at random and second by randomly splitting all occurrences of the behaviour within a context into 2 equal halves. The DMahR was then calculated between points associated with all subsets of occurrences. This was repeated 100x/session and the results averaged. The average DMah values involving occurrences of the target behaviour within and 97 between contexts across all sessions were compared using an ANOVA. As shown in Figure 3-9D, the distances between ensemble representations of the target behavior were much larger if the spike counts were drawn from two different contexts versus a single context (F(1,28)=46.2, p<0.001). While DMahRs involving occurrences of the target behaviour drawn from within any of the individual contexts did not differ from each other (Figure 3-10E; multiple comparisons test, all p>0.05), DMahRs were significantly larger if they involved comparisons between the N and S contexts (Figure 3-9E, p<0.05) or between the F and S contexts (Figure 3-9E, p<0.05) than between the N and F contexts. These results therefore replicate the findings of the single neuron analyses using a completely different, ensemble-based approach. 98 Figure 3-10 Figure 3-10. Visualizing shifts in behavioral representations across emotional contexts. A-C Neural space and spike count plots of one example session for the 3 most frequently expressed behaviours across all 3 emotional contexts. Plots are colour coded for context (Blue=Neutral, Green=Food, Red=Shock). (Left panels) The spike counts of each neuron during all time bins from a single session were plotted on separate axes and the space was collapsed to 3 dimensions using Maximally-Collapsing Metric Learning (MCML). For each plot, the large dots represent the time bins when the HUB-DT detected-behavior occurred, whereas the small dots represent spike counts in all other bins. For visualization purposes, the total number of dots was reduced by down-sampling from 0.2s bins to 5s bins via averaging. (Right 99 panels) Each point represents the average (and s.e.m.) spike count across all 0.2s bins in which the behavior was detected in a given context, for each neuron. In this session, the order of the contexts was F-S-N and the neurons were sorted according to the magnitude of their responses in the F-context and the sorting was maintained for the remaining 2 contexts. Behavioural ‘Syllables’ and ‘Words’ Behaviours do not occur in isolation, but rather are linked together in groups over time. Hence, a potential reason for the large contextual shifts in the behavioral responses could be that the behaviors were linked together in different ways in each context and the neurons were sensitive to the overall sequence of behaviors. One way to conceptualize this would be to consider the discovered behaviors as ‘syllables’ that were linked together into longer sequences that formed unique behavioral ‘words’ (e.g. Wiltschko et al 2020). In order to determine if the behavioral words were consistent within and across contexts, we again selected the 10 most common behaviors and plotted them along with behaviors that immediately flanked them. Figure 3-11A shows that the behaviours (colours) preceding/following a target behavior tended to be similar across all occurrences of that behaviour both within and across contexts. In order to quantify this effect, matrices of sequence labels like those shown in Figure 3-11A were constructed for each session and correlations between all occurrences of a behavioural word both within and across contexts were calculated. An identical series of correlations were performed on sets of randomly generated behavioral word matrices. The average absolute correlations between multiple instances of behavioural words were significantly larger than the correlations between randomly generated behavioral word matrices of the same dimensions (F(11,599)=62, p<0.0001, post-hoc multiple comparisons, p<0.01). This demonstrates a surprising degree of consistency in the sequences of behaviours emitted throughout the sessions. By extension, this argues against inconsistencies in behavioral sequences as a potential cause of the instability of behavioural representations by ACC neurons. 100 Figure 3-11 Figure 3-11. Linking behaviors through time. A) For a single session, 10 randomly chosen occurrences of the top 10 most common behaviors were extracted along with the behaviors in the 5 x 0.2s bins flanking 101 each respective occurrence. Every behavior was then assigned a different colour. These colours were only used to differentiate behaviors and conveyed no quantitative information about a behavior or how similar behaviors were to each other. Each line represents one occurrence of a given behavior (centered at time 0). The horizontal gray dotted lines separate the 10 occurrences of one behavior from the 10 occurrences of another behavior. The sorting of the 10 behaviors were maintained across the 3 contexts, although the specific occurrences necessarily varied between contexts (N=Neutral context; F=Food context, S=Shock context). Since the colours were relatively similar across all occurrences of a given behavior, it meant that the sequence of behaviors surrounding the target behavior were consistent throughout the session. When viewing this plot, it is important to note that behaviors differ in adjacent 0.2s bins even though every behavior was defined by limb movements as slow as 0.5Hz; Behavioural labels are instantaneous labels of variable length processes, and each bin is assigned the most probable behaviour as a label. B) Average correlations between occurrences of behavioral words within and across pairs of contexts (black bars). Average correlations between randomly generated behavioral word matrices (bootstraps) of identical dimensions (gray bars). Variations in behaviour across contexts As an additional confirmation that variations in behavioral performance were not responsible for contextual dependencies in behavioral encoding by ACC neurons, the following decoding analysis was performed. The 5 most common behaviors across the 3 contexts were extracted for each session and regularized linear discrimination (LDA) was performed using the behavioral coordinates in the reduced HUB-DT space as the predictor data and emotional context as the class variable. A bootstrapping procedure was employed where, for each bootstrap, 80% of trials were used for training and 20% held out for testing. The decoding accuracy was defined in terms of the percentage of test trials in which the context was correctly predicted from the behavioral coordinates. The entire process was also repeated but using shuffled class labels. The average accuracy across the 100 bootstraps/session and across sessions is plotted in Figure 3-12A. The accuracy in predicting context using the behavioral coordinates varied by behavior but the overall differences in accuracy between the actual and shuffled labels was not significant (accuracy: actual labels=0.37±0.09, shuffled labels=0.31±0.08, F(1,8)=1.7, p=0.22). The identical procedure was then repeated but instead of using the HUB-DT behavioral coordinates as the 102 predictor variables, the spike counts/neuron associated with these behaviors were used (Figure 3-12B). In this case, the accuracy at predicting context was far superior for the actual context labels versus the shuffled labels (accuracy: actual labels=0.78±0.05, shuffled labels=0.34±0.02, F(1,9)=866, p<0.001). These results again demonstrate that even though the behaviors were performed consistently across contexts, the way in which they were encoded by ACC neurons varied strongly according to the emotional context. Figure 3-12 Figure 3-12. Decoding context from behavioral coordinates versus neural responses. A) The 5 most common behaviors across the 3 contexts were extracted for each session and LDA was performed using the behavioral coordinates (i.e. limbs x wavelets) in the reduced HUB-DT space as the predictor data and emotional context as the class variable. The average of 100 bootstraps/behavior/session are plotted for the actual context labels (black bars) and shuffled context labels (gray bars). B) The identical procedure as in (A) but using the spike counts of the neurons during each of the behaviors as the predictor data. 103 Discussion In this study we developed an automated behavioral discovery pipeline that, when linked to electrophysiology data, enabled us to perform comprehensive correlation analysis of how ACC neurons flexibly encode behaviors. It was possible to at least partially disambiguate emotional context signals from behaviors and we found that the tracking of context-specific behaviors could not account for the separation of emotional contexts by ACC ensembles. However, the unique emotional states induced in each emotional context had a strong impact on the way the precisely-defined, naturally occurring behaviors were represented. The results imply that ACC representations of behavior are intimately tied to, or contextualised by the emotional state experienced when the behavior is performed. Emotional Regulation There are a number of reasons to believe that the ACC is involved in the emotional regulation of behavior. On one hand, there is an extensive literature documenting the role of the ACC in emotion. This includes functional imaging studies in humans that have provided clear evidence that the ACC differentially encodes emotional states (Shackman et al, 2011) and that dysfunction of the ACC contributes to a number of emotional disorders (Jaworska et al, 2015; Drevets et al, 2008). At a cellular level, ACC neurons encode internal states such as stress, fear, pain and hunger (Padilla-Coreano et al 2016; Quinn et al 2008; Guiustino and Maren, 2015; Johansen et al 2001). This is consistent with anatomical data showing that the ACC has extensive interconnections with a widespread network of regions that generate and control emotional and autonomic states, including the amygdala, midbrain, brain stem and spinal cord (Hoover and Vertes 2007; Gabbott et al, 2020; Burgos-Robles et al, 2017). In rodents, disruption of these pathways alters the expression of emotionally driven behaviors (Jhang et al, 104 2018; van Heukelum et al, 2021) while in primates ACC lesions result in reduced reactivity to threatening stimuli and reduced behavioral output (Rudebeck et al 2006; Bliss-Moreau et al 2021). In humans naturally occurring damage to the ACC can lead to the emergence of akinetic mutism (Devinsky et al 1995) whereas more delimited, precise surgical removal of the ACC and surrounding cortex (anterior cingulotomy) has proven to be beneficial for reducing extreme emotional reactions to severe types of pain or to anxiety-proving stimuli (McGovern et al, 2017; Brotis et al, 2009). In addition, there is a largely separate literature highlighting a role for the ACC in the control of behaviour. This includes anatomical studies documenting the connections between the ACC and regions that generate behaviour, such as the motor cortex, thalamus, striatum and spinal cord (Leow et al, 2022; Takeuchi et al, 2022; Brockett et al, 2020). Likewise, electrophysiological studies have shown that ACC neurons respond to the movements of individual limbs as well as a wide range of actions and behaviors (Jung et al, 1998; Seo et al, 2012; Lindsay et al, 2018). These behavioural correlates can be modulated by a variety of factors, including the environmental context, task context as well as the effort involved in executing the behavior and the outcome it yields (Sachuriga et al, 2021; Porter et al, 2020; Bryden et al, 2019; Caracheo et al, 2018; Ma et al, 2016). The confluence of emotional and behavioral information within the ACC supports the hypothesis that this region plays a central role in the emotional modulation of behavioural output (Seamans and Floresco, 2022). The present study attempted to illuminate how ACC neurons combined information about emotional states and behaviours. Defining and Extracting Behaviour Behaviour can be a somewhat general and ambiguous term. Here we used a specific operational definition, which was changes in pose (i.e. relative body part locations) that evolved over a range of timescales. Our automated behavioral discovery tool, HUB-DT, could reliably categorize and label 105 statistically separable behaviours. We referred to the process of unsupervised categorisation as behavioural ‘discovery’ because HUB-DT clustered a range of behaviours, some of which were not readily differentiable to human observers simply from observation of video. Indeed, it was often subtle variations in one or two limbs that separated context specific behaviours from visually similar behaviours present in other contexts. The application of HUB-DT provided what could reasonably be considered the full spectrum of observed behaviours on this task. Our operational definition of behaviour differs from the approach of defining behaviour according to the animal’s goals. While some of the behaviors detected by HUB-DT were goal-directed, for others the relationship was less obvious. This was partly due to the fact that the 3-valence task involved Pavlovian contingencies that did not depend on the rat’s behavior. As a result, the only truly goal-directed behavior was pellet retrieval. The other challenge was that because naturalistic behaviors flowed continuously from one to another, decisions about behavioral segregation were difficult. For this reason, it may be more appropriate to consider the behaviors detected by HUB-DT as sets of movement ‘syllables’, similar to the approach taken in correlational studies of motor output (Lashley, 1951; Bizzi and Cheung, 2013). These sequences of behavioral syllables could be combined into unique behavioural ‘words’ that would be perhaps more similar to what a human observer would consider as distinct behaviors. We found that on the 3-valence task, rats often performed the same behavioral syllables in a consistent pattern throughout the session. Within these patterns, the same behavioral syllable was sometimes repeated at a high frequency, while in other instances the behavioral syllables transitioned in adjacent 0.2s bins. It is important to note that although HUB-DT could theoretically endow each 0.2ms bin with a unique behavioral label, it did not define behaviors as transitions between poses in adjacent 0.2s time bins. Instead, each instance of a given behavioral syllable corresponded to a single point within a specific cluster that was defined by pose projections across a range of frequencies from 0.2s to 2s, and is therefore informed about movement beyond the bounds of that single bin. Behavioral syllables could 106 transition in adjacent 0.2s bins because identified behaviors neither dwelled nor transitioned at fixed, well-defined intervals. For some perspective on this issue, consider the example of an animal running. Running is often interspersed with brief interruptions, stutters or even transitions to walking and the animal may transition from running to stumbling and back to running in less than a second even though a complete running stride cycle is longer than 1s; this stochastic temporal quality motivated our focus on cross-context analyses of occurrences of target behaviours, rather than single time bins. Representing Behaviour in ACC neurons One way to verify if the behavioral boundaries were appropriate was to evaluate if they were associated with changes in the activity of ACC neurons. We found that there were robust responses to the wide variety of behaviours expressed on this task. For many context-specific behaviours identified by HUB-DT, there was a closer correspondence between ACC firing than those scored by a human observer. We acknowledge that this is not a strict comparison between HUB-DT and all ‘human observable’ behaviour, but rather to a set of general, easily observed behaviours not tailored to any specific task. We have already demonstrated that ACC neurons track changes in limb positions (Lindsay et al, 2018), but this factor alone could not fully account for our results as the average relationship between firing and behavior (i.e. r2) was stronger than between firing and limb positions shown in Lindsay et al (2018). It is of course still possible that ACC neurons were combining representations of limb positions into more complex representations of behaviors. Emotional Valence and the Modulation of Behaviour Consistent with our prior study (Caracheo et al, 2018), distinct ACC ensemble state patterns were associated with each emotional context of the 3-valence task. Each context-specific pattern was initiated 107 by the first tone within a block and remained in place throughout every subsequent time bin, including the ~50s inter-stimulus intervals when no tones or outcomes were presented. Although HUB-DT detected context-specific behaviors, these contextual representations did not arise because the neurons were tracking these behaviors. We can say this because the analyses involving residual firing matrices showed that emotional context selectivity was largely unaffected by removal of behavioural correlates. Therefore, the context-specific patterns were likely representing the emotional reactions to the unique outcomes themselves (Caracheo et al 2018). ACC ensembles produced clear and separable representations of each emotional context, even though individual neurons were sensitive to tones and outcomes of more than a single valence. This conclusion is in seeming contrast to the findings of Monosov (2017), who identified sets of valence-specific ACC neurons in primates during a two-valence task. However, the discrepancies may come down to differences in the operational definition of neuronal responsiveness and the specifics of the analysis used. In Monosov (2017), the definition of responsive neurons was limited to monodirectional modulation of a neuron to outcomes of a single valence. Neurons which responded in more complicated ways, or responded to multiple task factors were not accounted for, or were categorized as responsive to only a single one of these factors. In addition, their analyses did not take into account possible transformations of the responses similar to what we observed here. Nevertheless, both studies provide clear evidence that ACC neurons are informative of valence in addition to other stimuli and task factors. Mixed Selectivity and Population Encoding The observation that behavioral representations were intermixed with emotional context representations of multiple valences is consistent with the concept of ‘mixed selectivity’. Mixed selectivity is now well-established in cortical encoding analysis and describes how multiple task factors 108 can be represented by individual neurons and distributed across a neuronal population (Stringer et al 2019; Kira et al 2023). These structured representations are consistent and robust, but are comprised of variable groups of neurons with intermittent participation. A growing body of work including some recent advances in neural network design (Rigotti et al, 2013, Barak et al, 2013, Fusi et al, 2016, Nogueira et al, 2023, Mazzucato et al, 2016; Koay et al, 2022) suggests that networks of neurons possessing mixed selectivity offer advantages in terms of flexibility and stability. In particular, clustering multiple representations within a given region of neural space affords networks the ability to construct more detailed and nuanced representations of complex task situations (Musall et al, 2019; Bernardi et al, 2020; Koay et al ,2022) and improves network capacity. Within this framework, neurons participate in many representations, and switching between them is a process of reweighting the responses across the population. As a result, the pairings between represented stimuli and individual neurons are not necessarily linear, nor do they vary smoothly. In ensembles of neurons with mixed selectivity, consistency is expressed in terms of cluster distances and boundaries in neural space (i.e. the representational geometry). Further progress in describing these ensemble representations may therefore be possible by implementing approaches such as direct geometric analyses (Driscoll et al, 2017; Gallego et al, 2020, Williams et al, 2021, Nogueira et al, 2023; Qi et al, 2017) and dynamical systems analysis (Linderman et al., 2016, Pandarinath et al, 2018). In the present study, the effects of mixed selectivity were evident in multiple analyses. Perhaps most obviously, it accounted for the overlapping response distributions. Although each neuron tended to encode multiple behaviors, even the strongest behavioral correlates accounted for only a relatively small portion of the variance in firing. Furthermore, the responsivity of neurons to a given behavior was not an all-or-none phenomenon but was smoothly distributed across the population (Figure 7). These properties create a scenario where individual neurons weakly encode multiple task events and changes in the emotional context shift the relative strengths of each representation. In the capacity to convey 109 information, the functional unit is the ensemble, rather than the individual neuron, and as an ensemble, the representation of behaviour, emotional context, and other task factors is highly consistent and robust. ‘Context’ Encoding as a General Principle Contextual shifts in ACC representations are not limited to ‘emotional contexts’ as changes in the task context (e.g. a task rule such as the order of actions or direction of travel) or the physical context (i.e. environment) also change how actions are represented by ACC neurons. Ma et al (2014; 2016) examined the mechanistic basis of contextually-induced remapping by studying how neuronal responses to 3 operant actions varied when the actions were performed in a different order (i.e. task context) or different enclosure (i.e. physical context). The remapping was structured in such a way that all 3 action clusters were shifted in the neural ensemble space by the same amount and the relative geometry of the 3 action clusters was preserved. This was possible because there appeared to be a fixed amount of ‘responsivity’ for the actions that was distributed across the population in each context such that when the context changed, the total amount of responsivity remained constant but it was redistributed across the population (Ma et al, 2014, 2016). All neurons seemed to encode all events to varying degrees, but not all neurons were affected by changes in context in the same way (Figure 9). In other studies, we found that the extent and the magnitude of the shifts were dependent on how the context change was experienced. When a change in context was immediate and obvious to the animal (e.g. when the animal was moved between different physical environments), the changes in the responses of single neurons tended to be highly synchronized across the population (Hyman et al, 2013), whereas in cases where the animal slowly accumulated information that the context had changed, such as during gradual trial-and- 110 error learning (Emberly and Seamans, 2020) or learned extinction (Russo et al, 2021), the changes in the responses of single neurons were much more desynchronized. Emotional ‘Gain’ and Contextually-appropriate Behaviour Given the extent of contextual remapping observed in ACC, it seems unlikely that the region is dedicated to the processing of a specific type of information. Instead, we have argued that the ACC may imbue events, behaviors or sensations with a type of emotional, or contextual ‘gain’ (Seamans and Floresco, 2022). Such a view is consistent with the effects of ACC lesions in primates that cause reduced reactivity to threatening stimuli and reduced behavioral output, as well as with the emergence of akinetic mutism in patients with severe ACC damage (Devinsky et al, 1995; Rudebeck et al, 2006; Bliss-Moreau et al, 2021). To be clear, we are not saying that the ACC directly produces behaviors or emotions. Rather, it exerts a biasing influence on which stimuli or internal-states modulate behavior and how vigorously or persistently the behavior should be performed. The shifts in behavioral responses in the 3 contexts could be examples of how this process is instantiated at a neuronal level. The emotional modulation of behavioral representations may be the mechanism used by the ACC to inform downstream regions about the types and intensities of behaviors that should be emitted in a given context. This process ensures that behavioral output is appropriate to attain a goal, which is as relevant for survival in naturalistic settings as it is for success in social situations. Code Availability: Links to Github Repositories for code used in this study are linked below. HUB-DT: https://github.com/Loken85/HUB_DT Other Analysis: https://github.com/Loken85/ephys_ML_repo 111 Chapter 4: The geometry of emotion in ACC: Topological data analysis and the neural trajectory point net Introduction It is now well established that frontal cortex neurons represent information across multiple modalities, a coding regime referred to as mixed-selectivity (Fusi et al, 2016; Tye at al, 2024). These representations are concurrent, and are dynamically modulated in response to changing tasks and contexts (Rigotti et al, 2013; Stringer et al, 2019; Kira et al, 2023). In the case of the anterior cingulate cortex (ACC), neurons have been reported to represent a vast array of stimuli and actions, aspects of executive function and cognitive control, pain signals and emotional or autonomic states (Devinsky et al, 1995; Rudebeck et al, 2006; Seamans & Floresco, 2022). The expression of mixed-selectivity is not a matter of simple linear mixing, but rather involves a complex interplay of diverse representations across a population of participating neurons. The encoding of specific information, like a particular behaviour, is typically embedded within an over-arching contextual representation. This property was clearly illustrated by Ma et al (2016) who had rats perform 3 unique actions in two different contexts (physical enclosures). They found that each action was represented by a unique cluster in neural space and that a change in context shifted all 3 action clusters by the same amount in the space. Actions were encoded as part of a larger contextual representation and the overall ‘responsiveness’ of the ensemble for each action remained consistent across contexts but the 112 responsiveness was redistributed across the population. In other words, the ensemble representations could be seen as highly consistent, so long as one ignored the identity of the individual neurons. Physical context is only a part of the relevant overall context involved in the modulation of information processing. We have found that the representation of specific events also depends on the emotional context (Caracheo et al, 2018; Lindsay et al, 2024;). Specifically, animals were given blocks of trials (i.e. emotional contexts) in which a unique tone was followed by either an appetitive, aversive or null outcome. We found that the way ACC ensembles represented specific behaviors depended on the emotional context in which they were embedded. We argued that this may be a mechanism to imbue representations of behaviours, actions, etc. in the ACC with a form of emotional ‘gain’ (Seamans and Floresco, 2022) as a means to ensure that behavioural output is appropriate for the setting and goals for which they are performed. With this framing in mind, and building on our previous work in this study we posit the following question: What are the common features of these complex neural representations in ACC that are informative of emotional context and behaviour, and what can we learn about the contextual modulation of the representation of behaviour from these features? A key practical consideration in extracting information from populations of highly multi-modal neurons is knowing how to extract a signal of interest from noise and other potentially uninformative variance that is present in the recordings. Recordings sample from a relatively small portion of the neuronal pool, and may not, in isolation, be representative of how information is represented. To combat this, we sought to combine recordings from multiple experimental sessions and subjects into a single dataset. As both context representation and behaviour representation are similarly present in individual sessions, and follow seemingly similar patterns of responsiveness and modulation (Lindsay et al, 2024), common population features could likely be isolated from this combined set of recordings. However, a critical issue is that individual neurons’ identities and number, and therefore their orientation in neural space, are not preserved across recording sessions nor across different animals. This presents a technical 113 challenge in building equivalence amongst the differing populations of neurons and the underlying common representations. If the changes across sessions can be wholly accounted for by a rearrangement of the input neurons, functionally a rotation in the underlying neural space, then it may be sufficient to project sessions into a lower-dimensional space via a cross-decomposition method such as canonical correlation analysis (CCA: see Methods below) to allow downstream decoding and analysis. This technique has been applied in decoding matched behaviours from motor cortical signals in monkeys and mice (Safaie et al, 2023), for example. These decompositions rely on the underlying dynamics being linear however, and may fail to account for more complicated relationships between neurons. In addition, this assumes the input neuronal signals are already temporally aligned, which may be reasonable for cued motor tasks, but is less likely to be true for continuous or less well temporally defined signals such as emotional context. Even should all these conditions be met; such an approach ignores potentially informative structure in the signal. There is a growing body of emerging work (Nogueira et al, 2023; Galgali et al, 2023; Tye et al, 2024) that focuses on this structure, detailing the relationships between neurons participating in the representation of motor behaviours, sensory information etc. with more sophisticated analysis to try and address this possible shortcoming. Dynamical systems analyses have also revealed that temporal dynamics are highly informative across a variety of experiments and regions (Linderman et al, 2016; Pandarinath et al, 2018; Ye and Pandarinath, 2021). While these analyses have demonstrated the value of representing the temporal structure of the neural signal, their application has been constrained by the considerable computational of data requirements of building generative system models. So far this has restricted their use to large datasets with single subjects or known alignment across inputs (Azabou et al, 2023). To account for both spatial and temporal structure it is necessary to take a more flexible approach to consolidating neuronal signals. One that focuses on the consistent elements of structure that are 114 present for a given representation across sessions and subjects. We sought to build a framework based on the assumption that the firing rates of neurons are samples drawn from an underlying neural manifold that we cannot fully access. This manifold is a high dimensional subspace defined by the firing of the various neurons participating in a given representation. The firing rate through time is then a neural trajectory, a path traced through the various manifolds. These manifolds can overlap, and likely do so for concurrent representations and signals with differing time courses (they are components of the overall combined representation). The goal, then, is to use these neural trajectories as a window to describing the neural manifolds they traverse, and by extension generating a description of context and behaviour representations that are consistent across sessions and subjects. To this end we focus on the representational geometry of these neural manifolds. There is strong evidence for preserved geometry in the underlying neural space in ACC in previous work we have undertaken (Lindsay et al, 2024; Caracheo et al, 2018; Ma et al, 2014) as well as in a variety of other experimental tasks and brain areas (Seamans and Floresco, 2022; Nogueira et al, 2023; Galgali et al, 2023). The highly multimodal, non-linear, distributed encodings present in mixed-selectivity neurons lend themselves to geometric population measures as a method to approach this complex representational mapping. Traditionally geometric analysis of population encoding has been carried out using simple metrics such as distance measures or covariance. Recently, more sophisticated approaches focus on structure across multiple dimensions; Informative relationships in neural data may manifest in dynamics across spatial dimensions, between neurons, temporal dimensions, through time, and across trials, but still approach the analysis as a linear latent decomposition (Pelligrino et al, 2024). In the present study, we opted for a purely geometric approach, building on a selection of state-of-the-art analysis techniques from topological data analysis and computer vision. We utilized these tools to define and describe the neural manifolds underlying the neural representations of interest. Finally, with these descriptions in hand, we identified structural consistency as well as differences in the way emotional 115 context and behaviour are represented in ACC, and forwarded our functional understanding of how context modulates behaviour as part of a complex, multi-modal representation. Methods: Extracting and Labelling Behaviour: Subjects were recorded by a custom setup of two synchronized colour video cameras, one camera side-on to the enclosure and another camera below. Automated feature tracking was performed on combined videos using DeepLabCut (Mathis et al., 2018). 3-d tracking data from DeepLabCut was post-processed to yield animal pose data agnostic about location in the enclosure as well as the direction or orientation. We then passed this data to our behavioural discovery tool, HUB-DT. Hierarchical unsupervised behaviour discovery (HUB-DT) (Lindsay, 2024) quantifies behaviours based on a spectrographic projection approach. Spatial and temporal features from the pose data are discretized together into a behavioural space by this projection, and then hierarchical density-based clustering is applied to label distinct behaviours within this space without supervision. The behaviours labelled by HUB-DT are therefor clusters of common changes in pose (relative body part locations) that evolve over a range of timescales. Here behavioural discovery and labelling was performed across the entire data set at once, providing a set of common behavioural labels across all experimental sessions. CCA: Canonical correlation analysis (CCA) is a variant of the supervised partial least squares method for dimensionality reduction and regression (Wegelin, 2000). These cross-decomposition methods find the relation between two matrices by maximising the covariance between their transformed (low-dimensional) forms. Unlike principal component regression, the selection of components is supervised 116 (by covariance with the second input matrix), allowing the selection of relevant components rather than only those of highest variance. As a consequence of the least-squares method, CCA is restricted to representing (kernel)-linear relationships between features in its input matrices (in our case, between neurons). This renders it likely insufficient for capturing the necessary dynamics for cross-session decoding, but it is still useful as a means for aligning projected neural trajectories for visualisation. Takens Embedding: From Takens’ theorem for the reconstruction of dynamical systems (Takens, 1981), a Takens embedding is a form of time delay embedding, a sliding window of fixed size over a signal, where each window can be represented as a point in a higher-dimensional space. Time delay embeddings depend on two main parameters, the embedding dimension and the time delay, and one additional parameter, the stride or overlap between adjacent windows. These parameters can be determined algorithmically from a given time series. We use a mutual information measure to determine the optimal time delay, and the ‘false nearest neighbours’ procedure to determine the optimal embedding dimension. Together this yields an optimal embedding for the most informative dynamics in the time series, in our case the most dominant temporal signals contained in our binned spike counts. These time delay embeddings of time series are used to reveal the underlying topology of the primary dynamics in the signal. This can be done by performing topological data analysis on the resulting point clouds, an analysis approach that will be discussed in more detail below. However, the simple application of time delay embedding to neural data is insufficient to enable the application of these methods. The timeseries of spike counts are noisy, and as discussed above, are unaligned with each other across sessions and subjects, as well as with relevant task factors of interest. Aligning this data, 117 both temporally and by neuron identity, or rather their role in a given neural representation, is non-trivial. Performing this alignment requires accounting for informative structure both spatially and temporally simultaneously. In response to the alignment challenge, we propose utilizing a modified version of the PointNet approach (see below), a geometric neural network originally built for object recognition and sementation, which is able to achieve this alignment while also providing meaningful output to downstream analysis as a result of its geometric latent space. Figure 4-1 118 Figure 4-1. Labelling behaviour with HUB-DT. Behavioural labels are generated using our unsupervised behavioural annotation tool, HUB-DT. A-F) An overview schematic of how HUB-DT categorizes and labels behaviour from video. Feature tracking is input from DeepLabCut (Mathis et al., 2019). These features are projected via a set of morlet wavelets to produce a high-dimensional spatiotemporal behavioural manifold. This manifold is projected into a 2-D density map, which is then clustered using a hierarchical density-based clustering method. Each distinct cluster is then assigned a behavioural label. G) A breakdown of the ‘prototype’ of a single behaviour from HUB-DT. This prototype is comprised of the set of mean wavelet amplitudes that describe the spatiotemporal changes in pose indicative of this behaviour. H) The set of labelled behavioural clusters for the multi-session dataset. HUB-DT was run on a combined set of sessions, and produced a consistent set of behavioural labels across all sessions. Figure 4-2 119 Figure 4-2. Generating neural trajectories from spike count data. A) The Lorenz attractor is used as an example of generating a set of trajectories from time-series data. The time-series of the attractor is split into fixed length, fixed partial overlap temporal trajectories. These trajectories share the same dimensionality of the input time-series, 3-D in the case of the lorenz. B) Neural trajectories are generated from a time-series of time-binned neuron spike counts. Illustrated is the division of the spike count matrix into fixed length trajectories (one for each interval) with partial overlap. The length and overlap of the trajectories are based on maximally-informative dynamics as measured by an adaptive Takens embedding. The illustrated example trajectories are projected down to 3-D for visualisation, but the full neural trajectories are in high-dimensional space, one dimension for each neuron. PointNet: The PointNet (point net) (Qi et al., 2017) is a neural network model designed to perform identification (classification) and segmentation based on point cloud input data. [Note, any discussion of artificial neural networks, their design and architecture, alongside neural data and neural representations brings some unavoidable overlap in terminology. We will endeavor to be clear in which sense we are applying a particular term to avoid confusion]. While originally conceived to operate in the space of computer vision, its properties have proved more generally applicable. These properties stem from its architecture, which was designed to accommodate the unique challenges presented by operating on raw point clouds. In the original paper, the authors emphasise three key points: • Unordered: Point clouds do not have a fixed order. In the computer vision case, the surface scan could return points in any permutation. For example, a surface scan of an object like a chair need not input the points defining the seat of the chair together, or indeed in any particular order. As such, the network needs to be invariant to the order of its inputs. • Transformation invariance: Objects and their associated surface point clouds can be rotated or at different sizes. The network should be invariant to these, accommodating inputs that are at arbitrary scales or orientations. 120 • Point interactions: The spatial relationships between individual points can be meaningful. The network should be able to capture structure from nearby points and interactions between these structures The point net handles these challenges through a remarkably simple design. The bulk of the network is made up of shared multi-layer-perceptrons (MLPs), functionally convolutions, each applied independently to all the points in the input. These convolutional layers produce a spatial feature embedding, representing the structure of the input. The order invariance is provided by a single layer implementing a simple symmetric function (a function whose output is the same regardless of the order of its inputs), maximum pooling. This pooling layer aggregates a global feature vector from the high-dimensional feature embedding that is agnostic of the order of points in the input. The networks transformation invariance is provided by a pair of spatial transformer modules, described in more detail below, inserted between the blocks of shared MLPs. Finally, a simple fully-connected network maps the global feature vector output from the pooling layer to a set of probabilities for the possible output classes. Transformers: ‘Transformer’ is the blanket term for a type of neural network that performs transformations on inputs based on other inputs around them. This is opposed to the architecture of many multi-layer perceptron (MLP) or feed-forward models that process inputs independently through a shared set of operations or filters. Transformers as parts of larger neural networks are at the heart of the current surge in AI/ML development, spurred on by their demonstration in the seminal paper, ‘Attention is All you Need’ (Vaswani et al., 2017). There is considerable variation in architecture in transformers across various network designs, but the transformer as a component usually serves a 121 similar role. Their function as part of a larger overall network is typically to encode context; in other words, to modify the embedding of a given input based on the inputs around it (this mechanism is often referred to as ‘attention’). In a generative large language model, transformers act to contextualize the semantic embedding of a given word based on the words appearing before it. This semantic context can be quite extensive, thousands of words long in the case of some models, and is a significant part of the large language models’ power to generate meaningful output. The transformer plays a more limited role in the point net, but still serves to encode the informative relationships between inputs. Motivated by the use of specialised transformers to perform spatial alignment for images (Jaderberg et al., 2016), the point net architecture contains two transformer modules to perform a similar role. The first transformer learns from the inputs’ common meaningful patterns, i.e. frequently co-occurring spatial patterns in the input that are informative of the class separation the network is attempting to learn. The trained transformer then contextualizes inputs by projecting them into a canonical input space, aligning the input by these common patterns. For example, in the computer vision case of training a PointNet to classify common household objects, the network frequently encounters edges and corners, and the spatial transformer would utilize these common patterns to rotate and resize inputs into a canonical alignment. The second transformer module functions similarly, but instead of operating on the inputs themselves, it instead aligns features (output from the filters in the previous layer of the network) into a canonical feature space. 122 Figure 4-3 Figure 4-3. Formatting data for the neural trajectory point net. We built a combined dataset for all experimental sessions. Sets of neural trajectories were created from time-binned spike counts from each session following the procedure in Figure 4-2. To maintain fixed dimensionality for the neural trajectories, each sessions neurons were sampled to a consistent number (32 for most instances. Individual session neuron numbers vary from ~50-100 neurons). This sampling was permuted across dataset creation for model testing. Each trajectory had accompanying labels for each timepoint in the trajectory generated as follows. Emotional context (colour coded: Blue=Neutral, Green=Food, Red=Shock, Grey=Inter-context period) labels and behaviour labels (shown as variable length blocks of assorted colours, one colour corresponding to each behaviour, length corresponding to the number continuous time bins in that instance of the behaviour) were applied to each time bin. The sets of neural trajectories were then combined into one ‘mega dataset’ alongside the matching emotional context and behaviour labels. Neural Manifolds as Point Clouds: The properties of point clouds in the computer vision problem space have parallels in a neural data space. If we consider a series of binned spike counts, or instantaneous firing rates, as a series of points in a high dimensional neural space (each neuron is a single dimension), a collection of these points defines a point cloud. Rather than an object of interest defined by points from 123 a surface scan, we have neural state, or its manifold, defined by the corresponding series of binned firing. Changes in the identities or order of neurons in a recording, as occurs when utilizing data from different sessions or subjects, changes the order of individual neurons that define each point in the space. Re-ordering the neurons transforms the underlying manifold as the dimensions defined by individual neurons change places. Similarly changes in correlated noise, signal strength etc. serve to translate or scale the manifold. Where neural data departs from point cloud equivalence is in its order. Unlike surface scans, binned firing does proceed in a fixed order and we expect there to be informative temporal components in the neural representations. However, these temporal dynamics are varied, and as described above take place at a variety of scales. While aligning neural signals with fixed events, such as stimulus or reward delivery is relatively straightforward, aligning with long-term states like our ‘emotional contexts’ is ill-defined. When we consider fixed-length trajectories of neural activity as point clouds, we can leverage the order invariant properties of the point net to accommodate mismatches in these dynamics by flexible alignment. The network can permute trajectories while maintaining the informative temporal dynamics captured by local structure. This allows us to use a consistent set of fixed-length trajectories to compare representations of different kinds, such as emotional context and behaviour, even if the underlying temporal dynamics and alignment vary between them. Neural Trajectory Point Net (NTPN): The point net is well suited for the dissection of neural representations of context and behaviour. It is robust to noise, and is invariant to the order of inputs (orientation), scale, and position of neural manifolds, enabling its application on data from across sessions. As a consequence of its design, the point net learns a canonical representation of its inputs, and these representations are amenable to downstream geometric analysis. However, it does require 124 some modification to accommodate neural data as input and to promote interpretability. These changes result in an adjusted point net model, which we have named the Neural Trajectory Point Net (NTPN). The transformer layers in the NTPN function as in the point net above. The act of projection into a canonical space can be thought of aligning the neurons in the input into a shared, cross-animal, cross-session neural space. This is similar to the alignment performed by a method like CCA, except that the transformer version maintains the full dimensionality of the neural space and is much more flexible, allowing it to represent non-linear relationships between neurons in the input. Processing neural data into neural trajectories: Data is pre-processed into neural trajectories before being passed on to the NTPN as input. Our data in its raw form is a set of binned spike counts, with a length corresponding the length of that session and each bin containing a spike count or iFR for each of the recorded neurons in that session. This neurons x bins matrix is randomly sub-sampled across neurons, to yield a fixed dimensionality dataset (recall that the dimensionality of the neural trajectory is determined by the number of neurons, each neuron by its firing rates defines an axis in the neural space). This fixed dimensionality data is then split into trajectories of fixed length. The length is set by the maximally informative dynamics identified by the Takens embedding. Adjacent trajectories partially overlap, but are unaligned with any particular task factor. The set of trajectories completely covers the length of the session. This results in a dataset of neural trajectories, each of fixed length and of fixed dimensionality. Evaluating the NTPN features on neural data (ablation): To evaluate the efficacy of the point net’s design features on neural data, we performed a series of ablation tests comparing the emotional context decoding accuracy of different neural network architectures on fixed data sets. We constructed 125 two versions of fixed dataset for evaluation. First, we combined all sessions into one ‘mega’ session. This session was pre-processed as described above (a set of 32 neuron by 32 bin trajectories, 0.2s bins, labelled by emotional context), and then split into training (81% of the data), validation (9% of the data), and test portions (10% of the data). Network variants were fed the training and validation sets for training, and were then evaluated on the test set. While this test set is completely unseen by the networks during training, it contains elements from multiple sessions as it was constructed from the ‘mega’ session. To evaluate session specific learning amongst the networks, we construct a second fixed dataset; here an entire session is held out as test data, and the remaining sessions are used for training and validation sets. Figure 4-4 Figure 4-4. Feature ablation on the neural trajectory point net. Tables of classification accuracy for the full NTPN model and degenerate model versions with features/constraints removed. A) Models were trained, validated, and tested on a mega-dataset of all session. Here, testing data is totally unseen by the models during training, but is drawn from the same sessions. The model versions are the full NTPN, the NTPN with the spatial transformer modules removed, the NTPN with the global feature pooling module replaced with a fully-connected down-sampling module, and finally a model with both changes. Each row lists the baseline accuracy (%) of the full model, and then changes in accuracy (positive or negative) from the baseline for each degenerate model. B) As in A, but with an alternate dataset. Training and validation were done using a combined multi-session dataset, but testing was performed with an entirely separate, held-out session. Again, rows list the baseline accuracy and changes from the baseline for each model. 126 Performance on these fixed datasets was evaluated for four different network architectures. The baseline model is the full NTPN as outlined in Figure 4-5. The ‘transform -’ model follows the same architecture but with the transformer modules removed, limiting the networks’ ability to do canonical alignment of the inputs and features. The ‘pooling -’ model swaps the max pooling layer for a fully-connected layer. This maintains output dimensionality to the fully-connected classifier, but swaps the symmetric aggregation of features into a global feature vector for a non-symmetric version. Finally, the ‘transform - pooling -’ model has both changes together, and is roughly equivalent to a simple convolution net of the same size. The gains from the transformers and their canonical projection are modest (Figure 4-4), similar to what was reported by the authors of the original PointNet. In our case, if the network is sufficiently expressive, it may be able to accommodate multiple rotations in feature space without a loss in performance. This is supported by the larger effect present in the unseen session comparisons, as rotations present in the unseen session may be entirely unaccounted for in the trained network. The global feature pooling has a much more dramatic impact on the generalisation of the network. This suggests that the NTPN’s ability to permute and align the trajectories in response to variable temporal dynamics is a significant portion of its ability to generalize on unseen neural data. The slight recovery in performance in networks missing both transform and pooling layers is likely due to an increase in flexibility in the network as a whole, enabling it to memorize more of the informative inputs. Our dataset is of limited size, and while the networks are not capable of fully memorizing the data, this likely plays some role in the network comparison. Overall, the key design features of the PointNet architecture make it well suited to generalizing decoding across subjects and sessions based on neural trajectories and its geometric basis provides purchase for the further analysis of neural representations and their underlying manifolds. 127 Figure 4-5 Figure 4-5. The Neural Trajectory Point Net: Step-by-step 128 1. Binned neuron spikes from electrophysiology recordings are embedded as fixed length temporal trajectories in neural space (each dimension of this space corresponds to the firing rate of a single neuron) 2. These neural trajectories are input to the first connected layer of the network. 3. The first of two spatial transformers. Transformers weigh each element of an input according to what is important or common. Here it creates a transformation matrix to appropriately weight spike count trajectories based on commonalities across all trajectories. This serves to align the inputs based on learned patterns of firing. The transform is agnostic of the identity of contributing neurons and the order of the trajectories, and is robust to the scaling and relative position of the patterns of interest. 4. A multi-layer perceptron (MLP). MLPs are trained to find common patterns or features. In this case, the MLP is trained to recognize common trajectory shapes (features) from the aligned inputs it receives from (3). It maps or embeds the inputs from (3) into this new feature space. This network is shared, meaning each input undergoes an identical and independent embedding. 5. The second spatial transformer performs another transformation, this time on the embedded features from (4). This second transformation serves to align learned structure in the feature space, as opposed to the first transformer which aligned in input space. These transforms in conjunction provide invariance to rotations, translation, and scaling in the inputs/features. 6. The second MLP. Features are again embedded into a higher dimension space by a second shared MLP. This MLP works as a pattern detector for the aligned feature space received from (5). Just as with the first, each feature is embedded by the same network, ensuring order invariance in the embedding. 7. The high dimensional feature space is reduced to a set of global features via a max pooling operation, yielding an aggregate signal of the entire input trajectory. Applying only symmetric operators ensures that the resulting set of global features is invariant to input order and identity. 8. A three-layer fully-connected MLP classifier predicts a set of class probabilities (in our case it could be the 3 emotional contexts or a set of behaviors) from the global features. 9. These class probabilities form the output of the network, predicting behaviours and emotional contexts from a set of neural trajectories. The structure of these trajectories is reflective of the dynamics of the neural system. The NTPN is invariant to perturbations of these trajectories by rotation, translation, and scaling, is robust to noise, and critically is invariant to the order (and identity) of the neurons whose firing makes up the input neural trajectories. Together, these allow it to learn to predict behaviour and context across both experimental sessions and subjects from neural data without alignment or sorting. A. A stylized example of how neural trajectories are transformed by the point net into a set of global features. Illustrated is the passage of a set of 1D trajectories through each step of the network. First, the inputs are aligned for local structure via a spatial transformer. These aligned inputs are then embedded into feature space by a set of shared filters. The embedded features are aligned for structure in feature space by a second spatial transformer. A second feature embedding generates a set of meta-features, or features of features. This final feature space is then collapsed to a set of global features by pooling the maximal responses. B. Relevant structure of the input neural trajectories and their underlying neural manifold can be extracted from the network. Critical sets: the subset of each trajectory that was informative to the network in assigning it an output class. Upper-bounds: the bounds of each class as set by the invariances of the network; samples of a given class lie between the minimal ‘critical set’ and the ‘upper-bound’. Topology: the extracted features are examples of high-dimensional geometry, shapes, for each of the associated neural manifolds. These shapes can by analysed further for their topology and other geometric properties. 129 Critical Sets: The PointNet, and by extension the NTPN offers insight into the structure of its inputs via its embedding and transforms. As discussed by the models’ authors, the global feature vector is directly related to the overall expressiveness of the model. They refer to the dimensionality of this vector as the ‘bottleneck dimension’ of the network as it provides a ceiling on the number of points in the input that can contribute to the classification of an input; as the symmetric pooling operation only selected the maximally responsive point for each filter or feature in its input. We can query the network for any given input about which points contribute to and define this global feature vector for that input, and this set of points is referred to as the ‘critical point set’ for that input. This critical point set is a sparse representation of informative points, and in our case represents the subset of timebins within a trajectory that are critical to decode it. For downstream analysis we extract critical point sets directly from the trained network for given inputs. Upper bounds: Just as the critical point set represents a minimal input for a given class, there similarly exists a bound on points which can be added to the input without changing the resulting global feature vector. In the PointNet this is referred to as the ‘upper-bound shape’, together with the critical point set define the range of inputs which result in equivalent global feature vectors; any input between the critical point set and upper-bound will result in the same classification output. In the PointNet, defining upper-bound shapes can be done by sampling the space of possible inputs (a unit cube in standardised input space) keeping points which do not affect the global vector. This unit sampling approach is more difficult to achieve and visualize in the neural space, so a modified sampling technique is used to generate neural state upper-bounds; The set of critical point sets for each neural state of interest is first aligned and then extensively sampled to provide rough bounds that approximate this upper-bound shape. An example of how critical sets and upper bound shape are derived is shown in Figure 4-6. 130 Figure 4-6 Figure 4-6. Critical sets and bound shapes. A) Schematic of extracting a critical set for a given example input trajectory. For each input, the trained NTPN is queried for the points in the trajectory that are maximally responsive on each feature (points which influence the global feature vector). Those critical points form a subset of the original trajectory, a critical set. B) Critical sets are aligned with each other via a shared UMAP projection followed by CCA. Plotted are three example groups of aligned critical sets. C) Bound shapes are generated from a set of aligned critical sets, all belonging to the same class. This set of sets defines the space of the underlying manifold that is visited across the population of trajectories and is relevant to defining the class (as it is a combined set of critical points). This set of sets is spatially sampled to produce a bound for the manifold, which we visualise as a voxelized partial surface. Visualising Neural Space: The neural trajectories and underlying manifolds have a dimensionality dependent on the number of neurons in the sample. These high-dimensional representations can be projected down to lower-dimension spaces by embedding to allow for visualisation in 2-D or 3-D. Uniform manifold approximation and projection (UMAP) is an embedding method for producing a lower dimensional projection of the original data. UMAP first constructs a ‘fuzzy topological representation’ of the input data, and this topology codifies the local structure of the data in its native high-dimensional form (for further details refer to the UMAP publication: McInnes et al, 2018). Then UMAP attempts to 131 optimize the fit (by cross-entropy) between a low-dimensional approximation of the topology with its high-dimensional original. UMAP is parameterized by the number of neighbours, used to calculate local structure, as well as the minimum distance, which controls the local density of the embedding space. Here we use the UMAP python package (https://github.com/lmcinnes/umap), with the parameters individually optimized for the various use cases. UMAP’s inbuilt plotting methods were used to produce visualisations of low-dimensional embeddings of context spike counts, and raw trajectories. UMAP’s embeddings were also used as input to several other python libraries to generate the visualisations seen here. These libraries include pyvista (https://github.com/pyvista/pyvista), PVGeo (Sullivan and Trainor-Guitton, 2019), and open3d (Zhou et al, 2018) for plotting 3-d point clouds, surfaces, and meshes, as well as giotto-tda (Tauzin et al, 2021), a library for topographical data analysis and its inbuilt implementation of ‘mapper’. Topological Data Analysis: Topological data analysis (TDA) refers to the application of methods that take a geometric approach to finding patterns or shapes within data (Murugan et al., 2019, Lum et al., 2013). Topology itself is concerned with the properties of geometric objects, or shapes, and takes a qualitative approach to describing them. These descriptions can then be expressed numerically, and used to analyse the geometric statistics of the underlying data. TDA provides an alternate route for exploring high-dimensional data from clustering methods, and is less sensitive to noise, choice of metric, and parameterization. In practice, applying TDA follows a similar process to other data analysis techniques; We first generate a geometric representation of the data, and then apply topological methods to explore the shape and connectivity of that geometry. 132 Generating Topology: A geometric description of the data is produced by generating a ‘persistent homology’ of that data. This persistent homology records the persistence of features in the data corresponding to set homology groups. Each homology group tells us about the number of ‘holes’ or ‘voids’ of a given dimension in our data. For example, homology group ‘0’ tells us the number of components, group ‘1’ the number of 1-D holes or loops, group ‘2’ the number of 2-D holes or voids, etc. By organising data into a graph, or simplicial-complex, we can read off the homologies based on the edges and structure of the graph. There are multiple methods to generate these graphs or complexes, but here we utilize an algorithm called the Vietoris-Rips complex on our neural data. We centre a circle, or sphere of the dimensionality of the input data, of zero radius at each point. Then, at each iteration, we expand this radius by a small amount, and mark our graph based on these new, expanded circles. When components meet (when the circles overlap), we connect them by an edge. When these edges form a complex with a given homology (such as a loop), we mark the ‘birth’ of that feature in that homology group. When this complex disappears, we mark the ‘death’ of that feature. We continue this process until some upper-bound radius for the circles, functionally when all the components are overlapping, is met (this is a similar process to how a dendrogram is constructed for hierarchical clustering). At the completion of the process, after the final iteration, we have a measure of the persistence of each feature, or instance, of a given homology group. i.e., the iteration from when it emerged, its birth, to when it disappeared, its death. In essence, persistent homology tracks changes in geometric features of the input shape as we change resolution, or scale. The persistence of features can be plotted as a persistence diagram, and these diagrams are then used to compare shapes by measuring the distance between their persistent homologies, either by a persistence distance metric such as Wasserstein or Geodesic distance, or directly on the homology groups via Betti distance (similar to Mahalanobis distance but on homology groups) (Figures 4-7, 4-8). 133 Figure 4-7 Figure 4-7. Generating and counting homology groups with a Vietoris-Rips complex. A toy example of generating and counting homology in a 2-D point cloud. Adapted from Murugan and Robertson, 2019. We start with a circle of radius epsilon around each point in the point cloud. A-F) At each step, we increase epsilon, and if the circles of points overlap, we connect them with an edge. In the accompanying table we record the count, bk, for each k where k is the Betti number of the associated homology group. K=0 are components, k=1 are 1-D holes, k=2 are 2-D voids, etc. At radius 1, A), there are 6 components (each of the points). At radius 3, B), two of the points are now connected, reducing the count of components to 5. As the radius is increased to 5, C), now all of the points have been connected together. The component count is now 1, and there is a 1-D hole present. D) At epsilon=6 the 1-D hole has now been filled in by an extra edge. E) There is now a new 1-D hole formed by adding an extra edge. F) Finally at radius 8, and all values of epsilon > 8, the second hole is filled in by connecting edges. Each member of each homology group has a birth, the timestep where is emerged, and death, the timestep where it disappeared. The set of birth and deaths defines a persistence diagram for the homology of the point cloud. 134 Figure 4-8 Figure 4-8. Persistent Homology. Schematic detailing the creation of a persistent homology for a point cloud. A) to F) Iterations of the Vietoris-Rips algorithm as detailed in the preceding figure (the tables list the Betti number, k, and count of instances, bk, for each homology group). For steps B, D, F corresponding persistent homology tables are presented. For each of the two homology groups (k0, k1) present in the example point cloud from the preceding figure, a table is populated with the birth and death iterations of each instance of that homology. The difference between the birth and death (number of iterations) for each instance of a homology, determines that instances’ persistence. These tables can be plotted as a persistence diagram. G) An example persistence diagram for a 3-D point cloud. Instances of each homology group (k0, k1, k2) are plotted as coloured dots. Their distance from the birth=death diagonal is their persistence. A persistent homology of this type is generated for each point cloud of interest (neural trajectories, critical sets, bound shapes). Difference between point clouds can be measured by the distance between their persistent homology tables, or equivalently, persistence diagrams. 135 Mapper: Mapper is an algorithm that takes an alternate approach to describing shape, by the application of a selected lens or filter. A lens is a function that maps the data from its raw input space to some, usually lower-dimensional, real valued space. Mapper first applies this lens to the input, and then constructs a cover of the filtered values. This cover is a set of overlapping intervals, with fixed size and overlap. This cover is then applied to the raw data (i.e. points that are in the same interval in the filtered space are assigned the same interval in the raw space). Each portion of the cover is then clustered, in our case using a density-based clustering algorithm. Finally, mapper constructs a graph of the clustered cover connecting components if elements of clusters are shared across intervals (this is referred to as the ‘nerve of the refined pull back cover’, which is another form of simplicial-complex, similar to what is generated by the Vietoris-Rips algorithm above) (Figure 4-9). For application on neural data, we utilize a density-based clustering algorithm (DBSCAN) to cluster the cover, and filter utilizing UMAP. The resulting graph provides an informative visualisation of the underlying high-dimensional topology in 3-D and provides a mechanism for comparison between different input shapes. 136 Figure 4-9 Figure 4-9. Mapper: generating topology from structure. A schematic and example comparing two different means for generating topology from point clouds. A) Vietoris-Rips complex builds a topology from persistent homologies. Circles of expanding radius grow from each point, forming transient homologies. These homologies and their persistence describe the underlying geometry of the point cloud. B) A toy example of generating a topology using the mapper algorithm. Adapted from Murugan and Robertson, 2019. A geometric description for a 2-D point cloud is generated using mapper. In this example, the point cloud is filtered via a 1-D height function. A cover is then generated for the 1-D projection, dividing the original points into overlapping intervals. Points belonging to each interval of the cover are then clustered in the original 2-D space. Finally, a nerve of the pullback cover, or map, is made from the clusters. Edges are drawn between clusters that share points across overlapping intervals. With appropriate filter and cover functions, mapper produces a graph representation of the structure in the original point cloud. 137 Figure 4-10 Figure 4-10. Classification accuracy for the NTPN. A) Classification accuracy for NTPN run on an example trajectory system with known properties, the Lorenz attractor. Testing data is unseen by the network during training. Peak accuracy was 99% for classifying true versus shuffled trajectories, and 76% training and 75% testing for classifying trajectories from high versus low chaos regimes. B) Classification accuracy for the NTPN on select behaviours, using a combined multi-session dataset. 77% peak training accuracy, and 84% peak testing accuracy. C) Classification accuracy for the NTPN on emotional context. Shown are paired training and test accuracies for single sessions (averaged), paired sessions (averaged) and for all sessions combined. All plots show adjusted chance with a dotted line. 138 Results Geometry of Neural Representations in ACC Our goal was to extract a set of descriptions of the neural representation of emotional context and behaviour in the ACC. We achieved this by focusing on the geometry of neural trajectories (firing of neurons through time) and the neural manifolds they travel through. This geometry describes both the structural arrangement of neurons in neural space, patterns in firing amongst sets of neurons, as well as the temporal dynamics, the patterns in firing through time. In order to access this geometry, we first aligned our data via the NTPN. In this case, the NTPN addresses the spatial relationships, via its transformers, and temporal relationships via the global feature projections. By these mechanisms, the resulting representation of an instance of a given class, by which we mean an emotional context or behaviour representation, has definable and describable geometry. Application of the NTPN provided consistent, coherent geometric descriptions of neural manifolds for emotional contexts and behaviours across sessions and subjects. Testing the NTPN on a known system As a sanity check for its performance on a dynamical system with known properties, we assessed prediction on variations of the Lorenz attractor. We generated two datasets of Lorenz attractor trajectories: first with trajectories taken from Lorenz of high and low rho values (rho determines how chaotic a given system is), and a second dataset of true versus shuffled Lorenz trajectories. Lorenz trajectories were tested at a variety of lengths, but for the purposes of the direct comparison reported here the length was matched to that used for the neural trajectories (32 x 0.2s bins). Shuffles were across trajectories, as within trajectory shuffles are accounted for in the NTPN by global feature 139 projection. The NTPN performed well on both prediction tasks, and was able to consistently separate trajectories from different Lorenz systems (Figure 4-10) as well as easily identify trajectories that had been shuffled (Figure 4-10). Decoding Emotional Context and Behaviour We assessed the application of the NTPN first by its prediction accuracy, i.e. its ability to decode class based on neural trajectory input. As shown in Figure 4-10, the NTPN performed similarly well in decoding both emotional context and behaviour. Interestingly, emotional context decoding varied between contexts, suggesting that food and particularly shock states are more distinct geometrically than the neutral state (Per context cross-session accuracy: N: 73.81%; F: 83.11%; S:89.07%). Of note, is that this consistent performance is across inputs from different sessions and different subjects, highlighting the ability of the NTPN to extract meaningful consistency in the geometry of the input trajectories. In addition, this performance is preserved in different tasks, even though the underlying primary temporal dynamics (between context and behaviour) are likely different. Latent representations extracted from the NTPN The NTPN generates embeddings for each neural trajectory, which are ultimately represented within the network by an inputs’ global feature vector. This vector encodes the network response to that trajectory, but also by the mechanism of the point net encodes the set of points in that trajectory that are informative in determining its class. Recall that the global feature vector of the network is generated from pooling maximally responsive inputs for each of the features learned by the network yielding a direct and interpretable relationship between the raw input points, the neural trajectory, and its global feature vector. The global feature vector itself is fed downstream to the MLP network for classification, 140 but can be queried for the subset of inputs which contributed to it. We compare these ‘critical point sets’ to their raw trajectories directly by visualising them in the neural space. We project this space down to 3-D via UMAP for viewing, and align the trajectories to permit multiple comparisons (Figure 4-11). Viewed in this way, the critical set can be seen as a simplification of a given trajectory, retaining only those features of the path (points in time) that were relevant to the encoding of a given context or behaviour. En masse, these critical sets can be used to define the underlying neural manifold, disentangling it from other concurrent representations. We aligned and sampled sets of critical sets for each emotional context and behaviour learned by the NTPN. This sampling provided an estimated surface of each manifold, a ‘bound shape’, defining the bounds of points in neural trajectories involved in that representation. We visualized this estimated surface via a voxelated projection to 3-D space (example in Figure 4-6). These visualisations provide qualitative measures of the geometry of class associated trajectories and their neural manifolds. To find more complete geometric descriptions, and to provide quantitative measures and comparisons we turned to the field of topographical data analysis. The critical sets and bound shapes extracted from the NTPN formed the inputs to those techniques. 141 Figure 4-11 142 Figure 4-11. Trajectories to Critical Sets. A comparison between a selection of raw neural trajectories and critical sets extracted from the NTPN. Critical sets are of reduced complexity compared to raw trajectories from the corresponding class, as they are the subset of informative inputs that produce the global feature vector for that sample. Distinct class features are easier to observe in critical sets, and their corresponding geometry is similarly distinct. Representative samples of aligned trajectories and critical sets are shown for each emotional context. A) Neutral, B) Food, and C) Shock. D) Procedure for generating critical sets from neural trajectories. E) Procedure for generating visualisations of trajectories/critical sets. 143 Figure 4-12 Figure 4-12. Differences in the geometry of neural representations: Mapper. 2-D views of 3-D graph/map plots from the ‘Mapper’ algorithm. Bound shapes of emotional context representations and select behaviour representations were processed as point clouds by Mapper to produce graph representations of topology. Point clouds were filtered using a 3-D UMAP projection, and intervals were built with a cubical cover. Clustering was done using a density-based clustering method. The resulting structure-based topology was graphed in 3-D using the same 3-D UMAP projection. Scale is relative for each Mapper projection. A-C) Mapper visualisations of emotional context representations. Structure within the graphs is representative of the geometry of the bound shapes for each of the contexts. D-F) Mapper visualisations of behaviour representations for 3 select behaviours. Again, structure in the graphs is indicative of the unique geometric structure of the neural representation of that behaviour. There are marked differences between the structure of these neural representations, in particular between emotional contexts as a group and behaviours. 144 Visualising geometry with Mapper Applying Mapper to the ‘bound shapes’ of emotional context and behaviour extracted from the NTPN provided a visual representation of the high-dimensional geometry of those shapes projected down to 3-D. To reiterate, structure within the 3-D graph of one of these bound shapes is representative of structure present in the neural manifolds in raw neural space that these shapes correspond to. Each emotional context bound shape maps to a distinct, coherent graph via Mapper (Figure 4-12). The distinct structure in the graph connectivity is the topological signature of that context in neural space. Larger nodes indicate highly-frequented (appearing on the path of critical sets, and their corresponding trajectories), or equivalently densely-packed, areas of the manifold. Dense connectivity indicates strong relatedness between nodes, or equivalently that the manifold has low-variance across multiple dimensions (recall that dimensions in neural space represent the activity of relevant neurons) in those areas. When we compared these emotional context visualisations to those generated from the bound shapes of behaviours, the differences were striking. In the maps of these three select behaviours (Figure 4-12), the overall graph structure is markedly different than that seen in the context shapes. The behavioural shapes are less coherent, being divided into multiple disconnected, or tenuously connected graph sections. This division of the underlying manifold roughly corresponds to each emotional context, although the mapper process is not informed by these contextual labels. There is likely correspondence between this separation in the topology of the behaviour manifolds and the distinct remapping of behavioural representation between emotional contexts that we highlighted in previous work (Lindsay et al, 2024). The degree of this separation is not necessarily consistent between different behaviours, as shown in Figure 4-12. It is possible that this difference is due to the relevance of a given behaviour in a particular context, or to its location within the geometry of the representation (these possibilities are not mutually exclusive). Nonetheless, simply through visualisation of the underlying topology of these 145 upper bound shapes, we can see distinct structural differences between individual emotional contexts, individual behaviour, and between contexts and behaviours. Figure 4-13 Figure 4-13. Measuring the distance between topologies. A) Pairwise distances between the topology of behavioural representations using the Betti distance metric. Topology for bound shapes for each behaviour was generated by a Vietoris-Rips complex. The resulting persistence diagrams are pairwise compared by Betti distance and plotted in a diagonal matrix (the matrix is reflected across the diagonal). B) Pairwise distances between the topology of emotional context representations. C) Pairwise distances between the topology of behavioural representations and emotional context representations. The top three rows are behaviour, and the bottom three are context. Scale across the three plots is relative, as Betti distance depends on both the distance between and number of persistent homology generators in each shape’s persistence diagram. D) Complexity of critical sets. Plot of the dimensionality (mean) of the sets of critical sets for emotional context and behaviour representations. 146 Distances between geometry The differences in geometry between the representations of emotional contexts and behaviours can be quantified via measurements of their topology. To achieve this, we extracted the topologies of the bound shapes of context and behaviour by the Vietoris-Rips complex. This process yielded sets of persistence measures for the distinct topologies within these shapes (homology groups). We then measured the distances between these sets of persistent homologies to produce pairwise distance matrices for each comparison. When we examined the resulting distances within task (between contexts, or between behaviours), there was consistent separation between the geometries (Figure 4-13). While both context and behaviour exhibit this separation, the distances between contextual representations are larger than those between behaviours, indicating that the structure of the representations of emotional context are more distinct than those of behaviour. When the distances were compared between tasks, between behaviours and contexts, we observed that in addition to the differences in within-group distance, the between-group distance is again larger; i.e. the contextual and behavioural representations are topologically more distinct from the other group compared to other representations within the same group. Just as the shape of critical sets en masse is a representation of the overall shape of the neural manifolds, the complexity of critical sets is also representative of the complexity of the associated manifold. By complexity here, we mean the information capacity of the shape; a simple shape can be represented, and discriminated by relatively few points. A complex shape, or set of shapes that define the representations of a given group, emotional context of behaviour, requires more points to differentiate between them. We measured this relative complexity simply by comparing the size, or 147 dimensionality of critical sets between the different representations. Within group critical set dimension varies between contexts and between behaviours. Within context, dimensionalities are significantly different for all comparisons (N vs S: t=10.7, df=198, p< 0.01; F vs S: t=15.4, df=198, p < 0.01; F vs N: t=6.81, df=198, p < 0.01), although the separation of shock from food and neutral is more distinct than between food and neutral. Within behaviours, some, but not all comparisons are significantly different (A vs C: t=-0.56, p>0.01; B vs C: t=-6.56, p<0.01; B vs A: t=-5.49, p<0.01), suggesting that the behavioural representations are of similar complexity within group (Figure 4-13). However, there is a much larger difference in dimensionality between groups. The emotional context critical sets, and by extension the shape of the underlying neural representation is relatively more complex than that of select behaviour. This result is in line with our expectation that the behavioral representations are contained within broader contextual representations, and are remapped or modulated along with many other relevant representations by the more complex, multi-modal context signal. 148 Figure 4-14 Figure 4-14. Comparing neural trajectories between emotional contexts using Mapper. 2-D views of 3-D graphs of topological structure generated using Mapper. Here Mapper was applied to sets of raw trajectories, A), and critical sets, B), from all three emotional contexts. These sets were filtered using UMAP, and divided by a cubical cover before density-based clustering was applied to each interval of the cover. Node scale and colour is indicative of the number of trajectories/critical sets in the cluster and their identity respectively. Connections between nodes indicate overlap in the clusters between neighbouring intervals of the cover. The Mapper graph is projected down to 3-D for visualisation by the same UMAP projection. Individual emotional contexts are well separated by nodes in both the raw trajectory, and critical set maps. There is distinct, non-symmetric structure between contexts and within contexts. In addition, there are marked differences in the relative distribution of each context, and complexity of structure within and between contexts between the two versions. Relationships between emotional contexts Our descriptions of the shapes of neural representations so far have focused on extracting the topology of individual representations. To explore the geometric properties of emotional context as a whole, we will extract the topology of all three contexts together. To do this, we selected a set of neural trajectories for each of the three emotional contexts, then, using the trained NTPN, we extracted critical 149 sets for each of the trajectories. Two datasets were submitted to the mapper algorithm, a set of raw neural trajectories, and a matching set of critical sets. We then visualised the topology of the 3 emotional contexts and compared the critical sets belonging to each. As illustrated in the resulting 3-d mapper graphs (Figure 4-14), the three emotional contexts had unique geometric characteristics that occupied their own distinct portions of the neural space. Their relationships to one another, the connectivity and distribution within the graph, were non-symmetric in that there were distinct structures related to the food and shock contexts, separated by a more nebulous structure related to the neutral context. Comparing the raw trajectory graph to that generated from critical sets, there is a distinct simplification of shape, although the distribution of the contexts remains similar. For the shock context, a large portion of the complexity seen in the structure derived from the raw data is absent in the critical sets, suggesting that some of the complexity of the shock context representation may be a result of concurrent representations of other factors, as this complexity is not necessarily informative in differentiating the shock context from the others. 150 Discussion In this study we adapted and applied a series of geometric and topological analyses to extract and describe the geometry and properties of the representations of emotional context and behaviour in the ACC. We were able to provide consistent and coherent geometric descriptions of these neural representations from a complex electrophysiology dataset containing multiple recordings from different neural populations and animals. These geometries show distinct structure between contexts and behaviour, illustrating the difference in the encoding of these neural signals in ACC. The relationships between the geometries were consistent with the emotional states believed to have produced them, and are consistent with the idea that behaviours are contextualised by emotion. The results demonstrate some of the properties of varied, multi-modal representations in the ACC and provide insight into possible mechanisms of representational modulation in this part of the brain. Modulating behaviour by emotional state The involvement of the ACC in the emotional regulation of behaviour has been well established by a substantial and ever-growing body of research. Anatomically, the ACC is interconnected with a number of other brain regions involved in emotional and autonomic states (Gabbot et al, 2020; Burgos-Robles et al, 2017). The ACC is also strongly connected with multiple brain areas responsible for the generation and expression of behaviour (Leow et al, 2022; Brokett et al, 2009). Functionally, there is evidence for the involvement of the ACC in emotion in both human and animal studies: ACC neurons are known to encode internal states in rodents (Padilla-Coreano et al 2016; Johansen et al 2001), and the disruption of the connections between ACC and other regions has been shown to impact the expression and output of specific behaviours as well as reactions to stimuli across species (Jhang et al, 2018; Bliss-Moreau et al, 2021). In humans, studies have demonstrated emotional state encoding and the impact of damage or 151 removal of the ACC on emotional disorders and emotional expression (Shackman et al, 2011; Drevets et al 2008; McGovern et al, 2017; Brotis et al, 2009). Similarly, representation of behaviour in ACC is also well established, and these representations can be modulated across a wide range of contextual changes (Jung et al, 1998; Lindsay et al, 2018; Sachuriga et al, 2021; Porter et al, 2020; Bryden et al, 2019; Caracheo et al, 2018; Ma et al, 2016). Clearly there is strong evidence for the involvement of the ACC in the modulation of behaviour by emotional state. Here we have explored the geometric properties of these modulated and modulating representations in the ACC, and attempted to provide some insight on the possible functional implications. Extended context and mixed-selectivity As established, the representation of context in ACC goes well beyond that of just emotional state. In addition to contextual correlations found across a variety of experimental tasks, prior work has demonstrated contextual modulation by changes in physical context as well as task structure or rule changes (Ma et al, 2014; Ma et al, 2016). This modulation is expressed by shifts in the representation of task factors or events, and the way in which these shifts occur depends on the type of contextual change (Hyman et al, 2013; Seamans & Emberly, 2020; Ruso et al, 2021). These representations are fluidly spread across the population of neurons, and the burden of representation is proportionately redistributed as context changes. This representational framework is in line with the mixed selectivity seen in ACC and other cortical areas (Stringer et al 2019; Kira et al 2023, Rigotti et al, 2013). Mixed selectivity is an encoding framework by which multiple task factors can be concurrently represented by a population of neurons; these representations are distributed across variable groups of neurons, and individual neurons participate in multiple representations, switching between them by reweighting across the population. There are distinct advantages to this framework of network design in terms of 152 flexibility and stability of representation as well as overall network capacity (Rigotti et al, 2013, Barak et al, 2013, Fusi et al, 2016, Nogueira et al, 2023, Mazzucato et al, 2016; Koay et al, 2022; Musall et al, 2019). Critically for the present study however, is the key property of information encoding in such a schema: Consistent neural representations are a consequence of ensemble structure and relationships, rather than the strict correlation of any particular neuron with a given factor. This ensemble structure can be expressed as its representational geometry, and the properties of this geometry are a key functional component of the contextual modulation of representation within the ACC. Framing the results of topological and geometric analysis on neural data The main analyses utilised in this report focus on the geometry, or shape, of the representations of information, context or behaviour, within neural space. This neural space is defined by a set of axes, each corresponding to a single neuron, whereby a given point in this space is a vector of the firing rates of those neurons at a particular point in time. While this underlying neural space is dependent on a particular set of individual neurons, collected via electrophysiology recordings, these analyses strictly concern the properties of the representative geometries of these neural spaces. It is important to keep in mind, that all the comparisons between representations, whether behaviours, contexts, or between the two, are being made in topological space. That means that the neural trajectories that produce the representations have been aligned to one another, and the representations are scale-less, and equivalent under spatial transforms. The comparative measures are purely geometric, and as such are able to be universal across sessions and subjects, despite changes in the identity and arrangement of the actual neurons producing these neural representations. We acknowledge that this abstraction does add a layer of difficulty in making comparisons between these methods and more standard measures of neuron responsivity and neural representation, however we believe this is outweighed by the clear 153 benefits of this approach. In particular, changing a complex dynamics problem into a geometry problem. Geometric techniques address the practical difficulties in performing comparative analysis on representations on high-dimensional space. These practical difficulties stem from the underlying mathematical realities of signal processing discussed above. Information measures and learning suffer from the curse of dimensionality and struggle to isolate sufficiently representative portions of the signal, and latent, low-dimensional approximations benefit from a unifying framework to aid generalisation across data and tasks. By utilizing the NTPN and TDA, we have gained the ability to accumulate neural representations across sessions and subjects while maintaining the informative aspects of spatial and temporal dynamics in the populations of recorded neurons. In addition, as the resulting descriptive geometries are representative of the abstract class as a whole, rather than being specific to any one example group of neurons, they are more informative of possible functional considerations and network design. Defining the geometry of ACC representations Through the use of the NTPN in conjunction with downstream topological data analysis we were able to produce consistent and coherent geometric descriptions of both emotional contexts and behaviours. These descriptions are consistent, as they are seemingly robust to the inherent noisiness of ACC ensemble recordings, and more importantly are reliable and well defined across both subjects and sessions. We support this assertion by our decoding results; the NTPN is able to reliably decode class, both emotional context and behaviour, from unseen neural data including neural trajectories from completely novel neural ensembles. These descriptions are coherent, as these geometric representations are identifiable, and separable from one another, even from single trajectory examples. The sets of critical sets, the portions of neural trajectories informative of encoding a particular class, 154 form distinct groups. This distinction is both visible, in our projections of aligned critical sets, as well as topological, as they possess common and consistent geometric features. These shapes generated from sets of critical sets via the NTPN, what we are referring to as ‘bound shapes’ tend to the abstract, even as low-dimensional projections and can be difficult to evaluate in isolation. However, when paired with their topology, they are much more informative. When we focus on the differences in the geometry of context and behaviour manifolds, we see these differences manifest in both qualitative and quantitative features of their geometry. The graph representations clearly illustrate the marked structure present in the topologies of each context and behaviour. Each single emotional context is distinct from other contexts, and the same is true of the selected behaviours. Critically, the separation between the structure of contexts considered as a group and behaviours is even more distinct. This distinction is to be expected as these are two groups of representations that differ in kind; behavioural representations are a subset of the multi-modal, concurrent representations of task factors and stimuli present in ACC that are embedded within the current context. Contrast this to the emotional context representations, which are themselves a critical component of this overall context encoding. We see evidence for this distinction in the complexity of these manifolds, too. Our dimensionality analysis of the critical sets demonstrated a clear difference between context and behaviour; the contextual representations were more complex, requiring more information to define and separate them over the comparatively simple behavioural representations. The differences in dynamics between these groups are evident directly in their topology as well, and even more striking is the clear geometric signature of the embedding of behaviour within the three emotional contexts; the geometry of a given behavioural representation is projected by each of the emotional contexts, resulting in multiple distinct sub-manifolds. This behavioural shape is still consistent, in that it is reliably decodable regardless of the context in which it occurs, but has been modulated by this context. 155 Non-symmetric relationship between contexts While the emotional context and behaviour form two distinct groups of representative geometries, there are interesting within group differences as well. In addition to observations of within group differences in critical set dimension (manifold complexity) and decoding accuracy (separable geometries), we gained additional insight by shifting the perspective of the geometric mapping. When we considered the sets of neural trajectories of the three contexts together, we were able to observe the structure in the relationships between the contexts. Unsurprisingly, the structural separation between contexts is non-symmetric. To interpret these relationships, we can speculate a metric of emotional state, one that measures the distance between the valences associated with each emotional context. Along this metric, the food and shock contexts might form extremes, with the neutral context residing in between. The structure present in the mapped geometries is more complex than this simplistic interpretation, and likely represents a number of other associated context factors beyond strict valence. However, this structure, and the separation of the emotional contexts into distinct connected clusters within the geometric space suggests that the information present within these neural representations is at the very least related to some measure of this emotional state, and illustrates the consistent representation of the three emotional states at a combined population level. Critically, this is in line with, and supports previous single session and single neuron observations about these representations with the ACC. Dynamics and geometry in the ACC In a recent report, Galgali et al. (2023) investigated the dynamics of prefrontal cortical signals related to movement and decision in visuomotor tasks. Their in-depth break down of both average and residual 156 dynamics by a variety of modelling approaches suggests that the dynamics of different representations may be unaligned with one another, or rather aligned to differing timescales. Specifically, their work is consistent with a framework wherein contextual representations may operate over longer timescales, with appropriately longer dynamics than the relatively short-term representations of behaviour. These proposed distributions of dynamics are supported by our analyses as well. We utilized Takens embeddings to extract the most informative temporal dynamics across our two sets of representations and found long, multi-second dynamics in emotional contexts and much shorter single, or sub-second dynamics in behaviours. These long context dynamics are beyond those found by Galgali et al, but are associated with context as a whole, rather than just the decision epoch specifically. It may be expected that behavioural dynamics would be similarly short relative to the timescale in which they are often performed. This is in contrast to specific motor areas where pattern generators and movement representations may have much longer-lived representations (Gallego et al, 2020). Rather, the strongly transient movement related signals we observed are likely the result of input that is unaligned with the long-term dynamics of context (Galgali et al. 2023, Soldado-Magraner et al., 2023). Along these lines, it has been suggested that the rotation of representations at the input level of the network reduces the integration of irrelevant information into long-term representations (Soldado-Magraner et al, 2023). In the modeling of neural networks, both in this work and in work by others (Fusi et al, 2016; Mazzucato et al, 2016;) these long dynamics, in this case contextual dynamics, tend to dominate the network, providing a possible mechanism for the modulation of behaviour, or indeed other representations within the neural space. In general, stable latent dynamics in relatively low-dimensional manifolds are efficient for preserving representations of behaviour, stimuli, or other factors in the long term. However, the role of ACC is more complex than the simple maintenance or integration of multi-modal information. Rather, it’s role as part of the decision-making process requires the integration of these simple representations with 157 information about goals, task, and emotional state amongst others. Computationally, integrating and maintaining the requisite information requires recurrent dynamics. These long-term dynamics define the current context, their features encode emotional state along with other contextual information. Behaviours, as defined by coordinated limb movements, are represented dynamically on a moment-to-moment basis. It is likely that other representations, such as sensory stimuli, may have similar representational dynamics. The representations of behaviour and stimuli are contained within the larger, protracted context representation. Their representational geometry is projected onto that of the longer-term dynamics of the overall context. Complexity in the geometry of context is therefore expected compared to the set of concurrent, transient representations it contains. Modelling and dynamical systems approximation work suggests that the alignment of this contextual manifold is dependent on rotational dynamics, and this alignment determines or modulates the relevance of inputs, as well as ongoing representations (Galgali et al, 2023; Nogueira et al, 2023; Musall et al, 2019). In this framework, the context representations, or the latent modes of the neural manifold account for aspects of task specificity, relevance, etc. Functionally, contextual shifts should have an impact on the representational manifold defined by these longer-term dynamics, but the impact on the representations of behaviour would depend on their relevance to the context. If the dynamics of the combined context space are rotational, the modulation of behaviour and indeed, any other stimulus or factor may be dramatic in neural space, but would preserve many of the underlying geometric properties, as we have observed in our analysis. Extending the NTPN The original PointNet architecture was built to accommodate an additional class of problems beyond simple shape classification, that of shape segmentation. Here the goal is to segment portions of an input 158 shape into component parts; a common use case could be segmenting a 3-D depth scan of a room into items of furniture, walls, floor, windows etc. To solve this problem the authors added an additional module that concatenates the global feature vector with a local feature vector for each point in the input, in essence informing the network of both local and global features simultaneously to allow salient local features (for example, the shape of a chair) to inform segmentation in the context of the overall input shape (for example, the interior of the whole room). While translation to neural representations is not straightforward, it is worth pointing out that the NTPN’s capability to perform shape classification within changing context has already been demonstrated by the analyses performed within this report. Our results have demonstrated that while the representation of behaviours is modulated by context, as evidenced by the segmented topology in the mapped graphs, these representations are still correctly decoded. There is likely additional insight to be gained here however, and an appropriate dataset from a cohort of subjects with annotated behaviours and task related stimulus or task factors in defined contexts might enable the more direct application of the NTPN to neural representation segmentation. This alternate route to disentangling co-occurring representations using the point nets’ ability to utilize both temporal and structural dynamics may prove fruitful in light of the growing body of work highlighting the importance of dynamics across time, neurons, and trials in the representation of information in a wide variety of brain areas. Code Availability: Links to Github Repositories for code used in this study are linked below. HUB-DT: https://github.com/Loken85/HUB_DT Other Analysis: https://github.com/Loken85/ephys_ML_repo 159 Chapter 5: Discussion Summary The main hypothesis explored in this thesis is that neural representations in ACC are organized primarily according to emotional state, which in turn determines how cues, tasks, behaviours or other variables are encoded. The body of the thesis was broken down into three main sections, Chapters 2, 3, and 4. Chapter 2 provided a complete description of the hierarchical unsupervised behavioural discovery tool (HUB-DT). HUB-DT is a comprehensive and robust behavioural annotation tool that allows the user to label the full range of behaviours in freely moving animals without prior definition. The tool as allows the user to compare discovered behaviours to manually annotated behaviours, and to electrophysiology recording data. Provided in this chapter was a user guide to HUB-DT and a comprehensive explanation of the design motivation and functionality of the tool. HUB-DT was then applied to experimental data utilized in the other studies that make up this thesis, as well as related datasets, thereby demonstrating the ability of HUB-DT to discover behaviours of interest across multiple experiments. Chapter 3 consisted of a published study on the reconfiguration of behavioural signals by emotional state. Here we applied HUB-DT to experimental sessions from our 3-valence paradigm and performed comprehensive correlation analysis at the single neuron and ensemble level to investigate how behaviours and emotional states were encoded in ACC. Results showed that emotional and behavioural signals could be partially disambiguated, despite being concurrently represented in ACC. We also showed that context-specific behaviours were not sufficient to explain the clear and persistent separation of emotional context by ACC ensembles. Instead, the emotional context representations, presumably driven by emotional states, had a significant impact on the encoding of behaviours. This suggested that behavioural representations could be modulated by emotional state as part of a contextualized 160 representation in the ACC. The third section, Chapter 4, covered the creation of the neural trajectory point net (NTPN) and its application to ACC data from the 3-valence paradigm. We used the NTPN and topological approaches to describe the unique properties of behavioural and emotional context representations in ACC The geometric structure, consisting of both spatial and temporal dynamics between ensembles of neurons, was distinct between and within different contexts and behaviours. This work highlighted the fundamental differences in the encoding of these modalities by the ACC. In addition, the changes in representational geometry between contexts were not arbitrary, but instead seem to lie on some continuum of valence, with neutral interposed between positive (food) and negative (shock) states. Finally, the results in Chapter 4 showed that the structural geometry of the emotional context and behavioural manifolds were consistent across neural populations drawn from multiple experimental sessions and even across different subjects. Collectively, this thesis provides a comprehensive and novel perspective on how emotional states and behaviours are represented in ACC and how emotional representations might shape behavioural representations as a central aspect of ACC function. Emotion is Context The studies covered in this thesis focus on the 3-valence task, where each context is tied to a strong emotional state. In this task, the emotional component is so strong that it defines the overall context. However, evidence from other tasks have seemed to show that emotion is not the sole driver of shifts in neural dynamics. Ma et al, (2016), for example, observed the contextual remapping of actions by varying the order that the actions were performed in, as well as the physical enclosure where the actions were performed. The representations of these actions were redistributed across neural space by changes in 161 context. Other studies have shown that similar shifts in ACC ensemble dynamics can be driven by changes in task strategy (Durstewitz et al 2010; Hyman et al, 2013). Because no physical space or task strategy is motivationally neutral, however, it is difficult to state with certainty that some measure of emotional association is not being formed. Clearly in cases where explicit conditioning between a location and emotional state is experimentally induced (e.g. fear conditioning via conditioned place aversion), this emotional association is clear. But even if a task context is, for example, defined by differences in the sequence of actions as in Ma et al (2016), where each action sequence likely does not evoke a unique emotional state there could be some motivation, relevance, or other cognitive bias that contextualises the neural representation of each action sequence. Cognition and emotion are intimately linked. A link made clear when we consider the broader definitions of emotion, like what has been suggested by Fridja (1986, 2012), who refers to emotions simply as motivational states, ascribing to emotion the whole gamut of motivated actions. Or consider a perspective from cognitive science, where Bach (2009) casts emotions as cognitive modulators, such as arousal and resolution, pleasure and distress, competence and uncertainty reduction, that function solely in the service of cognition. If we accept those broader definitions of emotion, i.e. consider emotions as drivers for cognitive and behavioural modulation in general, emotional context assumes a critical cognitive role. Emotion supports motivated decision making and behaviour, learning, and social cognition. These conclusions are well beyond the scope of the work presented here, but do provide some food for thought when considering the full extent of emotional encoding and suggest that by studying emotion, we gain insights into cognition as a whole. 162 The case for the emotional contextualisation of behaviour To review, in our analysis, behaviour provides a directly observable and continuous correlate for portions of ACC neural activity. This allowed us to observe how the representation of a given behaviour was altered by changing emotional context. Behaviour is also related to the presumed ACC output, as it is an external observable indicator of emotional state. While some behaviours are contextually specific, being related to a particular valence, many behaviours were present across multiple emotional contexts. It was the representations of these common behaviours, selected via HUB-DT, rather than the context-specific behaviors, that were the focus of my analyses. Overall, the results supported the central hypothesis of the thesis, that emotional context was a main determinant of how a given behaviour was represented. However, it is relevant to ask what are some possible outcomes that would not have supported our hypothesis? For one, it could have been the case that the emotional context representations were not separable from behavioural representations. In other words, the representation of emotional context and behavior could have been more tightly intermingled, with behavioral representations strongly influencing the form of the emotional context representations. At the other extreme, the behavioural representations could have been completely divorced from the emotional context representations, not being shifted or remapped by changing context. In this case, a given behaviour would have been represented as a single cloud of points in MSUA space that remained in the same location across emotional contexts. Instead, what I observed was that emotional context was clearly the main organizing force in the neural signals, and behavioural representations were shifted by the changes in emotional state induced by each emotional context. The nature of these shift provides an interesting perspective on ACC dynamics. In spite of the impact of emotional context, it was nevertheless still possible to reliably decode behaviours, even across different subjects and sessions. As outlined in Chapter 4, the contextual shifts transformed the representational 163 manifold of behaviour within neural space, rotating, translating it or changing its scale, but maintaining its geometry and internal structure. This suggested that while the behavioural manifolds are shifted across neural space by changes in emotional context, the shifted behavioral manifolds nevertheless always exhibited a unique and identifiable structure. Once again, this need not have been the case, as each new context could have triggered a complete reorganization of the behavioral representation, with the new behavioural manifold bearing little resemblance to the old manifold. Such a result would have meant that changes in emotional state caused the ACC to treat a given behaviour as fundamentally different. The fact that the geometry of the behavioral representations remained intact following shifts in emotional context suggests that the ACC is rather modulating, or re-interpreting the same behavior depending on emotional state. Encoding Relevance The distinct dynamics of emotional context representations versus behavioral (or other) representations, are likely a feature of their computational role in the ACC. I will cover some of the functional implications below. My exploration of neural manifolds in Chapter 4 showed that emotional context manifolds had more complex geometry, in both their dimensionality (Figure 4-13) and topology (Figure 4-12), than was present in any behavioural manifold. A part of this geometry was their long-timescale dynamics. These long-timescale dynamics allow emotional context representations to incorporate or integrate information about the various task factors, including behaviour, needed for ACC function. In contrast, behaviours, and likely other representations of moment-to-moment factors have shorter, unaligned dynamics, as evidenced by their geometry. As a result, the overall dynamics of ACC as a whole are 164 determined by emotional context, and behavioural representations are contained within, or projected onto the more protracted contextual representation. As emotional context dominates the overall dynamics, changing emotional context transforms the entire neural manifold (by rotation, translation, scaling, or some combination thereof). This changes the alignment of the manifold relative to the initial behavioural representation. To linear analysis, like that performed in Chapter 2, this change in alignment suggests that a given behaviour was represented differently in each context. The ensemble analysis and results from Chapter 4 indicated that this was not in fact the case. The NTPN demonstrated consistent geometry in the behaviour representations, even across animals, sessions, and contexts. The emotional context representation obscured the behavioural representations, but they remained geometrically stable. The behavioural representations were just transformed (re-oriented, squished or expanded) by the emotional context dependent shift in the overall manifold. Why might an area like ACC need this encoding schema? ACC receives a large number of varied inputs, representing a variety of information. Presumably, it needs some mechanism for selecting what representations are relevant for internal and downstream processing. This proposed schema accounts for aspects of task specificity, appropriateness, motivation, and relevance efficiently by this change in alignment. Functionally this re-alignment of representations via manifold transformation could be applied to extract relevance from the ongoing stream of information in (at least) two different ways. In one case, the transformation of the overall manifold aligns it with a different set of output structures, enabling processing by different parts of the network depending on the alignment; Representations may be relevant to different downstream areas depending on the context. The other case, considers the same processes from the perspective of bottleneck dimension. Bottleneck dimension describes the available dimensionality, often equivalent to the number of units, available at a key step in a neural network. Here the transform associated with a given context is allocating dimensionality to the relevant 165 representations and removing the irrelevant ones by projecting them to zero, similar to how an auto-encoder compresses inputs to keep only the most informative features. When the context changes, and the manifold is realigned, a different set of representations are now relevant, and passed on down the network, and other previously relevant representations are projected to zero. Instead of rearranging the inputs, as in the first case, in the second case the representations are instead compressed, leaving only those that are relevant. Both of these strategies could improve computational and representational efficiency by making more efficient use of available neurons. Some recent work points towards the latter interpretation (Aitken et al, 2022; Soldado-Magraner et al, 2023), but these strategies need not be mutually exclusive. Overall, this encoding schema is speculation at this point, but does align closely with what we and others have observed in ACC (Galgali et al, 2023; Fusi et al, 2016; Soldado-Magraner et al, 2023), as well as aligning with current research in neural network models (Mazzucato et al, 2016; George et al, 2022). What is the functional significance of this contextualised representation? I would argue that this serves as a form of emotional ‘gain’ (Seamans and Floresco, 2022), in that these aligned representations bias the impact of certain aspects of behaviour and other factors have on decisions when they are performed in a certain emotional state. In such a framework, the combined representations of behaviour, events, etc., modulated by emotional context make up the output signal of ACC, in turn modulating the emotional/autonomic state. This emotional or autonomic state then likely drives the potentiation and selection of emotionally motivated actions. The specifics of this model of ACC function are discussed in much greater detail in Seamans and Floresco, (2022), but here I will highlight two perspectives relating to emotional gain from this thesis. First, the relevance encoding described above offers an interesting example of how such a ‘gain’ might be functionally achieved, although strictly speaking the emotional gain model as proposed is a function of the output of ACC, rather than its internal encoding. The multi-modal signal within ACC is primarily organised by emotional context, as discussed in Chapters 3 and 4. 166 As such the representation of events and actions is emotionally contextualised, via transformation/alignment selecting for relevant representations. This contextualised representation is instantiated in the firing activity of output neurons and is therefore passed to areas responsible for regulating autonomic states. In short, through the action of emotional context, the behavioural representation has become realigned, and as a part of this aligned, combined representation, the gain, goes on to influence downstream processes. A second perspective comes from network design. As discussed above, if we accept the role of emotion in action potentiation, output from ACC, by way of the modulation of autonomic state, acts to tune the dial for behaviours, driving the expression of appropriate actions and the suppression of inappropriate ones. This is an example of the computational modulation that plays a critical part in managing mixed representations, as will be discussed in the section on mixed selectivity below, driving the selection of appropriate modes of representation in flexible networks. To be clear, the emotional modulation of behavioural representations need not be directly expressed as modified behavioural output. However, because these representations are instantiated in the firing patterns of ACC output neurons, the shifted behavioural representations, along with all the other representations that make up the multi-modal signal, would impact the form of ACC output and therefor impact forthcoming decisions and actions. Mixed selectivity Even though emotional context appeared to be the main organizing force in the analysed neural signals, the degree of responsiveness to emotional context was small for individual neurons (which is true of responsiveness to any factor we have analyzed thus far). Although small, this signal was however represented across a much larger proportion of the recorded ensemble than was any given behavior. On the other hand, responsiveness was always was always a distribution, with all neurons representing all 167 emotional contexts to varying degrees. The emotional context in essence determined how responsiveness to other task factors was distributed across the ensemble of neurons. This conclusion is consistent with the concept of mixed selectivity. As has been discussed at length across the preceding chapters, mixed selectivity is a framework where multiple concurrent representations are present within groups of neurons. The reason for such a framework in ACC is reasonably straightforward when we consider the breadth of factors that seem to be represented within its neural landscape. Dedicating populations of neurons to each possible representation would very quickly grow beyond feasible range, even for a very large network of neurons, and would be severely limited, by network size and available bandwidth, in the kind of information processing that could be done across these representations, resulting in a constrained and inflexible network. But the functional implications are more profound, and extend even to areas of cortex that may not, at first glance, need to mix representations in this way. The argument here, is that mixed selectivity is not only a feature of cortical neurons in general, but an expected and perhaps necessary functional consequence. This is a phenomenon studied at length in the machine learning community, with a significant literature focused on the concept of superposition (Elhage et al, 2022; Cheung et al, 2019). Individual neurons participating in network representations do not respond to just one feature or category, regardless of the neural network architecture but rather superimpose responses to multiple factors on top of one another. In a recent review Tye et al (2024) discuss the last decade of ever-increasing research and analysis into multi-selectivity in cortical circuits. Their conclusion: mixed selectivity is the norm, and neural circuits that do not exhibit at least some degree of mixed selectivity are few and far between. Seemingly everywhere we look in cortex, even in primary sensory areas thought to be topographically mapped with receptive fields, we find some degree of multi-selectivity (Rigotti et al, 2013; Kira et al, 2023). Mixed selectivity is a necessary network feature for learning complex representations from sparse inputs. This selectivity can take different forms in terms of the relationships between individual neurons 168 and the information they represent. Linear mixing, where the encoding of representations can be broken down as a linear sum enables abstraction, aiding in generalisation. Nonlinear mixing, of the kind observed in our ensembles of ACC neurons, enables increased complexity and flexibility in representation and computation. The functional drive for this complexity in a biological network likely lies in its geometry. More complex, high-dimensional representations can provide learnable, separable outputs for a variety of different tasks (Galgali et al, 2023; Nogueira et al, 2023), leading to a network that is flexible, and tunable to diverse circumstance. Context-modulation of cue responding is one of the key applications of this capability (Tye et al, 2024), or in our case, the context-modulation of emotionally motivated behaviour. Mixed selectivity is not by itself a panacea to computational complexity in representation however. Mixing schema that freely represent every combination of possible factors quickly become completely intractable. Two factors mitigate these possible encoding difficulties: the first is that the world, and therefore the cognitive tasks encountered within, are restricted to some subset of all possibilities. In learning the world, representational schema can be appropriately trimmed. The second lies in variations of network design. The encoding frameworks observed across different regions seem to implement different strategies of mixed selectivity (Benna and Fusi, 2021; Barak et al, 2013). Stacked atop these differences in design are the control mechanisms of neuromodulators and neural dynamics, resulting in a variety of implementations that likely go some way to explain the flexibility and competence of the cortex across different cognitive tasks. Modelling Biological Networks It is easy to mistake the framing of complicated artificial neural networks and other machine learning models used in this thesis as an attempt to directly model the underlying biological network. This is 169 certainly an avenue of investigation that could be pursued, and indeed some of the discussed generative models would likely be good starting candidates for such an endeavor. However, that is not the intent of the work presented here. To be clear, the role of the variety of models and machine learning techniques applied in this work is to identify, extract, and evaluate the properties of these neural representations. While certainly some intriguing functional similarities are present between the models I used and the biological networks in question, direct functional overlap is at this stage speculative, and is certainly an active area of research (Fusi et al, 2016; Mazzucato et al, 2016; Pandarinath et al, 2018; Ye and Pandarinath, 2021; Rigotti et al, 2013; Soldado-Magraner et al, 2023). Alternate Machine Learning approaches In Chapter 4 on the geometry of emotion, I highlighted the importance of accounting for both structural and temporal relationships in neural representations and the technical challenges in extracting this information from neural signals. Amongst the alternate strategies to pursuing the extraction of the common properties of these representations it is worth spending some time discussing dynamical systems models as well as more general neural network models. Two generative dynamical systems models of note are LFADS (Latent-factor analysis via dynamical systems) (Pandarinath et al, 2018) and PLRNNs (Piece-wise linear recurrent neural networks) (Durstewitz et al, 2022). The idea behind LFADS is to extract the latent dynamics of neural data through sequential autoencoders. These autoencoders serve to bottleneck the representation of the underlying dynamics of the data, reducing it to a latent dynamics space, and this allows for the generative modelling of the neural signal (generative in this case means that the trained model produces data with dynamics matching that of the input data). A similar approach, PLRNNs model the dynamics via a piecewise-linear recurrent neural network (piecewise-linear models drastically reduce complexity while being able to accurately approximate general dynamics). 170 Generative models, or at least these models as currently implemented, do not do input alignment per se. Rather, any generalisation across subjects or sessions is dependent on the model having sufficiently learned the underlying dynamics of the neural system from a single training session. While this is of course possible for sufficiently sized and curated datasets, this is still a significant hurdle for many electrophysiology applications. Evaluating success in this case is also non-trivial, as there needs to be sufficient confidence that the generative model is indeed correctly modelling the true neural dynamics. However, if such an evaluation can be done for a given dataset, these models can be incredibly powerful, particularly if subsequently endowed with physiological or anatomical interpretability (Durstewitz et al, 2022). These dynamics can also be represented by non-recurrent means, as was our approach in the NTPN. Another such strategy is reflected in modelling with neural data transformers, NDT (Ye and Pandarinath, 2021). Unlike the generative models discussed above, this approach estimates the underlying dynamics without the need for and explicit dynamical system, such as an RNN. This alternative can be viewed as a parallel approximation, whereby the NDT learns the spatiotemporal structure in parallel as opposed to sequentially like LFADS. This saves considerably on computation and data requirements, and if properly framed can yield similar insight into the underlying dynamics of the neural signal. So far, this approach has not been applied on cross session or subject data, and like LFADS would require some explicit correspondence of inputs. A new approach, and the sole approach among those discussed here to directly tackle cross session learning is POYO, Pre-training On manY neurOns (Azabou et al, 2023). This method leverages several of the recent advances in natural language processing models, namely tokenisation of inputs and transformers, to build large-scale multi-session models. Of particular interest is the adaptive properties of these models, as the authors have demonstrated rapid incorporation of new data across tasks, so called ‘few-shot’ learning. This is a compelling set of properties, and should enable the application of 171 POYO on a wide variety of neural datasets, although training a model of this complexity does carry a considerable burden of necessary data. While this model demonstrates excellent decoding performance across a variety of tasks, a concern, and I hasten to add this is true for almost all complex neural network models applied in this way, is interpreting the latent space in a way that is informative of underlying biological function. This is not to say that such interpretation is impossible, the view of neural network models as black boxes is rapidly fading as we develop new techniques for exploring and understanding their latent representations. With the NTPN, this interpretation comes by way of its geometric latent space. The features learned by the network are directly relatable to the input space and expressible as geometry. While POYO does not, at this time, have a similarly interpretable interface for the underlying structure of the neural data, it is extremely flexible, and could be immediately applied to a much wider range of datasets as a result of its pre-trained core. This discussion is not solely an exercise in examining alternative approaches, but also indicates possible avenues of future research. Certainly, with the collection of appropriate datasets it becomes much more compelling to apply generative techniques like LFADS, NDT, or indeed a technique such as POYO to ACC ensemble encoding. Building a model to adequately simulate the dynamics of the neural space has the potential to yield a more complete picture of the functional properties of contextual modulation as long as there is sufficient and clear ground truth to validate it. Improvements in data and network training efficiency should also offer traction for an approach like POYO to leverage data from across subjects similar to the NTPN. Application of these techniques also offers additional purchase for applying principles of network design to what is seen in ACC, and building representative models of ACC function. 172 Ensuring Interpretability in Novel Analysis Throughout the course of the tools and studies covered in this thesis, we have gained some insight into the emotional modulation of behaviour in ACC. I would, however, also like to directly highlight the process of adapting and applying novel machine learning analyses to this problem. The inclusion of this swathe of novel techniques was motivated by our desire to extract and interpret these representations of emotional state and behaviour and leverage the common properties of contextual modulation that we had observed in previous work. The inclusion of machine learning models and analysis techniques is not without its requisite groundwork. In applying these techniques as part of our research, we must ensure that we motivate their selection and design based on the questions we were interested in asking of our data. We need to delineate the capabilities of these models, as well as demonstrate that the models are specifically explainable within the context of their application. And finally, we need to ensure that an interested reader is sufficiently grounded in the basic principle and use of the selected analysis to follow their application and interpretation. I highlight this process to underscore that bridging the fields brings an additional burden of explanation, but this is ultimately worth the outlay given the benefits new models and techniques can bring. HUB-DT, the NTPN and the Future In the chapters on HUB-DT and the NTPN, I made brief mention of possible future applications for these tools. These tools represent a substantial body of coding work and experimentation, and while these are directed at the research questions explored in this thesis, they are no doubt valuable to a multitude of other research. I will restate here my sincere hope that other neuroscientists, and indeed computer scientists, will make use of these tools in some capacity in future research. As I mentioned in the 173 introduction, there is some degree to which specific research questions require tailor-made analyses, and no tool is truly right for the job immediately out of the box. Nonetheless, I encourage interested users to experiment and adapt, and if nothing else use the tools and analysis developed and deployed in this work as a template for the cross-field pollination of machine learning to neuroscience. Additional Resources Repositories for the Tools and Analysis created for and used in this work: HUB-DT: https://github.com/Loken85/HUB_DT NTPN and TDA: https://github.com/Loken85/NTPN_and_TDA Other Analysis: https://github.com/Loken85/ephys_ML_repo 174 References Aitken K, Garrett M, Olsen S, Mihalas S. (2022). The geometry of representational drift in natural and artificial neural networks. PLOS Computational Biology. https://doi.org/10.1371/journal.pcbi.1010716 Arac A, Zhao P, Dobkin BH, Carmichael ST, Golshani P. (2019) DeepBehavior: A Deep Learning Toolbox for Automated Analysis of Animal and Human Behavior Imaging Data. Frontiers in systems neuroscience, 13, 20. https://doi.org/10.3389/fnsys.2019.00020 Azabou M, Arora V, Ganesh V, Mao X, Nachimuthu S, Mendelson MJ, Richards B, Perich MG, Lajoie G, Dyer EL. (2023). A Unified, Scalable Framework for Neural Population Decoding. arXiv. https://doi.org/10.48550/arXiv.2310.16046 Bach J. (2009). Principles of Synthetic Intelligence. New York. Oxford University Press. Baeg EH, Kim YB, Huh K, Mook-Jung I, Kim HT, Jung MW. (2003) Dynamics of population code for working memory in the prefrontal cortex. Neuron. 2003 Sep 25;40(1):177-88. doi: 10.1016/s0896-273(03)00597-x Barak O, Rigotti M, Fusi S. (2013). The sparseness of mixed selectivity neurons controls the generalization-discrimination trade-off. Journal of Neuroscience. 33(9):3844-3856. https://doi.org/10.1523/JNEUROSCI.2753-12.2013 Belozertseva IV, Dravolina OA, Tur MA, Semina MG, Zvartau EE, Bespalov AY. (2016) Morphine-induced Straub tail reaction in mice treated with serotonergic compounds. European Journal of Pharmacology. 2016 Nov 15;791:1-7. DOI: 10.1016/j.ejphar.2016.08.014 Benna MK and Fusi S. (2021) Place cells may simply be memory cells: Memory compression leads to spatial tuning and history dependence. Proc. Natl. Acad. Sci. USA. 2021; 18e2018422118 https://doi.org/10.1073/pnas.2018422118 Berman GJ, Choi DM, Bialek W, Shaevitz JW. (2014) Mapping the stereotyped behaviour of freely moving fruit flies. J R Soc Interface 2014, 11(99). http://dx.doi.org/10.1098/rsif.2014.0672 Bernardi S, Benna MK, Rigotti M, Munuera J, Fusi S, Salzman CD. (2020) The geometry of abstraction in the hippocampus and prefrontal cortex. Cell 183:954–967.e21. doi: 10.1016/j.cell.2020.09.031 175 Beucher S, and Meyer F. (1993) The morphological approach to segmentation: the watershed transformation. In Mathematical Morphology in Image Processing (Ed. E. R. Dougherty), pages 433–481. Bizzi E, Cheung VC. (2013) The neural origin of muscle synergies. Frontiers in Computational Neuroscience. 7:51. doi: 10.3389/fncom.2013.00051 Bliss-Moreau E, Santistevan AC, Bennett J, Moadab G, Amaral DG. (2021) Anterior Cingulate Cortex Ablation Disrupts Affective Vigor and Vigilance. Journal of Neuroscience;41(38):8075-8087. doi: 10.1523/JNEUROSCI.0673-21.2021 Brockett AT, Tennyson SS, deBettencourt CA, Gaye F, Roesch MR. (2020) Anterior cingulate cortex is necessary for adaptation of action plans PNAS 117:6196–6204. https://doi.org/10.1073/pnas.1919303117 Brotis AG, Kapsalaki EZ, Paterakis K, Smith JR, Fountas KN. (2009). Historic evolution of open cingulectomy and stereotactic cingulotomy in the management of medically intractable psychiatric disorders, pain and drug addiction. Stereotactic and Functional Neurosurgery, 87(5), 271–291. Bryden DW, Brockett AT, Blume E, Heatley K, Zhao A, Roesch MR. (2019) Single Neurons in Anterior Cingulate Cortex Signal the Need to Change Action During Performance of a Stop-change Task that Induces Response Competition. Cerebral Cortex. 2019 Mar 1;29(3):1020-1031. doi: 10.1093/cercor/bhy008 Burgos-Robles A, Kimchi E, Izadmehr E, Porzenheim MJ, Ramos-Guasp WA, Nieh EH, Felix-Ortiz AC, Namburi P, Leppla CA, Presbrey KN, et al. (2017) Amygdala inputs to prefrontal cortex guide behavior amid conflicting cues of reward and punishment. Nature Neuroscience; 20, 824–835 (2017). https://doi.org/10.1038/nn.4553 Campello RJGB, Moulavi D, Sander J. (2013) Density-Based Clustering Based on Hierarchical Density Estimates. In: Pei J, Tseng VS, Cao L, Motoda H, Xu G. (eds) Advances in Knowledge Discovery and Data Mining. PAKDD 2013. Lecture Notes in Computer Science, vol 7819. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-37456-2_14 Caracheo BK, Grewel JS, Seamans JK. (2018) Persistent Valence Representations by Ensembles of Anterior Cingulate Cortex Neurons. Frontiers in Systems Neuroscience. Oct, 2018. https://doi.org/10.3389/fnsys.2018.00051 176 Caruana F, Gerbella M, Avanzini P, Gozzo F, Pelliccia V, Mai R, Abdollahi RO, Cardinale F, Sartori I, Lo Russo G, Rizzolatti G. (2018) Motor and emotional behaviours elicited by electrical stimulation of the human cingulate cortex. Brain. 2018 Oct 1;141(10):3035-3051. doi: 10.1093/brain/awy219 Cheung B, Terekhov A, Chen Y, Pulkit A, Olshausen B. (2019). Superposition of many models into one. arXiv. https://doi.org/10.48550/arXiv.1902.05522 Condé F, Maire-lepoivre E, Audinat E, Crépel F. (1995). Afferent connections of the medial frontal cortex of the rat. II. Cortical and subcortical afferents. Journal of Comparative Neurology. Vol 352-4. 567-593. https://doi.org/10.1002/cne.903520407 Cowen SL, and McNaughton BL. (2007) Selective Delay Activity in the Medial Prefrontal Cortex of the Rat: Contribution of Sensorimotor Information and Contingency. https://doi.org/10.1152/jn.00150.2007 Cowley BR, Snyder AC, Acar K, Williamson RC, Yu BM, Smith MA. (2020) Slow drift of neural activity as a signature of impulsivity in macaque visual and prefrontal cortex. Neuron 108:551–567.e8. doi: 10.1016/j.neuron.2020.07.021 Critchley HD, Mathias CJ, Josephs O, O'Doherty J, Zanini S, Dewar BK, Cipolotti L, Shallice T, Dolan RJ. (2003) Human cingulate cortex and autonomic control: converging neuroimaging and clinical evidence. Brain. 2003 Oct;126(Pt 10):2139-52. doi: 10.1093/brain/awg216 Damasio AR. (1994) Descartes’ error: Emotion, reason, and the human brain. New York: Putnam Damasio AR. (2012) Emotions and Feelings: A Neurobiological Perspective. In: Manstead ASR, Frijda N, Fischer A, eds. Feelings and Emotions: The Amsterdam Symposium. Studies in Emotion and Social Interaction. Cambridge University Press; 2004:49-57. Devinsky O, Morrell MJ, Vogt BA. (1995) Contributions of anterior cingulate cortex to behaviour. Brain. 1995 Feb;118 (Pt 1):279-306. doi: 10.1093/brain/118.1.279. PMID: 7895011. Drevets WC, Price JL, Furey ML. (2008) Brain structural and functional abnormalities in mood disorders: implications for neurocircuitry models of depression. Brain Struct Funct. 2008 Sep;213(1-2):93-118. doi: 10.1007/s00429-008-0189-x Driscoll LN, Pettit NL, Minderer M, Chettih SN, Harvey CD. (2017) Dynamic reorganization of neuronal activity patterns in parietal cortex. Cell 170:986–999.e16. doi: 10.1016/j.cell.2017.07.021 177 Durstewitz D, Vittoz NM, Floresco SB, Seamans JK. (2010) Abrupt transitions between prefrontal neural ensemble states accompany behavioral transitions during rule learning. Neuron. 2010 May 13;66(3):438-48. doi: 10.1016/j.neuron.2010.03.029 Durstewitz D, Koppe G, Thrum MI. (2022) Reconstructing Computational Dynamics from Neural Measurements with Recurrent Neural Networks. 2022. BiorXiv. DOI: https://doi.org/10.1101/2022.10.31.514408 Elhage N, Hume T, Olsson C, Schiefer N, Henighan T, Kravec S, Hatfield-Dodds Z, Lasenby R, Drain D, Chen C et al. (2022). Toy Models of Superposition. arXiv. https://doi.org/10.48550/arXiv.2209.10652 Emberly E, Seamans JK. (2020) Abrupt, Asynchronous Changes in Action Representations by Anterior Cingulate Cortex Neurons during Trial and Error Learning. Cereb Cortex. 2020 Jun 30;30(8):4336-4345. doi: 10.1093/cercor/bhaa019 Euston DR, Gruber AJ, McNaughton BL. (2012) The Role of Medial Prefrontal Cortex in Memory and Decision Making. Neuron. 2012 Dec 20;76(6):1057-70. https://doi.org/10.1016/j.neuron.2012.12.002 Euston DR, and McNaughton BL. (2006) Apparent encoding of sequential context in rat medial prefrontal cortex is accounted for by behavioral variability. The Journal of Neuroscience, 26(51), 13143–13155. doi: 10.1523/JNEUROSCI.3803-06.2006 Fowlkes EB, and Mallows CL. (1983) A Method for Comparing Two Hierarchical Clusterings. Journal of the American Statistical Association. 78 (383): 553. doi:10.2307/2288117 Frijda NH. (1986). The emotions. New York: Cambridge University Press. Frijda NH. (2012) Emotions and Action. In: Manstead ASR, Frijda N, Fischer A, eds. Feelings and Emotions: The Amsterdam Symposium. Studies in Emotion and Social Interaction. Cambridge University Press; 2004:158-173. Fusi S, Miller EK, Rigotti M. (2016) Why neurons mix: high dimensionality for higher Cognition. Current Opinion in Neurobiology. Vol 37. 66-74. http://dx.doi.org/10.1016/j.conb.2016.01.010 Gabbott PLA, Warner TA, Jays PRL, Salway P, Busby SJ. (2005) Prefrontal cortex in the rat: Projections to subcortical autonomic, motor, and limbic centers. Journal of Comparative Neurology. 2005 Nov 14;492(2):145-77. doi: 10.1002/cne20738 178 Galgali AR, Sahani M, Mante V. (2023) Residual dynamics resolves recurrent contributions to neural computation. Nature Neuroscience 26, 326–338 (2023). https://doi.org/10.1038/s41593-022-01230-2 Gallego JA, Perich MG, Chowdhury RH, Solla SA, Miller LE. (2020) Long-term stability of cortical population dynamics underlying consistent behavior. Nature Neuroscience 23, 260–270. https://doi.org/10.1038/s41593-019-0555-4 Gellert VF, Holtzman SG. (1978) Development and maintenance of morphine tolerance and dependence in the rat by scheduled access to morphine drinking solutions. J Pharmacol Exp Ther. 1978 Jun;205(3):536-46. PMID: 566320. George T, Lajoie G, Baratin A. (2022) Lazy vs hasty: linearization in deep networks impacts learning schedule based on example difficulty. arXiv. https://doi.org/10.48550/arXiv.2209.09658 Globerson A, Roweis S. (2005) Metric learning by collapsing classes. Advances in Neural Information Processing Systems 18. Guiustino TF, Maren S. (2015) The Role of the Medial Prefrontal Cortex in the Conditioning and Extinction of Fear. Front. Behav. Neurosci., 09 November 2015 Sec. Learning and Memory https://doi.org/10.3389/fnbeh.2015.00298 Günel S, Rhodin H, Morales D, Campagnolo J, Ramdya P, Fua P. (2019) Deepfly3d, a deep learning-based approach for 3D limb and appendage tracking in tethered, adult drosophila. Elife 8:e48571. doi: 10.7554/eLife.48571 Hastie T, Tibshirani R, Friedman J. (2011) The Elements of Statistical Learning: Data Mining, Inference, and Prediction. 2011. hastie.su.domains/ElemStatLearn Hoover WB, Vertes RP. (2007) Anatomical analysis of afferent projections to the medial prefrontal cortex in the rat. Brain Struct Funct 212, 149–179. https://doi.org/10.1007/s00429-007-0150-4 Hsu AI, Yttri EA. (2021) B-SOiD, an open-source unsupervised algorithm for identification and fast prediction of behaviors. Nature Communications. 12, 5188 https://doi.org/10.1038/s41467-021-25420-x Hyman JM, Whitman J, Emberly E, Woodward TS, Seamans JK. (2013) Action and outcome activity state patterns in the anterior cingulate cortex. Cerebral Cortex, 23 (6), pp. 1257-1268, doi: 10.1093/cercor/bhs104 22617853 179 Jaderberg M, Simonyan K, Zisserman A, Kavukcuoglu K. (2016) Spatial Transformer Networks. arXiv. 2016. https://doi.org/10.48550/arXiv.1506.02025 Jaworska N, Yang XR, Knott V, MacQueen G. (2015) A review of fMRI studies during visual emotive processing in major depressive disorder. World J Biol Psychiatry. 2015 Oct;16(7):448-71. Jhang J, Lee H, Kang MS, Lee HS, Park H, Han JH. (2018) Anterior cingulate cortex and its input to the basolateral amygdala control innate fear response. Nature Communications 9:2744. doi: 10.1038/s41467-018-05090-y Johansen JP, Fields HL, Manning BH. (2001) The affective component of pain in rodents: Direct evidence for a contribution of the anterior cingulate cortex. PNAS 98(14) 8077-8082. https://doi.org/10.1073/pnas.141218998 Jung MW, Qin Y, McNaughton BL, Barnes CA. (1998). Firing characteristics of deep layer neurons in prefrontal cortex in rats performing spatial working memory tasks. Cerebral Cortex. 8(5):437–450. doi: 10.1093/cercor/8.5.437 Kaplan HS, and Zimmer M. (2020) Brain-wide representations of ongoing behavior: a universal principle? Current Opinions in Neurobiology. 64:60–69. doi: 10.1016/j.conb.2020.02.008 Kira S, Safaai H, Morcos AS, Panzeri S, Harvey CD. (2023) A distributed and efficient population code of mixed selectivity neurons for flexible navigation decisions. Nature Communications 14:2121. doi: 10.1038/s41467-023-37804-2 Koay SA, Charles AS, Thiberge SY, Brody CD, Tank DW. (2022) Sequential and efficient neural-population coding of complex task information. Neuron 110:328–249.e11. doi: 10.1016/j.neuron.2021.10.020 Kragel PA, LaBar KS. (2016) Decoding the nature of emotion in the brain. Trends in Cognitive Science 20:444–455. doi: 10.1016/j.tics.2016.03.011 Lashley KS. (1951) The problem of serial order in behavior. In: Cerebral mechanisms in behavior; the Hixon symposium (Jeffress LA, ed), pp 112–146. Wiley. Leow YN, Zhou B, Sullivan HA, Barlowe AR, Wickersham IR, Sur M. (2022). Brain-wide mapping of inputs to the mouse lateral posterior (LP/Pulvinar) thalamus-anterior cingulate cortex network. Journal of Comparative Neurology. 530(11):1992–2013. doi: 10.1002/cne.25317 180 Lima Portugal LC, Alves RCS, Junior OF, Sanchez TA, Mocaiber I, Volchan E, Smith Erthal F, David IA, Kim J, Oliveira L, Padmala S, Chen G, Pessoa L, Pereira MG. (2020) Interactions between emotion and action in the brain. Neuroimage. 2020 Jul 1;214:116728. doi: 10.1016/j.neuroimage.2020.116728. Linderman S, Johnson M, Miller A, Adams R, Blei D, Paninski L. (2017) Bayesian Learning and Inference in Recurrent Switching Linear Dynamical Systems. Proceedings of the 20th International Conference on Artificial Intelligence and Statistics, PMLR 54:914-922, 2017. Linderman SW, Miller AC, Adams RP, Blei DM, Paninski L, Johnson MJ. (2016) Recurrent Switching Linear Dynamical Systems. arXiv. https://doi.org/10.48550/arXiv.1610.08466 Lindsay AJ, Caracheo BF, Grewal JS, Leibovitz D, Seamans JK. (2018) How much does Movement and Location Encoding impact Prefrontal Cortex Activity. An algorithmic decoding approach in Freely moving rats. eNeuro 23 April 2018, 5(2) ENEURO.0023-18.2018; DOI: https://doi.org/10.1523/ENEURO.0023-18.2018 Lindsay AJ, Gallello I, Caracheo BF, Seamans JK. (2024). Reconfiguration of Behavioral Signals in the Anterior Cingulate Cortex based on Emotional State. Journal of Neuroscience 18 April 2024, e1670232024; https://doi.org/10.1523/JNEUROSCI.1670-23.2024 Lindsay AJ, Seamans JK. (2024) HUB-DT: a tool for unsupervised behavioural discovery and analysis. bioRxiv. doi: https://doi.org/10.1101/2024.01.08.574696 Logiaco L, Quilodtran R, Procyk E, Arleo A. (2015) Spatiotemporal Spike Coding of Behavioral Adaptation in the Dorsal Anterior Cingulate Cortex. PLOS Biology. doi: 10.1371/journal.pbio.1002222 Lum P, Singh G, Lehman A, Ishkanov T, Vejdemo-Johansson M, Alagappan M, Carlsson J, Carlsson G. (2013) Extracting insights from the shape of complex data using topology. Sci Rep 3, 1236. https://doi.org/10.1038/srep01236 Lundberg S, Lee S. (2017) A Unified Approach to Interpreting Model Predictions. arXiv:1705.07874 DOI: https://doi.org/10.48550/arXiv.1705.07874 Luxem K, Mocellin P, Fuhrmann F, Kürsch J, Remy S, Bauer P. (2020) Identifying Behavioral Structure from Deep Variational Embeddings of Animal Motion. bioRxiv 2020.05.14.095430; doi: https://doi.org/10.1101/2020.05.14.095430 181 Ma L, Hyman JM, Lindsay AJ, Phillips AG, Seamans JK. (2014) Differences in the emergent coding properties of cortical and striatal ensembles. Nature Neuroscience. June, 2014. DOI: 10.1038/nn.3753 Ma L, Hyman JM, Durstewitz D, Phillips AG, Seamans JK. (2016). A quantitative analysis of context-dependent remapping of medial frontal cortex neurons and ensembles. Journal of Neuroscience. 36(31):8258-8272. 10.1523/JNEUROSCI.3176-15.2016 Maldonado R, Stinus L, Gold LH, Koob GF. (1992) Role of different brain structures in the expression of the physical morphine withdrawal syndrome. Journal of Pharmacology and Experimental Therapeutics. 1992 May 1;261(2):669-77. Maldonado R, Koob GF. (1993) Destruction of the locus coeruleus decreases physical signs of opiate withdrawal. Brain research. 1993 Mar 5;605(1):128-38. Mathis A, Mamidanna P, Cury KM, Abe T, Murthy VN, Mathis MW, Bethge M. (2018) DeepLabCut: markerless pose estimation of user-defined body parts with deep learning. Nature Neuroscience volume 21, pages1281–1289. DOI: 10.1038/s41593-018-0209-y Mathis MW, Mathis A. (2020) Deep learning tools for the measurement of animal behavior in neuroscience. Current Opinion in Neurobiology. 2020 Feb;60:1-11. doi: 10.1016/j.conb.2019.10.008. Mazzucato L, Fontanini A, La Camera G. (2016) Stimuli Reduce the Dimensionality of Cortical Activity. Frontiers in Systems Neuroscience. Vol 10, 2016. DOI: 10.3389/fnsys.2016.00011 McGovern RA, and Sheth SA. (2017). Role of the dorsal anterior cingulate cortex in obsessive-compulsive disorder: converging evidence from cognitive neuroscience and psychiatric neurosurgery. Journal of Neurosurgery, 126(1), 132–147. doi: 10.3171/2016.1.JNS15601 McInnes L, Healy J, Astels S. (2017) hdbscan: Hierarchical density based clustering, Journal of Open Source Software, 2(11), 205, doi:10.21105/joss.00205. DOI: 10.21105/joss.00205 McInnes L, Healy J, Melville J. (2020) UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction. arXiv:1802.03426. DOI: https://doi.org/10.48550/arXiv.1802.03426 McNaughton BL, Mizumori SJY, Barnes CA, Leonard BJ, Marquis M, Green EJ. (1994) Cortical Representation of Motion during Unrestrained Spatial Navigation in the Rat. Cerebral Cortex. Vol 4-1. https://doi.org/10.1093/cercor/4.1.27 182 Mehta D, Sotnychenko O, Mueller F, Xu W, Elgharib M, Fua P, Seidel HP, Rhodin H, Pons-Moll G, Theobalt C. (2020) XNect: real-time multi-person 3D human pose estimation with a single RGB camera. SIGGRAPH 2020. Monosov IE. (2017) Anterior cingulate is a source of valence-specific information about value and uncertainty. Nature Communications. 8:134. doi: 10.1038/s41467-017-00072-y Murugan J, Robertson D. (2019) An Introduction to Topological Data Analysis for Physicists: From LGM to FRBs. arXiv. https://doi.org/10.48550/arXiv.1904.11044 Musall S, Kaufman MT, Juavinett AL, Gluf S, Churchland AK. (2019) Single-trial neural dynamics are dominated by richly varied movements. Nature Neuroscience. 22:1677–1686. doi: 10.1038/s41593-019-0502-4 Nogueira R, Rodgers CC, Bruno RM, Fusi S. (2023) The geometry of cortical representations of touch in rodents. Nat Neurosci. 2023 Feb;26(2):239-250. doi: 10.1038/s41593-022-01237-9. Padilla-Coreano N, Bolkan SS, Pierce GM, Garcia-Garcia AL, Spellman TJ, Gordon JA. (2016) Direct Ventral Hippocampal-Prefrontal Input Is Required for Anxiety-Related Neural Activity and Behavior. Neuron 89:857–866. https://doi.org/10.1016/j.neuron.2016.01.011 Pandarinath C, O’Shea DJ, Collins J, Jozefowicz R, Stavisky SD, Kao JC, Trautmann EM, Kaufman MT, Ryu SI, Hochberg LR, Henderson JM, Shenoy KV, Abbott LF, Sussillo D. (2018) Inferring single-trial neural population dynamics using sequential auto-encoders. Nat Methods 15, 805–815. https://doi.org/10.1038/s41592-018-0109-9 Pedregosa F, Varoquaux G, Gramfort A, Michel V, Thirion B, Grisel O, Blondel M, Prettenhofer P, Weiss R, Dubourg V, et al. (2011) Scikit-learn: machine learning in python. Journal of Machine Learning Research. 12:2825–2830. Pellegrino A, Stein H, Cayco-Gajic NA. (2024) Dimensionality reduction beyond neural subspaces with slice tensor component analysis. Nature Neuroscience. https://doi.org/10.1038/s41593-024-01626-2 Picard N, Strick PL. (1996). Motor areas of the medial wall: a review of their location and functional activation. Cerebral Cortex 1996; 6: 342-53. DOI: 10.1093/cercor/6.3.342 183 Pishchulin L, Insafutdinov E, Tang S, Andres B, Andriluka M, Gehler P, Schiele B. (2016). DeepCut: Joint Subset Partition and Labeling for Multi Person Pose Estimation. arXiv. https://doi.org/10.48550/arXiv.1511.06645 Porter BS, Li K, Hillman KL. (2020) Regional Activity in the Rat Anterior Cingulate Cortex and Insula during Persistence and Quitting in a Physical-Effort Task. eNeuro 28. 2020. DOI: https://doi.org/10.1523/ENEURO.0243-20.2020 Qi CR, Su H, Mo K, Guibas LJ. (2017) PointNet: deep learning on point sets for3D classification and segmentation. arXiv:1612.00593. https://doi.org/10.48550/arXiv.1612.00593 Quinn JJ, Ma QD, Tinsley MR, Koch C, Fanselow MS. (2008) Inverse temporal contributions of the dorsal hippocampus and medial prefrontal cortex to the expression of long-term fear memories. Learning and Memory. 2008 Apr 25;15(5):368-72. doi:10.1101/lm.813608 Rand WM. (1971) Objective criteria for the evaluation of clustering methods. Journal of the American Statistical Association, 66, 846–850. Rigotti M, Barak O, Warden M, Wang X, Daw ND, Miller EK, Fusi S. (2013). The importance of mixed selectivity in complex cognitive tasks. Nature 497:585–590. doi:10.1038/nature12160. Rudebeck PH, Walton ME, Smyth AN, Bannerman DM, Rushworth MF. (2006) Separate neural pathways process different decision costs. Nature Neuroscience. 2006 Sep;9(9):1161-8. doi:10.1038/nn1756 Russo E, Ma T, Spanagel R, Durstewitz D, Toutounji H, Köhr G. (2021) Coordinated Prefrontal State Transition Leads Extinction of Reward-Seeking Behaviors. Journal of Neuroscience 2 February 2021, JN-RM-2588-20; DOI: https://doi.org/10.1523/JNEUROSCI.2588-20.2021 Sachuriga NH, Yusaku T, Jumpei M, Mariana FP, Taketoshi O, Hisao N. (2021) Neuronal Representation of Locomotion During Motivated Behavior in the Mouse Anterior Cingulate Cortex. Frontiers in Systems Neuroscience. Vol. 15, 2021. DOI:10.3389/fnsys.2021.655110 Safaie M, Chang JC, Park J, Miller LE, Dudman JT, Perish MG, Gallego JA. (2023) Preserved neural dynamics across animals performing similar behaviour. Nature 623, 765–771. https://doi.org/10.1038/s41586-023-06714-0 Seo M, Lee E, Averbeck BB. (2012) Action Selection and Action Value in Frontal-Striatal Circuits. Neuron;74(5) 947-960. https://doi.org/10.1016/j.neuron.2012.03.037 184 Seamans JK, and Floresco SB. (2022) Event-based control of autonomic and emotional states by the anterior cingulate cortex. In Neuroscience and Biobehavioral Reviews (Vol. 133). Elsevier Ltd. https://doi.org/10.1016/j.neubiorev.2021.12.026 Shackman AJ, Salomons TV, Slagter HA, Fox AS, Winter JJ, Davidson RJ. (2011) The integration of negative affect, pain and cognitive control in the cingulate cortex. Nature Reviews Neuroscience. 2011 Mar;12(3):154-67. doi:10.1038/nrn2994 Soldado-Magraner J, Mante V, Sahani M. (2023) Inferring context-dependent computations through linear approximations of prefrontal cortex dynamics. bioRxiv 2023.02.06.527389; doi: https://doi.org/10.1101/2023.02.06.527389 Stringer C, Pachitariu M, Steinmetz N, Carandini M, Harris KD. (2019) High-dimensional geometry of population responses in visual cortex. Nature 571:361–365. doi: 10.1038/s41586-019-1346-5. Strobl C, Boulesteix AL, Zeileis A, Hothorn T. (2007) Bias in random forest variable importance measures: Illustrations, sources and a solution. BMC Bioinformatics 8, 25. https://doi.org/10.1186/1471-2105-8-25 Sturman O, von Ziegler L, Schläppi C, Akyol F, Privitera M, Slominski D, Grimm C, Thieren L, Zerbi V, Grewe B, Bohacek J. (2020) Deep learning-based behavioral analysis reaches human accuracy and is capable of outperforming commercial solutions. Neuropsychopharmacology. 45, 1942–1952 (2020). https://doi.org/10.1038/s41386-020-0776-y Takens, F. (1981) Detecting Strange Attractors in Turbulence. In: Rand DA and Young LS, Eds. Dynamical Systems and Turbulence, Lecture Notes in Mathematics, Vol. 898, 366-381. https://doi.org/10.1007/BFb0091924 Takeuchi D, Roy D, Muralidhar S, Kawai T, Bari A, Lovett C, Sullivan HA, Wickersham IR, Tonegawa S. (2022) Cingulate-motor circuits update rule representations for sequential choice decisions. Nature Communications 13, 4545. https://doi.org/10.1038/s41467-022-32142-1 Tauzin G, Lupo U, Tunstall L, Pérez JB, Caorsi M, Reise W, Medina-Mardones A, Dassatti A, Hess K. (2021) giotto-tda: A Topological Data Analysis Toolkit for Machine Learning and Data Exploration. arXiv. https://doi.org/10.48550/arXiv.2004.02551 Tu W, Zhang N. (2022) Neural underpinning of a respiration-associated resting-state fMRI network. Elife 11:e81555. doi: 10.7554/eLife.81555 185 Tye KM, Miller EK, Taschbach FH, Benna MK, Rigotti M, Fusi S. (2024). Mixed selectivity: Cellular computations for complexity. Neuron. https://doi.org/10.1016/j.neuron.2024.04.017 van der Maaten LJP and Hinton GE. (2008) Visualizing High-Dimensional Data Using t-SNE. Journal of Machine Learning Research 9(Nov):2579-2605, 2008. van der Maaten LJP, Postma EO, van den Herik HJ. (2009) Dimensionality reduction: a comparative review. Tilburg University Technical Report, TiCC-TR. van der Maaten L. (2014) Accelerating t-SNE using Tree-Based Algorithms. Journal of Machine Learning Research, 15. 3221-3245. van Dongen S. (2000) Performance criteria for graph clustering and Markov cluster experiments (Technical Report INS-R0012). Centrum voor Wiskunde en Informatica. van Heukelum S, Tulva K, Geers FE, van Dulm S, Ruisch IH, Mill J, Viana JF, Beckmann CF, Buitelaar JK, Poelmans G, Glennon JC, Vogt BA, Havenith MN, França ASC. (2021) A central role for anterior cingulate cortex in the control of pathological aggression. Current Biology 31:2321–2333.e5. doi: 10.1016/j.cub.2021.03.062 Vaswani A, Shazeer N, Parmar N, Urszkoreit J, Jones L, Gomez AN, Kaiser L, Polosukhin I. (2017) Attention is All You Need. arXiv. https://doi.org/10.48550/arXiv.1706.03762 Wegelin JA. (2000) A survey of Partial Least Squares (PLS) methods, with emphasis on the two-block case. University of Washington. Williams AH, Kunz E, Kornblith S, Linderman S. (2021) Generalized shape metrics on neural representations. arXiv:2110.14739v2. https://doi.org/10.48550/arXiv.2110.14739 Wiltschko AB, Johnson MJ, Iurilli G, Peterson RE, Katon JM, Pashkovski SL, Abraira VE, Adams RP, Datta SR. (2015) Mapping Sub-Second Structure in Mouse Behaviour. Neuron Volume 88, Issue 6, P1121-1135. DOI: https://doi.org/10.1016/j.neuron.2015.11.031 Ye J, and Pandarinath C. (2021) Representation learning for neural population activity with Neural Data Transformers. arXiv. https://doi.org/10.48550/arXiv.2108.01210 Yoshino A, Okamoto Y, Onoda K, Shishida K, Yoshimura S, Kunisato Y, Demoto Y, Okada G, Toki S, Yamashita H, Yamawaki S. (2012) Sadness enhances the experience of pain via neural activation in the 186 anterior cingulate cortex and amygdala: an fMRI study. Journal of Pain;13(7) 628-635. https://doi.org/10.1016/j.jpain.2011.12.005 Zhou Q, Park J, Koltun V. (2018) Open3D: A Modern Library for 3D Data Processing. arXiv. https://doi.org/10.48550/arXiv.1801.09847 Zhu J, Thagard P. (2002) Emotion and action. Philosophical Psychology, Vol 15, No 1, 2002. doi: 10.1080/09515080120109397 187 Appendix: HUB-DT User Guide Guide Page 1 188 Guide Page 2 189 Guide Page 3 190 Guide Page 4
Thesis/Dissertation
eng
Neuroscience
Vancouver : University of British Columbia Library
Attribution-NonCommercial-NoDerivatives 4.0 International
Graduate
Seamans, Jeremy
Understanding the geometry of emotion
Text