Semantic Segmentation of Anomalous Diffusion Using Deep Convolutional Networks

Heterogeneous dynamics commonly emerges in anomalous diffusion with intermittent transitions of diffusion states but proves challenging to identify using conventional statistical methods. To effectively capture these transient changes of diffusion states, we propose a deep learning model (U-AnDi) for the semantic segmentation of anomalous diffusion trajectories. This model is developed with the dilated causal convolution (DCC), gated activation unit (GAU), and U-Net architecture. The study addresses two key subtasks related to trajectory segmentation and changepoint detection, concentrating on variations in diffusion exponents and dynamic models. Additionally, extended analyses are conducted on the segmentation of single-model trajectories, multi-state biological trajectories, and anomalous diffusion with added long-time correlations. By rationally designing comparative models and evaluating the performance of U-AnDi against these models, we discover that U-AnDi consistently outperforms other models across all segmentation tasks, thereby affirming its superiority in the field. This performance edge also sheds light on the interpretability of U-AnDi's core components: DCC, GAU, and U-Net. The clarity with which these components contribute to U-AnDi's success underscores their congruence with the intrinsic physics underlying anomalous diffusion. Furthermore, our model is examined using real-world anomalous diffusion data: the diffusion of transmembrane proteins on cell membrane surfaces, and the segmentation results are highly consistent with experimental observations. Our findings could offer a heuristic deep learning solution for the detection of heterogeneous dynamics in single-molecule/particle tracking experiments, and have the potential to be generalized as a universal scheme for time-series segmentation.


I. INTRODUCTION
Anomalous diffusion [1,2], characterized by the nonlinear transport phenomena that deviate from standard Brownian motion, has drawn significant attention due to its widespread occurrence in various scientific fields, such as physics [3][4][5][6][7], chemistry [8][9][10][11], biology [12][13][14][15][16], and finance [17][18][19].Since anomalous diffusion can provide valuable insights into the underlying mechanisms of complex systems, it is of great importance to perform accurate and reliable analysis of this phenomenon .However, due to the heterogeneous dynamics with intermittent transitions of diffusion states [42][43][44][45], conventional statistical methods usually fail to precisely describe the anomalous diffusion processes in real-world experimental environments.This emphasizes the necessity of exploring effective techniques for the semantic segmentation of anomalous diffusion trajectories, which could offer a more fine-grained approach to detect state transitions and distinguish heterogeneous behaviors in diffusion dynamics.
On the other hand, as a pivotal technique in computer vision, semantic segmentation makes pixel-wise predictions in an image to enable the identification and delineation of distinct regions [46].With the advent of deep learning techniques, semantic segmentation methods have experienced a rapid development in recent years, significantly outperforming traditional approaches that rely on handcrafted features [47][48][49][50][51][52][53][54].These deeplearning-based methods have demonstrated remarkable * huangzih@hnu.edu.cnsuccess in a wide array of applications, including object recognition [47][48][49][50], scene understanding [51], and medical image analysis [52][53][54].In particular, convolutional neural networks (CNNs) have shown unparalleled capabilities in capturing complex patterns and hierarchical representations from raw data, leading to state-of-theart results in various semantic segmentation tasks [46].One representative example is the U-Net architecture [52], which is built on the basis of an encoder-decoder structure and the rational use of skip connections.U-Net has emerged as one of the most popular and effective frameworks for semantic segmentation and proven to be highly effective in diverse segmentation tasks [54].
In this work, motivated by the successful applications of CNNs in semantic segmentation, we explore the potential of employing deep convolutional networks for the semantic segmentation of anomalous diffusion.We introduce a novel deep learning model, U-AnDi, which synergizes the dilated causal convolution (DCC), gated activation unit (GAU), and U-Net architecture.The model's capabilities are validated across two pivotal subtasks of trajectory segmentation, based on variable diffusion exponents and different dynamic models, respectively.Moreover, the adaptability of U-AnDi is demonstrated by thoroughly analyzing both single-model trajectories and multi-state biological trajectories, as well as diffusion exhibiting extended long-time correlations.The results manifest that U-AnDi excels in all these segmentation tasks, outperforming other comparative models.The superior performance of U-AnDi underscores its effectiveness and the interpretability of its core components: DCC, GAU, and U-Net, in reflecting the model's alignment with the nature of anomalous diffusion.Fur-thermore, the generalization ability of U-AnDi for realworld data is evaluated through experimental observations of the diffusion of transmembrane proteins on cell membrane surfaces [55].The segmentation results exhibit a high degree of consistency with experimental observations, highlighting the applicability of our approach to characterizing anomalous diffusion in real complex systems.
The rest of this paper is organized as follows.Sec.II describes the segmentation tasks for anomalous diffusion, methods for generating simulated trajectories, and main evaluation metrics used in this work.Sec.III presents the architecture and core components of U-AnDi and its design principles.Sec.IV provides an analysis of U-AnDi's efficacy on simulated trajectories and compares its performance with that of other models.The interpretability of U-AnDi's core components is consolidated in Sec.V.In Sec.VI, we showcase the implementation of our method on experimental trajectories of transmembrane protein on membrane surfaces.Finally, we engage in a discussion and draw our conclusions in Sec.VII.

II. TASKS AND DATASETS
In this section, we present the details of two subtasks for the semantic segmentation of anomalous diffusion and corresponding simulated datasets used for model training and evaluation.These tasks aim to effectively address the challenge of capturing the intermittent transitions among different diffusion states.Data generation for both tasks is facilitated by utilizing the open-source Python package, andi-datasets, which is specifically designed for generating, managing, and analyzing anomalous diffusion trajectories [25,56].In particular, we primarily focus on 2D trajectory data in this work, as most experimental observations of anomalous diffusion are performed in 2D or quasi-2D environments.

A. Subtask 1: Segmentation of trajectories with varying diffusion exponents
The first subtask focuses on the segmentation of trajectories in which the sub-trajectories exhibit varying diffusion exponents.Here, the diffusion exponent α quantifies the relation between mean squared displacement (MSD) and time t, written as MSD ∼ t α . ( This exponent equals 1 in the description of standard Brownian motion.For anomalous diffusion, it can be either less than or greater than 1, corresponding to subdiffusion and super-diffusion, respectively.In real-world scenarios, the diffusion exponent may not remain constant due to inevitable changes of interactions between the random walker and its surroundings [43].However, traditional statistical methods, which are based on the calculation of MSD, require sufficiently long trajectories to accurately determine the diffusion exponent.As a result, for anomalous diffusion trajectories with limited length scales, these conventional approaches face substantial difficulties when attempting to distinguish segments with different diffusion exponents. To address this challenge, subtask 1 is designed to empower our model with the capability to identify these segments and predict their corresponding diffusion exponents.In detail, simulated segments are generated by the andi-datasets package within the theoretical framework of fractional Brownian motion (FBM) [57].This diffusion model describes an ergodic diffusion process that is driven by a fractional Gaussian noise, where the diffusion exponent α satisfies 0 < α < 2. When generating segments, their diffusion coefficients are fixed at 1.0, while diffusion exponents α are drawn uniformly from the interval [0.05, 2).Here, to quantify the difference in diffusion exponents between two adjacent segments, we introduce δα = α 2 − α 1 , where α 1 and α 2 represent the exponents of front and rear segments, respectively.In particular, a minimum value for |δα| is set as δα min to ensure a distinct transition between diffusion states.The default value of δα min is 0.5 in this work.
After that, M segments are combined to form a trajectory of length L. Here, M is randomly selected from the values 2, 3, 4, and 5.The length of each segment, T , is determined from a uniform distribution, with its bounds set between a minimum length T min = 10 and a maximum length T max = L − (M − 1)T min .Representative example of a single simulated trajectory with L = 500 and M = 5 is illustrated in Fig. 1(a), where different segments are marked in distinct colors.Time evolution of this trajectory is depicted in Fig. 1(b) for both the x and y dimensions, indicating that the trajectory data exhibits typical time-series characteristics.We assign the diffusion exponents of segments to each point as point-wise labels, leading to a point-wise regression task for our model.As shown in Fig. 1(c), these labels enable the clear identification of transition points (changepoints) among different diffusion states.

B. Subtask 2: Segmentation of trajectories with different dynamics models
The second subtask aims to segment trajectories composed of segments, each with dynamics originating from a distinct diffusion model.It has been proven that the dynamics of anomalous diffusion is multifaceted and can be described by a variety of theoretical stochastic process models.Similar to the varying diffusion exponents in subtask 1, the anomalous diffusion dynamics observed in the real world often undergoes transitions due to changes or fluctuations in the surrounding media [42,55].For instance, the diffusion of transmembrane proteins on the cell membrane surface [55,58] exhibits a duality of dynamics, encompassing both FBM and continuous-time random walk [59].However, traditional statistical methods are not particularly adept at identifying the dynamics model from raw trajectory data, and the detection of transitions among these dynamics proves even more challenging.Therefore, developing effective methods to address this issue bears considerable significance for the analysis of anomalous diffusion behaviors and the elucidation of underlying physical mechanisms.
For that purpose, we design the subtask 2 with the goal of enabling our model to detect state changepoints in the diffusion process and accurately identify the dynamics models of segments.Five theoretical diffusion models are considered: • Annealed transient time motion (ATTM) [60]: Brownian motion with a diffusion coefficient that varies randomly in either time or space (0.05 ≤ α ≤ 1).
Under the guidance of these 5 models, segments are generated using the andi-datasets package.The procedure for forming a trajectory in this subtask is the same as in subtask 1, i.e., M segments are joined to form a trajectory of length L. The parameter values are also consistent with those in subtask 1.As an illustrative example, we present a typical sample of a trajectory with L = 500 and M = 5 in Fig. 1(d) and its corresponding time evolution for both x and y dimensions in Fig. 1(e).This trajectory with different dynamics models is also labeled in a point-wise manner, as depicted in Fig. 1(f).

C. Evaluation Metrics
The main evaluation metric for subtask1 is the MAE: Here, N is the number of trajectories to be evaluated.For the ith trajectory at time step t, α Pred i,t and α GT i,t denote the predicted and ground truth values of the diffusion exponent, respectively.
For subtask2, we select the mean Dice coefficient (mDice) as the main evaluation metric.The Dice coefficient, also known as the Sørensen-Dice coefficient, can measure the similarity of two samples and is commonly utilized in segmentation tasks [63].This metric can be calculated in subtask 2 as: Here, X Pred On the other hand, pinpointing the changepoints among diffusion states is of significant importance with respect to the segmentation of anomalous diffusion.However, when performing the changepoint detection, the model may generate some non-existent changepoints (false positives, FPs), while potentially missing genuine changepoints (false negatives, FNs).This inevitably leads to errors in the identification of state transitions.Hence, to systematically quantify the model's performance in detecting these transitions, we define δc as: where c Pred and c GT are the predicted and ground truth changepoints, respectively.For the model-predicted changepoints, we categorize those with |δc| < T min as true positives (TPs) and those with |δc| ≥ T min as false positives (FPs).The number of FNs can be obtained by subtracting the count of true positives (TPs) from the total number of actual changepoints.After that, we employ the metrics below to further evaluate model's performance in changepoint detection for both subtasks [34]:

III. MODEL STRUCTURE AND DESIGN PRINCIPLES
The U-AnDi model proposed in this work is constructed by integrating the WADNet encoder [34] into the U-Net architecture.This integration is primarily driven by the aim to effectively capture the intrinsic dynamics of anomalous diffusion, particularly the long-time correlations, with the help of dilated causal convolution (DCC) and gated activation unit (GAU).Another motivation is the utilization of U-Net's adeptness at capturing local features and nuances for semantic segmentation tasks, which complements the WADNet encoder's focus on long-range dependencies.In the following parts, we will introduce the design principles of U-AnDi in detail, and outline their connections with the underlying physics of anomalous diffusion.The detailed implementation of U-AnDi can be found in Appendix A, while the associated training scheme is outlined in Appendix B.

A. Dilated causal convolution
Considering that the motion of a random walker is solely determined by its current and past states, preserving causality to prevent using future information when processing the anomalous diffusion data is not just a technical requirement but a fundamental necessity.This crucial aspect is highlighted by Verdier et al. in their recent work [35], where the causality is maintained by selecting incoming edges of each node originate only from nodes TABLE I. Overview of comparative models, their respective abbreviations, and the presence (highlighted by ✓) or absence of key components: dilated causal convolution (DCC), gated activation unit (GAU), and U-Net architecture.

Model
Abbr.DCC GAU U-Net Long short-term memory [64] LSTM ✓ Gated recurrent unit [65] GRU ✓ Transformer [66] TFM WADNet encoder [34] WE in the past in a graph neural network (GNN).Unlike the specific wiring scheme used in the GNN model, U-AnDi employs causal convolution to preserve the causality inherent in anomalous diffusion.Specifically, when applying the causal convolution to calculate the output at time step t, only the data from the preceding t steps in the previous layer will be used.This can be achieved by applying padding on both sides of the sequence.
On the other hand, as the long-time correlation is one of the essential properties of anomalous diffusion, our design should empower U-AnDi with the capability to capture these extended dependencies in trajectory data.However, the receptive field of a standard causal convolution is limited, posing challenges in capturing the long-range dependencies in longer trajectories.To address this issue, dilated convolution is concurrently employed with causal convolution within the WADNet encoder.As highlighted in Ref. [47], dilated convolutions can systematically aggregate multi-scale contextual information without compromising resolution by harnessing the exponentially expanding receptive fields.This is particularly crucial when dealing with anomalous diffusion data, where discerning long-time tails and correlations is of utmost importance.A schematic representation of a dilated causal 1D convolution is given in Fig. 2(a), where the kernel size (ks) is set as 3. Notably, by doubling the dilation factor layer by layer, after applying convolutions for d (dilation depth) times, a single node can cover the information of 2 d+1 − 1 nodes in the input layer.This exponential expansion of receptive capability enables our model to encapsulate more long-range correlation information within the feature map.Consequently, it assists the model in appropriately balancing the sampling for measurements associated with long-time tails with respect to anomalous diffusion.

B. Gated activation unit
While the exponentially expanding receptive field enhances U-AnDi's ability in collecting long-range correlation information, effectively processing this information and subsequently inferring the intrinsic properties of anomalous diffusion remains a challenge.Recogniz-ing that anomalous diffusion often exhibits correlations where the influence of a past event decays slowly over time, the gated activation unit [64,65,67], with its capacity to maintain memory and manage information flow, is well-suited to capture these slowly decaying dependencies.Here, the gating mechanism within the GAU plays a pivotal role.Essentially, it acts as a regulatory system, determining which information should be allowed to pass through and which should be retained or discarded.Given the nature of anomalous diffusion, where certain events or states have prolonged effects, it's crucial for a model to discern which pieces of information are pertinent over extended periods.The gating mechanism allows the model to "remember" significant events from the past and "forget" or downplay less relevant ones.This selective retention on certain data points aligns perfectly with the characteristics of anomalous diffusion, ensuring that the model remains sensitive to long-time correlations.Therefore, to adeptly process the long-range information gathered by the dilated causal convolution, we integrate the GAU into our network encoder.The detailed structure of this encoder is depicted in Fig. 2(b), with a comprehensive description in a mathematical form provided in Appendix A.

C. U-Net architecture
For semantic segmentation tasks, the precise delineation of boundaries between distinct objects or states necessitates a model's capability to effectively capture local variations.This aspect is as crucial as apprehending long-time correlations when it comes to the semantic segmentation and transition detection in anomalous diffusion.The reason is that transitions in diffusion states typically don't manifest as slow and continuous processes but rather occur within short time intervals.
Therefore, to enhance the model's ability in detecting these local changes, we integrate the WADNet encoder into the U-Net architecture.Such an architecture, originally designed for biomedical image segmentation, has garnered significant attention due to its exceptional performance in various segmentation tasks.As illustrated in Fig. 2(c), U-Net utilizes a symmetric encoder-decoder architecture, ensuring that spatial information diminished during encoding is effectively reinstated during decoding.Moreover, skip connections in U-Net transfer fine-grained details from the encoder directly to the decoder, ensuring that local features and nuances are preserved and enhanced in the output.That is, U-Net captures fine details through skip connections and grasps the broader context with its encoder-decoder structure.This dual capability makes it well-suited for pinpointing state transition points in anomalous diffusion trajectories, where subtle local variations and long-range dependencies are closely interwoven.Details of constructing the U-Net architecture in this work are also provided in Appendix A.

IV. ANALYSIS OF MODEL PERFORMANCE ON SIMULATED TRAJECTORIES
In this section, we present the performance of the U-AnDi model in segmenting simulated trajectories of varying lengths.The results are based on evaluations conducted on the validation sets for both subtasks, each comprising 200 000 trajectories.Considering the "black box" nature of machine learning models, it is imperative to provide controls and calibrations analogous to standard tests in traditional analytical methods.For this reason, and to gain a deeper understanding of the individual contributions of U-AnDi's core components: DCC, GAU, and U-Net architecture, we also evaluate the performance of several comparative models.Our choice of comparative models is both strategic and comprehensive, encompassing the models outlined in Table I, with detailed specifications provided in Appendix C. By contrasting U-AnDi with these baseline models, we can distinctly discern the individual and synergistic contributions of DCC, GAU, and U-Net to the semantic segmentation of anomalous diffusion.

A. Performance of U-AnDi on subtask 1
To provide a more intuitive demonstration of U-AnDi's performance on subtask 1, we present four representative trajectories of length L = 500 and number of segments M = 2, 3, 4, 5 in the left panel of Fig. 3.The right panel compares their predicted values with the ground truth values.It can be observed that the predicted diffusion exponents are quite close to the ground truth values, with only minor differences noticeable in a few short intervals.Quantitatively, we show the MAE scores of U-AnDi on the validation set for various trajectory lengths spanning from 50 to 900 in Fig. 4(a).The performances of other comparative models are also presented for reference.Evidently, across all trajectory lengths, U-AnDi consistently achieves the lowest MAE.This result underscores U-AnDi's robust capability, which is augmented by the synergistic effects of DCC, GAU, and U-Net, in discerning segments with different diffusion exponents.Interestingly, as the trajectory length increases, the MAE for all models, with the exception of U-CNN, consistently decreases.This enhancement in segmentation performance with longer trajectories can be attributed to the extended average length of individual segments.Such elongation offers the model a richer feature information for analysis.
Upon further analysis, models that integrate the GAU (U-AnDi, WE, LSTM, and GRU) outperform those without it (TFM and U-CNN).This pronounced difference highlights the pivotal role and efficacy of GAU in dealing with long-time correlations inherent in anomalous diffusion.Moreover, models equipped with DCC (U-AnDi and WE) exhibit an additional boost in performance, emphasizing the significance of DCC in capturing long-range dependence information for anomalous diffusion segmentation.However, the U-CNN, which integrates DCC but lacks GAU, experiences a decline in segmentation performance as trajectory length increases.This suggests that, in the absence of GAU, the DCC's ability to process longtime correlations is somewhat lacking.Additionally, it implies that the U-Net architecture, being more attuned to local variations, might misinterpret features without the ability to effectively handle long-time correlations, especially as trajectory lengths grow.
Next, we use trajectories of length 500 to provide a detailed analysis of U-AnDi's segmentation performance on subtask 1.For a fine-grained comparison between predictions and ground truths of diffusion exponents, we present the 2D histogram of α Pred versus α GT in Fig. 4(b).As expected, the high-frequency pairs are predominantly located near the line α Pred = α GT , suggesting that the prediction errors of are small for all α GT values ranging from 0.05 to 2. However, it should be noted that the prediction errors are not entirely uniform across different α GT values.As displayed in Fig. 4(c), for α GT values close to 0 or 2, the errors are relatively smaller, while for values around 1, the errors tend to be slightly larger.This result can be attributed to the characteristics of FBM, which approaches standard Brownian motion without long-time correlations when α ≈ 1 [25].Compared to scenarios with pronounced long-range dependencies (where α is close to 0 or 2), its identification becomes relatively more challenging.Considering that α ≈ 1 might typify many experimental situations, we provide a higher-resolution histogram of α Pred versus α GT for α GT ranging from 0.8 to 1.2 in the inset of Fig. 4(c).As observed, even though the MAE is generally larger around α GT ≈ 1, the error distribution of U-AnDi's predictions remains relatively uniform without any pronounced bias, highlighting the stability of model's prediction for α ≈ 1.
Given that the variation in diffusion states between two adjacent segments can be characterized by the difference in their diffusion exponents, denoted as δα, we investigate the influences of δα on U-AnDi's segmentation performance to quantify the effects of state variations.MAEs corresponding to different values of δα are presented in Fig. 4(d) for three scenarios: δα min = 0.1, 0.5, and 0.8.A conspicuous feature of the MAE versus δα plots is their clear symmetry, indicating that whether the exponent α increases or decreases does not significantly affect U-AnDi's predictions.Moreover, in most cases, a larger magnitude of |δα| correlates with a lower MAE, suggesting that more pronounced differences in diffusion states facilitate the model's ability to discern transitions.However, an exception arises when |δα| ≈ 0, where this trend reverses.This is because a negligible |δα| might result in indistinct changes in diffusion states, prompting the model to treat two adjacent segments as a single diffusion state, thereby yielding errors commensurate with the magnitude of |δα|.In addition, we showcase the model's overall performance across different δα min values in Fig. 4(e).Notably, a larger δα min , which guarantees more significant diffusion state variations, results in a smaller MAE, aligning well with our expectations.
Besides the accuracy of predicting diffusion exponents, another crucial aspect is the identification of changepoints among different diffusion states.As shown in the right panel of Fig. 3, the U-AnDi model, which generates continuous point-wise values as its output, enables an approximate visual determination of the changepoint ranges.However, this output cannot provide precise demarcations between successive distinct diffusion states.To address this issue, we introduce a post-processing technique that converts the continuous point-wise predictions into discrete segmented predictions (see Appendix D for details).An example of this process is illustrated in Fig. 5(a).After applying the post-processing, the predictions for all points within each segment become consistent, allowing for the identification of changepoints through the abrupt changes in diffusion exponents, as denoted by the dashed lines in Fig. 5(a).Based on this technique, we can further quantitatively investigate U-AnDi's performance on the detection of changepoints.
We define the total number of changepoints in the validation set as TNC and display the distribution of δc as a percentage of TNC in Fig. 5(b), spanning from -9 to 9. The majority of δc values are clustered around 0, signifying a relatively small error in the prediction of changepoints.Interestingly, the distribution demonstrates a mild leftward skew, suggesting that the model has a slight inclination towards predicting changepoints earlier than their true positions.In addition, the relationship between δc and segment length T is also examined.As demonstrated in Fig. 5(c), we present the mean values of δc, denoted as δc, corresponding to various lengths of the front and rear segments adjacent to the changepoints.It is evident that for the vast majority of segment lengths, δc consistently aligns close to -1.This trend reinforces our previous observation that U-AnDi has a propensity to slightly anticipate changepoints.In particular, when the segment length approaches the trajectory length, the prediction error increases significantly.Such an increase occurs when one segment dominates the majority of the trajectory, relegating other segments to near-minimal lengths.These short segments provide limited feature information, leading the model to yield less accurate predictions.
Expanding our analysis on the changepoint detection, we probe the distribution of TP, FP, and FN as a percentage of TNC and compare these metrics with the results from WE and U-CNN, as illustrated in Fig. 5(d).Obviously, U-AnDi demonstrates a higher count of TP while exhibiting fewer instances of FP and FN, highlighting its superior precision and recall.To validate the generality of this observation, we explore the distribution of precision and recall for the three models across different trajectory lengths, with results summarized in Fig. 5(e).Unsurprisingly, U-AnDi consistently outperforms both WE and U-CNN in terms of precision and recall across all lengths.Moreover, as indicated by the arrows, which denote the direction of increasing trajectory length, U-AnDi exhibits remarkably consistent changepoint detection performance, maintaining stable precision and recall across varying lengths.In contrast, as trajectory length increases, WE shows a slight decline in precision while its recall remains stable; U-CNN, devoid of GAU, witnesses a more pronounced drop in both precision and recall.The F1-score variations across trajectory lengths for the three models are illustrated in Fig. 5(f).Mirroring the MAE trends seen in Fig. 4(a), U-CNN, without GAU, significantly underperforms in changepoint detection for longer trajectories compared to GAU-equipped U-AnDi and WE.These findings reemphasize the pivotal role of GAU in effectively managing the long-time correlations inherent in anomalous diffusion.

B. Performance of U-AnDi on subtask 2
In a manner consistent with subtask 1, we initially seek to visually demonstrate U-AnDi's performance on the segmentation of trajectories with different dynamics models.For this purpose, the segmentation results of four representative trajectories of length 500 with number of segments M = 2, 3, 4, 5 are summarized in Fig. 6.In more detail, Fig. 6 is organized into three rows for a coherent presentation.The first row [Figs.6(a 1 )-6(a 4 )] presents the visualizations of these four trajectories, using unique colors to differentiate segments associated with distinct diffusion models.Subsequently, comparisons of predictions with ground truths for each of the four trajectories are displayed in the second row [Figs.with a high degree of confidence (probability).
Building on the insights from subtask 1, we further quantitatively evaluate U-AnDi's performance on subtask 2. As depicted in Fig. 7(a), the mDice scores of U-AnDi and other comparative models across different trajectory lengths ranging from 50 to 900 align with the findings from subtask 1.This consistency not only underscores U-AnDi's robustness across different segmentation tasks of anomalous diffusion, but also reinforces our prior analysis about the functionalities of U-AnDi's core components: DCC, GAU, and U-Net.Further, we continue to use trajectories of length 500 as our primary example.To gain a deep insight into the error origins regarding this point-wise classification task, the confusion matrix of classification results is displayed in Fig. 7(b).As observed, while the classification accuracy for the CTRW, FBM, LW, and SBM models exceeds 97%, the accuracy for the ATTM model is merely around 86%.This discrepancy can be attributed to the machine-learning features of ATTM extracted by the WADNet encoder, which bear resemblance to CTRW, FBM, or SBM, as elucidated in Ref. [34].Consequently, this leads U-AnDi to occasionally misclassify ATTM steps as CTRW (5.62%), FBM (3.68%), or SBM (4.55%).
On the other hand, detecting changepoints among diffusion states holds significant importance in subtask 2 as well.In contrast to subtask 1, no additional postprocessing techniques are required for the detection in this task.We can efficiently determine the positions of changepoints by examining abrupt changes in the predicted labels.In Fig. 7(c), the distribution of δc values ranging from -9 to 9 is presented as a percentage of TNC.A distinction from subtask 1 is that 91.1% of the cases have δc values of 0, indicating a significant portion of the predicted changepoints aligning perfectly with the ground truths.Given the highly imbalanced distribution of δc values, a logarithmic scale is employed in Fig. 7(c) to enhance visualization.Moreover, δc as a function of the lengths of segments adjacent to changepoints is explored, with the results depicted in Fig. 7(d).Differing from subtask 1, the majority of data points for both front and rear segments are concentrated around 0. Even as the segment length nears the trajectory length, there is no significant escalation in error.This suggests that U-AnDi exhibits commendable stability in segmenting trajectories with varying diffusion models, even when dealing with very short segments.
Similar to subtask 1, regarding U-AnDi, WE, and U- CNN, the distribution of TP, FP, FN for L = 500, along with the plots of recall versus precision across varying lengths and the F1-scores for different lengths are illustrated in Figs.7(e), 7(f), and 7(g) respectively.While the results largely mirror those from subtask 1, a stark deviation is observed in the FP count of WE, which have increased dramatically [Fig.7(f)].This surge adversely impacts the WE's precision, rendering its F1-score lower than both U-AnDi and U-CNN [Fig.7(g)].Considering that WE lacks the U-Net architecture, it can be deduced that such an architecture plays a crucial role in adeptly processing intricate local fluctuations intertwined with long-time correlations for the segmentation of anomalous diffusion.
Building on insights from both subtasks, we further investigate the case where the diffusion exponent and the dynamic model concurrently vary within a single trajectory.Detailed findings of this analysis are presented in Appendix E, which confirms U-AnDi's adaptability and robustness in the face of such complex conditions.

C. Extended analysis on the segmentation of anomalous diffusion
While U-AnDi has demonstrated commendable segmentation performance in discerning changes in diffusion exponents and transitions among diffusion models, it remains imperative to assess its capabilities in more intricate and broadly relevant anomalous diffusion or single-particle tracking scenarios.The robustness and widespread applicability of U-AnDi in diverse contexts are pivotal for its integration into practical applications, offering significant utility to potential researchers in the anomalous diffusion field who may not be well-versed in machine learning.
For that purpose, we expand our analysis to encompass three other distinct segmentation tasks in this section.Each task is designed to mirror the complexities often encountered in the domain of anomalous diffusion, serving as a basis for a rigorous examination of U-AnDi's versatility in handling complex anomalous diffusion scenarios.

Semantic segmentation of single-model trajectories with constant parameters
In the landscape of anomalous diffusion research, while transitions between diffusion states are frequently observed, it is equally common to encounter scenarios where a random walker moves exclusively within a singular diffusion model framework [1].These single-model trajectories, devoid of state transitions, represent a fundamental and ubiquitous aspect of experimental studies.In our previous discussions, we center on trajectories that exhibit state transitions (with M ≥ 2).This emphasis naturally leads to considerations about U-AnDi's perfor- mance on single-model trajectories.Such an evaluation is crucial as it offers potential users insights into U-AnDi's stability and reliability across an expansive range of diffusion scenarios.
For this investigation, we generate trajectories of length 500 using six diffusion models: ATTM, CTRW, FBM, LW, SBM, and the Brownian diffusion (BD).BD is included because it represents the most fundamental diffusion phenomenon in experimental observations.Here, it should be noted that BD is equivalent to the scenario of FBM and SBM when the diffusion exponent α = 1.To ensure the generality of our results, we extensively evaluate U-AnDi across a broad range of core parameters for the diffusion models.For the first five models, the selected parameter is α, with its range consistent with the description in Sec.II B for each model.For BD, the parameter is the diffusion coefficient D, which spans a range from 0.5 to 10. Further, to guarantee statistical robustness, we generate 10 000 trajectories for each pa-rameter value for testing.For convenience, we introduce two nomenclatures in this section: "U-AnDi-Exponent" refers to the model from subtask 1 that segments based on diffusion exponent, while "U-AnDi-Model" pertains to the model from subtask 2 that segments based on the diffusion model.
We first assess the performance of U-AnDi-Exponent on FBM trajectories with fixed diffusion exponents α.
To visualize the variation between the predicted values and the fixed exponent, we display the predictions of U-AnDi-Exponent for three representative trajectories with α = 0.3 (subdiffusion), 1.0 (Brownian diffusion), and 1.7 (superdiffusion) in Figs.8(a)-(c), respectively.Across these scenarios, the model's predictions closely cluster around the true values, indicating only slight variation.Quantitatively, we present the MAE scores for various α values in Fig. 8(d).It is evident that MAE values are all approximately around 0.07, suggesting consistently minor fluctuations.
Furthermore, we apply the post-processing technique described in Appendix D to identify changepoints.Given that these trajectories inherently lack changepoints, our analysis concentrates on the FPs in the predictions.We define the mean number of FPs per trajectory within the dataset as mFP and illustrate the distribution of mFP for different α in Fig. 8(e).Despite the fluctuation of mFP in response to changes in α, the values consistently remain low.Notably, by increasing the threshold ϵ in the post-processing technique, the model's precision can be further improved, as evidenced by a reduction in mFP [Fig.8(e)].Overall, U-AnDi-Exponent demonstrates a remarkable stability in dealing with FBM trajectories with constant parameters.In particular, the flexibility of our approach allows users to refine the precision of changepoint detection through threshold customization, thereby tailoring the model to their specific needs.
On the other hand, we employ U-AnDi-Model to test single-model trajectories generated by the six diffusion models.In addition to utilizing mFP as the evaluation metric [Figs.9(a 1 )-9(a 6 )], the mean proportion of predicted diffusion models within each individual trajectory, denoted as r, is displayed in Figs.9(b 1 )-9(b 6 ) to manifest the variation between predicted and true values.It is noteworthy that for ATTM, CTRW, FBM, LW, and SBM, the true model accounts for at least 87% of the predicted composition, underscoring the robustness of our method in this task.Since U-AnDi-Model primarily relies on the distinctive features of diffusion models to determine changepoints, the magnitude of mFP on singlemodel trajectories is largely influenced by the uniqueness of the diffusion model relative to others.For instance, the characteristics of LW are notably distinct from the other five models (Ref.[34]), allowing for a stable identification of LW without predicting state transitions, i.e., mFP = 0 for all α [Fig.9(a 4 )].Conversely, for FBM and SBM, as α approaches 1, the trajectories of these two models converge towards the characteristics of Brownian diffusion.This convergence results in an overlap that challenges U-AnDi's discriminative power, leading to an increased incidence of FPs [Figs.9(a 3 ) and 9(a 5 )].This phenomenon is also evident when U-AnDi-Model is tasked with analyzing BD trajectories, where the mFPs closely mirror those observed for FBM and SBM with α = 1 and are considerably higher than the forecasts by U-AnDi-Exponent [Fig.9(a 6 )].As shown in Fig. 9(b 6 ), predictions for BD trajectories show a significant proportion attributed to both FBM and SBM, emphasizing the indistinguishability between these two at α = 1.

Segmentation of simulated multi-state trajectories in biological experiment scenarios
In the realm of single-particle tracking experiments within biological systems [68][69][70][71][72][73], the microdynamics of the observed entities are prone to transitions due to environmental influences, necessitating effective methods for segmenting the trajectory data.However, in such experimental systems, the diffusion dynamics often observed are not limited to specific anomalous diffusion models but include transitions among Brownian, confined, directed, and immobile states.These states correspond to: • Brownian diffusion (BD): Free movement characterized by random walks, reflecting the absence of constraints in an open environment.
• Confined diffusion (CD): Restricted movement within certain boundaries, such as within cellular compartments or membranes.
• Directed Motion (DM): Motion driven by the external force or energy, such as bacteria propelled by flagellar motion or cells migrating in response to chemical signals.
• Immobile state (IS): A state where particles are trapped or bound to structures within the cell, exhibiting little to no movement over time.
For instance, as described in Ref. [38], molecules like CD44 in macrophages can exhibit these states.CD44 molecules display confined diffusion when interacting with the actin cortex, free diffusion when such interactions are inhibited, and immobility possibly when tethered to the cortex.Hence, to validate the effectiveness of U-AnDi in such biological experimental scenarios, we primarily adopt the simulation methods from Ref. [38] to generate segments representing these four dynamic states.We then combine these segments using the same approach as in subtask 2 to create composite trajectories for the validation, with a representative example of length L = 500 illustrated in Fig. 10(a).The simulation methods for these segments are detailed in Appendix F. The training of U-AnDi follows the same protocol as in subtask 2.
Furthermore, to observe the potential advancements of our model over conventional approaches, we benchmark the performance of U-AnDi against the traditional divide-and-conquer moment scaling spectrum (DC-MSS) analysis method [38].A brief introduction to DC-MSS is provided in Appendix C. As displayed in Fig. 10(b), we present the segmentation results of both methods on the trajectory shown in (a).It is evident that U-AnDi's predictions align almost perfectly with the ground truth, whereas DC-MSS exhibits numerous misjudgments, including incorrect state identification and changepoint detection errors.Quantitatively, we compare the mDice scores of both models for trajectories of varying lengths, ranging from 50 to 900, and summarize the results in Fig. 10(c).Notably, U-AnDi decisively outperforms DC-MSS across all lengths with mDice close to 1, indicating a significantly higher accuracy in state identification.
Similarly, U-AnDi's performance in detecting state transitions is markedly superior to that of DC-MSS.As with subtask 2, Figs.10(d)-10(f) detail the distribution of TP, FP, and FN as a percentage of TNC for L = 500, plots of recall versus precision for different trajectory lengths, and the variation of the F1-score with trajectory length, respectively.Across various lengths, U-AnDi demonstrates high precision, recall, and F1-scores, while DC-MSS lags in performance.Additionally, as trajectory length increases, DC-MSS shows a gradual increase in recall but a decrease in precision, revealing a trade-off between the two metrics.[Figs.10(e)].This trade-off results in uniformly low F1-scores for all lengths, which is evident from Figs. 10(f).
These findings underscore U-AnDi's exceptional segmentation capabilities for anomalous diffusion trajectories in biological experimental scenarios.They also highlight the significant performance gap between unsupervised algorithms like DC-MSS and supervised approaches, reinforcing the superiority of the latter in trajectory segmentation tasks.

Evaluating U-AnDi with more long-time correlations
Considering that long-time correlations are a fundamental property inherent to anomalous diffusion behaviors, we aim to further validate the versatility and adaptability of U-AnDi in segmenting trajectories characterized by more correlations.To achieve this, we generate trajectories where the velocity autocorrelation functions (VACFs) conform to four distinct long-time correlations.Subsequently, U-AnDi is employed to segment these trajectories.The chosen correlation functions for this evaluation are listed in the following paragraph.To maintain clarity and without loss of generality, we present the mathematical expressions in a one-dimensional framework in this section.
We denote C(t) = ⟨v(0)v(t)⟩ as the VACF.Four longtime correlation functions are detailed below: • Exponential decay (exp): where A is the amplitude and τ is the time constant.
• Multi-exponential decay (multi-exp): Here, A is the amplitude, ϕ is the weighting factor.τ 1 and τ 2 are the time constants of two exponential decays, respectively.
• Exponentially damped cosine wave (exp-cos): where A is the amplitude, τ is the time constant, and ω is the angular frequency.
We generate these trajectories using a modified version of the "fbm" Python package [75, 76], which employs the Davies-Harte algorithm [77].Associated codes are available in our GitHub repository [78].The effectiveness of this generation method is validated in Appendix G. Labels for the trajectory segmentation are determined based on the diffusion behaviors corresponding to their long-time correlations.Using the equation below [79]: it is evident that trajectories exhibiting exp, multi-exp, and exp-cos correlations manifest long-time Fickian behaviors (see Appendix G), i.e., MSD ∼ t.Consequently, for these three types of correlations, we utilize the longtime diffusion coefficient D as the target for trajectory segmentation.On the other hand, as outlined in Ref. [80], the diffusion exponent α of trajectories characterized by the M-L correlation equals 2 − λ.Therefore, for trajectories with the M-L correlation, we choose α as the segmentation label.In Table II, we provide a summary of the parameters, labels, and corresponding equations to calculate segmentation labels (see Appendix G for details) with respect to the four long-time correlations.Trajectory segments are combined to form a composite trajectory using the same method as in subtask 1.Additionally, the model and training approach remain consistent with those applied in that subtask.We evaluate U-AnDi's segmentation performance using MAE and F1-score, and compare it with WE and U-CNN.The results, illustrated in Fig. 11, encompass not only the performance of U-AnDi for the four distinct long-time correlations but also its evaluation scores in subtask 1, which pertains to the power-law correlation.A clear observation from the results is the superior performance of U-AnDi in comparison to both WE and U-CNN across all five types of long-time correlations, whether evaluated based on MAE or F1-score.Such consistent superiority across diverse correlation types highlights U-AnDi's robust adaptability, emphasizing its potential to serve as a universal scheme for the segmentation of time-series data.
Interestingly, as quantified by the MAE, both U-AnDi and WE exhibit a notably better performance in predicting the diffusion exponent compared to the diffusion coefficient.However, this distinction is not evident in the case of U-CNN.A potential reason for this difference can be attributed to the inherent characteristics of diffusion coefficient and diffusion exponent.While the diffusion coefficient primarily captures the "speed" of diffusion, the diffusion exponent provides deeper insights into the underlying mechanisms of diffusion process, inherently reflecting the long-time correlation information.Consequently, the diffusion exponent can be more readily predicted by models like U-AnDi and WE, both of which are adept at processing long-time correlations with the help of GAU.In contrast, U-CNN, which lacks the GAU, does not exhibit a similar advantage.

V. INTERPRETABILITY OF U-ANDI'S CORE COMPONENTS
The quest for interpretability in machine learning, particularly within the realms of physical sciences, is not merely a pursuit of operational transparency but a foundational requirement for scientific validity.In this work, the comparative evaluation of U-AnDi against other models partially diminishes the "black box" associated with our machine learning model, shedding light on the inner working of U-AnDi's core components: DCC, GAU, and U-Net.As long-time correlation is one of the fundamental properties of anomalous diffusion, these components faithfully encapsulate this underlying nature and are in strict accordance with our design principles.Within this section, we consolidate the interpretability insights that has been gained from the comparison among the performance of U-AnDi and its comparative models in the aforementioned tasks.

• Dilated causal convolution: Capturing long-time correlations
To effectively capture the pivotal long-time correlations inherent in anomalous diffusion, DCC, with its exponentially expanding receptive fields, is designed to encompass the full spectrum of these extensive dependencies.This enables DCC to acquire a comprehensive integration of temporal information across scales, ensuring that the long-time correlations are accurately represented within the model's predictions.Such an advantage is reflected in the enhanced performance of U-AnDi as well as WE's competitive superiority over other counterparts, where both models incorporate the DCC.
• Gated activation unit: Processing long-range dependencies To adeptly navigate the intricate long-time correlations in anomalous diffusion, the integration of GAU is engineered to leverage its gating mechanism to selectively emphasize salient temporal features.This selective filtration and prioritization by GAU are not merely structural benefits but are directly responsive to the characteristic memory effects and non-local interactions of anomalous diffusion.By modulating the flow of information, the GAU ensures that the model's focus is attuned to the most critical aspects of the data, which are indicative of the underlying long-time correlations.The superior performance of models equipped with GAU across all subtasks robustly demonstrates the proficiency of GAU in effectively processing long-time correlation information.
• U-Net architecture: Enhancing detection of local changes When segmenting the anomalous diffusion trajectories, the abrupt transitions and heterogeneous local dynamics demand a model's ability not only in emphasizing long-time correlations but also in precisely delineating local variations.The U-Net architecture excels in this regard, capturing fine details through skip connections, while concurrently grasping the broader context with its encoder-decoder framework.This dual capability makes U-Net exceptionally well-equipped to identify state transition points in anomalous diffusion.In this work, the integration of WE within the U-Net framework further refines the model's segmentation performance, covering all metrics.This result reinforces the utility of U-Net in the segmentation and changepoint detection of anomalous diffusion.
The interpretability of U-AnDi's core components is a tangible reflection of the model's alignment with the complex nature of anomalous diffusion.By capturing longtime correlations and enhancing the detection of local changes, these core components collectively contribute to the model's robust performance across varied segmentation tasks, bridging the gap between advanced machine learning techniques and the fundamental principles of anomalous diffusion.

VI. IMPLEMENTATION OF U-ANDI ON REAL-WORLD ANOMALOUS DIFFUSION DATA
In this section, we apply the U-AnDi model to realworld anomalous diffusion data and examine its performance on the semantic segmentation of experimental trajectories.The selected real-world system is the diffusion of transmembrane proteins on cell membrane surfaces, as illustrated by the schematic diagram in Fig. 12(a).The pertinent data are obtained through single-particle tracking techniques [68][69][70][71][72][73] from experimental observations, and are provided by N. Granik et al. in Ref. [55].The content of this section is structured as follows.Sec.VI A provides an overview of the raw experimental trajectory dataset, and describes the segmentation tasks along with the approach for preparing the validation set.The training strategy is outlined in Sec.VI B. In Sec.VI C, we demonstrate and discuss the performance of the U-AnDi model on interpreting the anomalous diffusion dynamics of transmembrane proteins.

A. Dataset description and segmentation tasks
The dataset with respect to the diffusion of transmembrane proteins on membrane surfaces comprises a total of 70221 2D trajectories, in which the x and y pixel locations are provided.The distribution of trajectory lengths is displayed in Fig. 12(b), with the counts plotted on a logarithmic scale to enhance clarity in visualization.An evident long tail distribution can be identified.In detail, trajectories of lengths no greater than 100 account for 98.6% (69259) of the entire dataset , while the maximum length in this dataset reaches 1406.Diffusion models of these trajectories have been previously assessed by machine learning approaches in Ref. [55], with N. Granik et al. proposing that the predominant dynamics consist of both CTRW and FBM.Therefore, this dataset offers us an excellent opportunity to test the segmentation performance of U-AnDi on experimental data.
Two specific segmentation tasks are addressed here: one involving labeled data and the other utilizing unlabeled data.In the task with labeled data, the validation set is prepared as below.Trajectories to be evaluated are generated by combining short trajectories with lengths not exceeding 100 from the experimental dataset.Diffusion-model labels of these short trajectories are as-signed by WADNet, a deep learning model capable of providing the probability of the diffusion model to which the input trajectory is most likely to belong.Further details regarding WADNet can be found in our previous work [34].Leveraging the model probabilities provided by WADNet for these short trajectories, we carefully select CTRW and FBM instances that exhibit high confidence levels (with probabilities of CTRW or FBM exceeding 0.9) to generate extended trajectories for further evaluation.Representative samples of these selected short trajectories with different lengths are illustrated in the inset of Fig. 12(b).The quantities of short CTRW and FBM trajectories spanning various lengths from 10 to 100 are presented in Fig. 12(c).By setting the overall trajectory length L and the number of segments M , we can utilize these short trajectories to create the validation set, thereby facilitating the evaluation of U-AnDi's performance.In particular, we establish a rule specifying that the average length of segments (L/M ) should not exceed 50.This constraint ensures the prevention of trajectory generation errors or the dominance of overly long segments.
On the other hand, in the task concerning unlabeled data, we employ the U-AnDi model to segment those long trajectories with lengths exceeding 100.To examine the performance of our model, the segments distinguished by U-AnDi are classified by WADNet to identify their corresponding diffusion models.Due to the absence of ground truth labels, we cannot use a conventional evaluation metric like the mDice to assess the segmentation results.Instead, we rely on the confidence levels (probabilities) provided by WADNet to evaluate the effectiveness of our model.

B. Training scheme
The architecture of the U-AnDi model and training methods in this section remain almost identical to those in subtask 2. One deviation is a reduction in the filter number of the last 1D convolutional layer from 5 to 2. This modification is due to the task at hand, which requires semantic segmentations of just two diffusion models, CTRW and FBM.Another update is the initialization of model weights.To accelerate the training process, we adopt a transfer learning strategy where the optimal model weights from subtask 2 are employed to initialize the model.This strategy allows the model to reach optimal performance within approximately 10 epochs, significantly reducing the training time.
In addition, taking the inevitable errors and noise during experimental observations into account, Gaussian white noise with a zero mean and a standard deviation of σ n is added when generating simulated trajectories for training.In order to pinpoint the optimal σ n and better mimic the circumstances of real experimental data, we select two validation sets comprising of experimental trajectories to evaluate the performance of U-AnDi at different σ n .The parameters for these two validation sets are L = 100, M = 3 and L = 200, M = 5, respectively, with each set consisting of 1000 trajectories.As demonstrated in Fig. 12(d), for both validation sets, U-AnDi achieves the best performance (the highest mDice score) when σ n = 0.125.Consequently, simulated trajectories with the standard deviation of noise σ n = 0.125 are chosen to train the U-AnDi model in this section.

C. Performance of U-AnDi on two tasks regarding experimental trajectories
For the task involving labeled data, we investigate the performance of U-AnDi on validation sets with different parameters, as quantified by the mDice scores.The results are summarized in Fig. 12(e), where each validation set contains 1000 trajectories.It is observed that all mDice scores are above 0.8 for trajectory lengths ranging from 100 to 300, indicating an exceptional capability of U-AnDi in segmenting experimental trajectories.We also observe that segmentation performance decreases as trajectory length increases.This trend may be due to the fact that trajectories with larger L are composed of longer segments, which introduce more noise and thus can mislead the model's classification accuracy.Moreover, to illustrate the segmentation results intuitively, we present two representative samples from the validation sets, along with their corresponding predicted labels, in Figs.12(f) and 12(g).Comparisons between the predictions and ground truths of these two samples are presented in the left and right panels of Fig. 12(h), respectively, with a high degree of consistency being observed as expected.
Next, in the task with unlabeled data, we utilize the trained U-AnDi model to segment natural trajectories in the experimental dataset with lengths exceeding 100.In the absence of ground truth labels, we leverage WADNet to obtain probabilities of diffusion models for the segments identified by U-AnDi.To provide a concrete illustration of the model's effectiveness, three representative trajectories and their corresponding results are displayed in Fig. 13.As distinguished by the distinct colors, trajectories in Figs.13(a)-13(c) are segmented by U-AnDi into 2, 3, and 4 segments, respectively.The corresponding probabilities of diffusion models for these segments are presented in Figs.13(d)-13(f).Observations suggest that, for the majority of segments, the diffusion models with the highest confidence levels (probabilities) remain CTRW and FBM.Nevertheless, for the second segment of the trajectory in Fig. 13(c), SBM is identified by WAD-Net as the most probable diffusion model.The result derived from our analysis on the task involving unlabeled data affirms the conclusion of N. Granik et al. that the diffusion of transmembrane proteins on cell membranes primarily exhibits CTRW and FBM characteristics [55].However, it also hints that this conclusion may not be a comprehensive description of the entire diffusion process, which could potentially entail a higher degree of complexity.

VII. CONCLUSION
In summary, we have introduced U-AnDi, a novel deep learning model for the semantic segmentation of anomalous diffusion trajectories, which integrates the strengths of the dilated causal convolution (DCC), gated activation unit (GAU), and U-Net architecture.A variety of segmentation tasks have been addressed, demonstrating a superior performance of U-AnDi against other methods.Comparative evaluations underscore the interpretability of U-AnDi's core components and, to a certain extent, mitigate the "black box" nature of deep learning models, aligning them with the complex physics of anomalous diffusion.Further, U-AnDi also exhibits an excellent capability in dealing with the real-world anomalous diffusion data, which is examined using the experimental dataset regarding the diffusion of transmembrane proteins on cell membrane surfaces.The supporting codes in this work are accessible at our GitHub repository [78].
Despite the promising performance of our model, there still exist opportunities for further refinements.The first is optimizing the detection of changepoints among different diffusion states, where reducing FP and FN can be a critical task for future training and finetuning.Secondly, the implementation of U-AnDi is trained to recognize only five diffusion models in this study.Extending the model's ability to identify a larger variety of diffusion models would enhance the utility of U-AnDi in future research.Such an expansion would enable researchers to apply U-AnDi more effectively in the segmentation and property prediction of experimentally observed heterogeneous diffusion dynamics.
Additionally, considering that U-AnDi does not require specific prior knowledge about anomalous diffusion, this model has the potential to be trained and perform segmentation tasks on other time-series datasets instead of anomalous diffusion.In other words, our method not only provides a powerful and versatile tool for better understanding the dynamics of anomalous diffusion, but it also holds promise to be generalized as a universal scheme for the segmentation of time-series data.
with ks = 1.W f,k and W g,k are independent dilated causal 1D convolutions with ks = 3 and dilation = 2 k−1 .h k is directly used as the input of next (k + 1)th layer, meaning x k+1 = h k .The output z of an encoder can be finally obtained by z = x 1 + d k=1 h k .For convenience, we denote the operation of WADNet encoder as W(•), i.e., z = W(x), in the following discussion.In particular, the encoder in the down-sampling block of U-Net is denoted as W d , while the one in the up-sampling block is represented as W u .
By incorporating this encoder into the U-Net structure, we construct the U-AnDi model, with its architecture displayed in Fig. 2(c).The down-sampling block consists of a WADNet encoder, a batch normalization layer, and a max-pooling layer.We employ four consecutive down-sampling blocks to perform feature extraction on the input tensor.In the mth block, the input v m is processed as governed by: where m = 1, 2, 3, 4. BN and MaxPool represent the batch normalization [81] and max-pooling operators, respectively.The filter number f m in encoder W d m is 64 × 2 m−1 for subtask 1 and 128 × 2 m−1 for subtask 2. The pooling size of max-pooling layer is set to 2.
Next, the output from the 4th down-sampling block, v 5 , is processed through five consecutive up-sampling blocks to generate full-resolution feature maps, which are then used for point-wise predictions.The up-sampling block is comprised of a WADNet encoder, a batch normalization layer, an up-sampling layer using the nearest neighbor algorithm, and a 1D convolutional layer with ks = 1.In particular, skip connections are applied to get the input p n of the nth up-sampling block when n ≥ 2, as displayed by the dashed lines in Fig. 2(c).These connections serve to reduce the loss of fine-grained details during the up-sampling process and can be mathematically described as: where n = 2, 3, 4, 5 and p 1 = v 5 .UP denotes the upsampling operator, with a scale factor set as 2. Concat is the concatenation operator, which is applied in the channel dimension.The filter number f n in encoder W u n is 64 × 2 5−n for subtask 1 and 128 × 2 5−n for subtask 2. The filter number of the 1D convolutional layer W 1 n is half that of in encoder W u n .Note that when performing the skip connection in Eq. (A5), the shapes of pn and u 6−n might not match.In such cases, we apply padding to pn to make it compatible with u 6−n for concatenation.In the last up-sampling block, the up-sampling layer is removed, and the filter number of the convolutional layer is adjusted (1 for subtask 1 and 5 for subtask 2).This yields a final output p f of the U-AnDi model, written as: To illustrate the details of the U-AnDi architecture more clearly, we take a trajectory with L = 500 as the input and present the shapes of intermediate tensors for subtask 2 in Table III.The shape follows the format [length, channel].
The post-processing techniques used to obtain the final predictions for both subtasks are summarized below.In subtask 1, which is a point-wise regression task, the output p f from a trained U-AnDi model serves as the predicted diffusion exponents.To ensure a reasonable prediction with exponents ranging from 0.05 to 2, values outside the interval are clipped to the interval edges in p f .On the other hand, p f is transformed using the following equations in subtask 2 to address this point-wise classification task: Here, i denotes the ith trajectory.Softmax represents the softmax activation function.X Prob i and X Pred i are the predicted probability and label, respectively.

Appendix B: Data preprocessing and training scheme of the U-AnDi model
To train our deep learning model, 1 000 000 trajectories are generated as the dataset for a fixed length parameter L. This dataset is randomly split into two parts: 80% for the training set and 20% for the validation set.The raw trajectory data is independently normalized along the x and y dimensions, achieving a mean of 0 and a standard deviation of 1 for each dimension.Then, the normalized data from both dimensions, [x(1), x(2), x(3), • • • , x(L)] and [y(1), y(2), y(3), • • • , y(L)], are concatenated to form a sequence: which is utilized as the input of the U-AnDi model.The selected loss functions are mean squared error (MSE) for subtask 1 and cross entropy (CE) for subtask 2. The model is trained using the back-propagation algorithm with a batch size of 512 on a single NVIDIA A100 GPU.The learning rate is 0.0002, and the optimizer is Adam.In particular, an L2 penalty is applied for subtask 2 with a weight decay of 2 × 10 −5 .The training process involves 100 epochs for subtask 1 and 200 epochs for subtask 2. The model performance on the validation set is evaluated every 1000 steps.
We use the trajectory data with L = 500 as the example to illustrate the evolution of loss function during training, as shown in Fig. 14(a) for subtask 1 and Fig. 14(b) for subtask 2. A rapid convergence of the train loss can be observed for both tasks, with the valid loss exhibiting a similar trend.This indicates that our model is fully capable of accomplishing both tasks without encountering over-fitting issues.Furthermore, the optimal weight of the U-AnDi model is determined based on the best metric achieved on the validation set.The epoch dependences of valid metrics for subtask 1 and 2 are presented in Figs.14(c) and 14(d), respectively.As indicated by the yellow dot, the selected weight corresponds to the step where the best metric is reached.where β i = α i+1 − α i .Next, we set a threshold value ϵ and identify all indices i satisfying β i > ϵ.These indices form a new sequence: If two consecutive indices i m and i m+1 in this sequence meet i m+1 − i m ≥ 10, we denote i m + 1 as the starting point of the current segment, and i m+1 as the endpoint of this segment.Then, the changepoint between two successive predicted segments [i a + 1, i a+1 ] and [i b + 1, i b+1 ] can be identified in the interval [i a+1 + 1, i b ].We select the point within this interval that exhibits the maximum absolute value of the derivative as the changepoint.Applying this rule, we can obtain the sequence of changepoints, given by: Here, c 2 , c 3 , • • • , c n−1 are the predicted changepoints, and c 1 and c n are set as 1 and L, respectively.Based on the detection result of changepoints, the predicted diffusion exponent αi of the ith segment can be given as: In particular, the method for determining the threshold value ϵ is summarized here.A larger ϵ tends to yield higher precision in detecting changepoints, albeit with a lower recall, while a smaller ϵ may compromise the precision but enhance recall.Therefore, as ϵ increases, the F1-score for changepoint detection initially rises and subsequently diminishes, as depicted in Fig. 15(a).Concurrently, alterations in ϵ also induce variation in the model's MAE, as illustrated in Fig. 15(b).Under these circumstances, the selection of ϵ emerges as a result of balancing a trade-off between MAE and F1-score on the validation set.In more detail, we select the optimal ϵ from a candidate interval where the F1-score is at least 98% of its maximum value, as indicated by the vertical dashed lines in Fig. 15(a).Within this interval, we seek the ϵ that minimizes the MAE value.In this work, 0.028 is identified as the optimal ϵ, as highlighted by the yellow dot in Fig. 15(b).
Appendix E: Addressing concurrent exponent and model variations using multi-task learning The versatility of U-AnDi has been previously highlighted for its effectiveness at segmenting trajectories based on variations in either the diffusion exponent or the dynamic model.However, real-world scenarios often present more intricate challenges where both exponent and model might concurrently vary within the same trajectory.To address this issue, we have further enhanced U-AnDi's capabilities through the integration of a multitask learning strategy in this section.
The method for simulating trajectories with concurrent variations in both exponent and model is an extension of the approach used in subtask 2. We combine segments from different diffusion models to generate a composite trajectory, as illustrated in Fig. 16 In line with the presentation style of subtask 1 and 2, we demonstrate U-AnDi's segmentation performance on trajectories of length 500 here.To visualize this intuitively, segmentation results for the diffusion exponent and dynamic model of the trajectory in Fig. 16(a).are illustrated in Figs.16(c) and 16(d), respectively.As expected, both predictions display a high degree of alignment with the ground truth.The results on the validation set yield an MAE of 0.1376 and an mDice of 0.9474, indicating that U-AnDi can effectively segment trajectories where the exponent and model concurrently vary.
On the other hand, when it comes to the detection of changepoints, Fig. 16(e) reveals that TP consistently ranks highest for both segmentation tasks, whether based on the exponent or the model.F1-scores achieved for these two detections are 0.8501 and 0.8269, respectively, underscoring a robust capability of U-AnDi in identifying changepoints.Furthermore, as depicted in Fig. 16(f), we compare the detection results with those from subtasks 1 and 2. For both exponent and model changepoint detections, there's a decline in recall, with the latter also experiencing a noticeable decrease in precision.The common reduction in recall can be attributed to the increased complexity of the task.The diminished precision in de-tecting model changepoints might stem from variations of diffusion exponent within a single model segment.These variations potentially result in occasional misinterpretations and consequently lead the model to detect more transition points than actual.
Appendix F: Simulation of multi-state trajectories in biological experiment scenarios In this section, we introduce the simulation techniques in detail for generating trajectories that represent different states commonly observed in biological experiments.These techniques are primarily adapted from the procedures described in Ref. [38].While the simulation parameters for each individual trajectory remain constant, they differ across the various trajectories.The chosen parameters align closely with those in Ref. [38] to ensure an equitable evaluation of the DC-MSS method's segmentation performance.
• Brownian diffusion (BD): Simulating the free Brownian diffusion requires a series of x and y displacements.Each displacement is drawn from a Gaussian distribution N (0, √ 2Dδt), where D is the diffusion coefficient and δt is the time interval.We set δt = 1 and select D uniformly from the range 1.0 to 3.0.
• Confined diffusion (CD): The generation of confined diffusion trajectories is akin to that of free Brownian diffusion trajectories.However, a reflection occurs once the subsequent coordinate of the random walker exceeds the boundary of the confined region.This confined region is defined as a circle with a radius R. Here, the radius R ranges from 3.0 to 5.0, while the diffusion coefficient D varies between 1.0 and 3.0.
• Directed motion (DM): Each displacement in a trajectory of the directed motion consists of two components: a Brownian diffusive component with a diffusion coefficient D ∈ [1.0, 3.0] and a directed component.The directed component is defined by v cos θ • δt for x-displacement and v sin θ • δt for ydisplacement.The drift velocity, v, varies between 2.0 and 3.0, while the drift angle, θ, spans from 0 to 2π.
• Immobile state (IS): The simulation of immobile state is achieved by generating x and y coordinates from a Gaussian distribution N (0, σ p ).Here, σ p represents the positional localization error, with values ranging from 0.8 to 1.6.
Leveraging these simulation techniques, we employ the same approach as in subtask 2 to combine trajectory segments of four diffusion states, ultimately producing the multi-state trajectories in biological experiment scenarios.The codes for trajectory generation can be found in our GitHub repository [78].Appendix G: Validating the method for generating trajectories with defined correlation functions Within this appendix, we will validate the effectiveness of our trajectory generation method based on the Davies-Harte algorithm.For that purpose, we initially compare the velocity autocorrelation functions [VACFs, C(t)] of trajectories generated using this method under various parameters with their theoretical values.The results of this comparison are summarized in Fig. 17.As observed, for the four types of long-time correlations, i.e., exp, multi-exp, exp-cos, and M-L, VACFs of simulated trajectories (represented by dots) align closely with their respective theoretical values (depicted by lines).This consistency strongly attests to the validity of our trajectory generation method.
On the other hand, from the perspective of MSD, we further validate the effectiveness of this method.Using the equation MSD = 2 t 0 (t − s)C(s)ds, we derive the theoretical expressions for exp, multi-exp, and exp-cos correlations, as detailed in Table IV.From the long-time behavior of MSD, we can discern that the trajectories associated with exp, multi-exp, and exp-cos correlations exhibit long-time Fickian diffusion theoretically.This diffusion type is typically represented by MSD ≈ 2Dt, where D denotes the long-time diffusion coefficient.To substantiate this, we present the relationship between MSD/(2D) and time t for simulated trajectories of these three types of correlations in Fig. 18(a).The slope of 1.0 across these plots confirms that MSDs for these trajectories are consistent with their theoretical descriptions.For the M-L correlation, the theoretical MSD value is determined via numerical integration.In Fig. 18(b), we present the MSDs of simulated trajectories for specific λ values of 0.6, 1.2, and 1.8 in a log-log form.These are juxtaposed with their theoretical predictions, underscoring a pronounced congruence between them.Furthermore, as indicated by the slope, the long-time diffusion exponent α derived from our measurements relates to λ following the relationship α = 2 − λ.This observation agrees well  13), are also depicted as lines.
with the descriptions provided in Ref. [80].
In summary, the alignment of the VACF and MSD with their theoretical values underscores the effectiveness of our trajectory generation method.This method offers a solid framework for studies focusing on segmenting anomalous diffusion trajectories that exhibit defined long-time correlations.

FIG. 1 .
FIG. 1. [(a), (d)] Representative examples of trajectories with varying diffusion exponents (a) and different dynamics models (d).Different segments are marked in distinct colors.[(b), (e)] Time evolutions of trajectories in (a) and (d) for both x and y dimensions, respectively.Changepoints of diffusion states are indicated by dashed lines.[(c), (f)] Point-wise labels of trajectories in (a) and (d), respectively.

FIG. 2 .
FIG. 2. (a) Schematic diagram of the dilated causal 1D convolution with a kernel size of 3. The dilation factor of convolution is doubled layer by layer.(b) Detailed structure of the WADNet encoder.(c) The architecture of our U-AnDi model.Skip connections are highlighted by the dashed lines.

i
is the predicted point-wise label and X GT i refers to the ground truth of the ith trajectory.Both are one-hot encoded as matrices of dimensions [L, n c ] for the Dice coefficient calculation, where n c is the total number of diffusion-model types.The symbol ⊗ denotes the element-wise multiplication operator, and the small in the fraction represents the summation of all elements in the matrix.The value of the mean Dice coefficient ranges from 0 to 1, with a higher value indicating a better segmentation performance.

FIG. 4 .
FIG. 4. (a) MAE scores of U-AnDi on the validation set for various trajectory lengths from 50 to 900, with performances of other comparative models presented for reference.(b) 2D histogram of prediction α Pred versus ground truth α GT .(c) Distribution of MAE for α GT values ranging from 0.05 to 2. Inset: higher-resolution 2D histogram of α Pred versus α GT spanning from 0.8 to 1.2.(d) MAE variations corresponding to different δα for three scenarios: δαmin = 0.1, 0.5, and 0.8.(e) Model performance, as characterized by MAE, across various values of δαmin.Here, (b)-(e) display the results for trajectories of length 500.

FIG. 5 .
FIG. 5. (a) Representative example of the post-processing technique in subtask 1, which converts the continuous point-wise predictions into discrete segmented predictions.The dashlines denote the predicted locations of changepoints.(b) Distribution of δc as a percentage of TNC, spanning from -9 to 9. (c) Mean values of δc (δc) corresponding to various lengths of the front and rear segments adjacent to changepoints.(d) Distribution of TP, FP, and FN as a percentage of TNC, juxtaposed with results from WE and U-CNN.Here, (b)-(d) show the results for trajectories of length 500.(e) Plots of recall versus precision for U-AnDi, WE, and U-CNN across different trajectory lengths, with arrows indicating the direction of increasing trajectory length.(f) F1-score variations across trajectory lengths for the three models.
FIG. 6. Visualization of U-AnDi's performance on the segmentation task with different diffusion models.(a1-a4) Illustrations of four representative trajectories of length 500 with varying number of segments (M = 2, 3, 4, 5), where segments with different diffusion models are marked in distinct colors.(b1-b4) Comparisons of predictions (blue) and ground truths (orange) for each trajectory.The strong alignment between them leads to the near invisibility of lines representing ground truth values.(c1-c4) Heatmaps of point-wise probability distribution for each trajectory, with darker colors indicating higher probabilities.

FIG. 7 .
FIG. 7. (a) mDice scores on the validation set of U-AnDi and comparative models across trajectory lengths from 50 to 900.(b) Confusion matrix of the point-wise classification results of U-AnDi, where horizontal and vertical coordinates denote predicted and ground truth labels, respectively.(c) Distribution of δc spanning from -9 to 9 as a percentage of TNC, which is plotted on a logarithmic scale.(d) δc as a function of the lengths of the front and rear segments adjacent to changepoints.(e) Comparative distribution of TP, FP, and FN values for U-AnDi, WE, and U-CNN, expressed as a percentage of TNC.Here, (b)-(e) illustrate the findings for trajectories of length 500.(f) Recall against precision for U-AnDi, WE, and U-CNN across varying trajectory lengths, where arrows denote the direction of increasing trajectory length.(g) Dependence of F1-score on trajectory length for the three models.

FIG. 10 .
FIG. 10.(a) Representative example of a simulated composite trajectory of length 500, containing the four dynamic states in biological experiment scenarios: Brownian diffusion (BD), confined diffusion (CD), directed motion (DM), and immobile state (IS).(b) Comparative segmentation results of U-AnDi and DC-MSS on the composite trajectory in (a).(c) mDice score comparisons between U-AnDi and DC-MSS for trajectories of varying lengths.(d)-(f): Analysis of changepoint detection for U-AnDi and DC-MSS.(d) Distribution of TP, FP, and FN as a percentage of TNC where L = 500.(e) Recall versus precision for different trajectory lengths.(f) The variation of the F1-score with trajectory length.

FIG. 11 .
FIG. 11.Comparative evaluation of U-AnDi, WE, and U-CNN using MAE and F1-score across five distinct long-time correlations: 1. exponential decay; 2. multi-exponential decay; 3. exponentially damped cosine wave; 4. Mittag-Leffler decay; 5. power-law decay.The dashed lines represent the best score for each correlation type, and the numbers on the dots correspond to the aforementioned correlation types.

FIG. 12 .
FIG. 12. (a) Schematic diagram of the selected real-world anomalous diffusion system: Diffusion of transmembrane proteins on cell membrane surfaces.(b) Logarithmically plotted distribution of trajectory lengths in the experimental dataset, with the dashed line denoting the length at 100.Inset: Representative instances of selected short trajectories of CTRW and FBM with different lengths, with labels assigned by WADNet.(c) The quantity distribution of short CTRW and FBM trajectories spanning various lengths from 10 to 100.(d) Segmentation performance of U-AnDi at different noise standard deviations σn.(e) mDice scores of U-AnDi on validation sets under diverse L and M parameters.(f)-(g) Trajectories from the validation sets with parameters L = 100, M = 3 in (f) and L = 200, M = 5 in (g).(h) Comparisons between the predictions (blue) and ground truths (orange) for the trajectory in (f) (left) and the trajectory in (g) (right), underscoring a high-level consistency.

FIG. 13
FIG. 13. (a)-(c) Representative natural trajectories from the experimental dataset with lengths surpassing 100.Segments identified by U-AnDi are distinguished by distinct colors.(d)-(f) Probabilities of diffusion models provided by WADNet for segments in (a)-(c), respectively.

FIG. 14 .
FIG. 14. (a)-(b) Evolution of the loss function during training for subtask 1 (a) and subtask 2 (b).The thick line represents a smoothed version of the original train loss to provide better visual guidance.(c)-(d) Epoch dependence of the valid metric for subtask 1 (c) and 2 (d).The dashed line denotes the value of the best metric, and the yellow dot highlights the location of the best step.

FIG. 15 .
FIG. 15.(a) F1-score for changepoint detection as a function of ϵ.The horizontal dashed line signifies 98% of the maximum F1-score, and the vertical dashed lines indicate the candidate interval for ϵ, within which the F1-score retains at least 98% of its peak value.(b) MAE as a function of ϵ.The optimal ϵ is selected to minimize the MAE within the candidate interval (vertical dashed lines).The yellow dot highlights the chosen optimal ϵ value of 0.028 for this work.
(a).A notable distinction in this enhanced simulation is the allowance for variations of the diffusion exponent within a segment characterized by a single dynamic model, as depicted in Fig.16(b).To enrich the diversity of simulated trajectories, we expand the number of segments, M , from the initial range of 2 to 5 to an extended range of 3 to 8.Subsequently, we employ a multi-task learning approach to enable U-AnDi to effectively segment these trajectories.In detail, we utilize the intermediate output of U-AnDi, just prior to the final 1D CNN layer, which is denoted as p o and expressed as p o = BN [W u 5 (p 5 )].This intermediate output is directed into two separate 1D CNN head layers, W 1 f1 and W 1 f2 .The layer W 1 f1 , with an output p f1 = W 1 f1 * p o , is dedicated to a point-wise regression task, aiming to segment based on the diffusion exponent.In contrast, the other layer W 1 f2 focuses on a point-wise classification task, targeting the segmentation of the diffusion model and leading to an output p f2 = W 1 f2 * p o .After that, we compute the loss functions L 1 and L 2 for p f1 and p f2 using MSE and CE respectively.The final loss function L for this task is given as L = L 1 + L 2 .The data size and training method are consistent with those in subtask 2.

FIG. 16 .
FIG. 16.(a) Illustration of a composite trajectory of length 500 with different diffusion models.(b) Time evolution of trajectories in (a) for both x and y dimensions, showing variations of the diffusion exponent within a single model segment.(c)-(d) Segmentation results for the trajectory in (a) based on the diffusion exponent (c) and the diffusion model (d).(e) Distribution of TP, FP, and FN as a percentage of TNC for both segmentation tasks.(f) Comparative analysis regarding precision and recall of changepoint detection results with those from subtasks 1 and 2.

FIG. 18 .
FIG. 18.(a) Relationship between MSD/(2D) and time t for simulated trajectories associated with exp, multi-exp, and exp-cos correlations.(b) Log-log plot of MSDs of simulated trajectories governed by a M-L correlation for specific λ values of 0.6, 1.2, and 1.8 (represented by dots).The corresponding theoretical predictions, derived from Eq. (13), are also depicted as lines.

TABLE II .
Summary of parameters, labels, and corresponding equations to calculate labels for segmentation tasks associated with the four long-time correlations.

TABLE III .
The shapes of intermediate tensors for subtask 2 when length of input trajectory is 500.