Tracking the time evolution of soft matter systems via topological structural heterogeneity

Persistent homology is an effective topological data analysis tool to quantify the structural and morphological features of soft materials, but so far it has not been used to characterise the dynamical behaviour of complex soft matter systems. Here, we introduce structural heterogeneity, a topological characteristic for semi-ordered materials that captures their degree of organisation at a mesoscopic level and tracks their time-evolution, ultimately detecting the order-disorder transition at the microscopic scale. We show that structural heterogeneity tracks structural changes in a liquid crystal nanocomposite, reveals the effect of confined geometry on the nematic-isotropic and isotropic-nematic phase transitions, and uncovers physical differences between these two processes. The system used in this work is representative of a class of composite nanomaterials, partially ordered and with complex structural and physical behaviour, where their precise characterisation poses significant challenges. Our developed analytic framework can provide both a qualitative and quantitative characterisation of the dynamical behaviour of a wide range of semi-ordered soft matter systems. Topological data analysis is an important framework for quantifying the structural and morphological features of soft materials. Here, structural heterogeneity is introduced as a quantitative measure of non-equilibrium mesoscopic order in soft matter and used to track the time-evolution of liquid crystal phase transitions.

S oft matter is characterised by two features 1 , namely, the complexity of its components, which may be polymers, liquid crystals, colloidal grains, etc., and its flexibility: a room temperature transformation, e.g. a chemical reaction or mechanical stress, can induce a drastic change in the physical properties of the material. Even within the more restricted field of colloidal suspensions, a wide range of configurations is possible because colloidal particles can be viewed as large atoms with tailored size, shape and interactions 2 . For example, charged platelet suspensions, e.g. clays, have complex phase behaviours, including isotropic to nematic transitions, that are mediated by electrical interactions 3 . Numerical models of colloidal dispersions of two types of anisotropic particles, cubes and tetrahedron, in a polymer matrix, show that their phase space is controlled by the interactions between nanoparticles and polymers and by the volume fraction 4 . Often, parameter changes in colloidal systems may lead to robust phase separation which may be relevant for biological systems 5 and to the formation of liquid crystal phases 6 . Some of this behaviour has been interpreted in terms of energy landscapes 7 and, in particular, the possibility that they may be fractal 8,9 . A common feature to all these systems is that they require powerful analytic methods for their accurate and quantitative characterisation. Persistent homology is a relatively new data analysis tool that makes use of the underlying shape of the data to obtain meaningful information about the physical system or phenomenon analysed [10][11][12] . In the context of soft condensed materials, persistent homology has proved to be an effective and quantitative method to reveal structural and morphological features in a variety of systems.
The topological analysis of certain geometric constructions associated to granular materials using persistent homology has led to a classification of granular packing 13 , and to the identification of tetrahedral and octahedral cavities 14 during a crystallisation process. Similarly, for silica glasses and glassy polymers, persistent homology has been used to reveal the presence of hierarchical structures 15,16 . The findings obtained via persistent homology allowed to explain, among other things, the diffraction patterns observed in these types of materials. Despite in all these examples the starting point for the topological analysis is the location of the 2 and 3-dimensional positions of the centers of the granular particles, persistent homology can also be used in the analysis of more complex data, such as RGB images.
Several fields in medicine requiring analysis of cellular tissue have been much benefited by the introduction of persistent homology as a complementary tool for image analysis. In cancer research, persistent homology has been used in the quantitative evaluation of architectural features in prostate tumour 17 , hepatic tumour classification 18 , melanoma detection 19 and tumour segmentation 20 . Furthermore, there have been developed new persistent homology-based methods to provide insight on the morphological changes in distinct cellular tissues as a consequence of biological processes, such as hepatocellular ballooning, angiogenesis and stenosis, which might lead to an early detection of life threatening conditions [21][22][23][24] .
Other applications of persistent homology in the analysis of soft matter systems concern the analysis of the morphology of materials 13,14 , the atomic configurations of complex organic molecules and ion aggregation systems [25][26][27][28][29] . Even though most of the topological characterisation of soft materials using persistent homology has been done through the analysis of timeindependent data, for most applications of soft matter materials it is important to evaluate their time-evolution under the action of external stimuli. In this regard, there are a few works reporting the use of persistent homology to analyse the topological changes experienced by spin lattices during the course of a phase transition [30][31][32] . In none of these studies, however, persistent homology was used to analyse the dynamical behaviour of materials at the supramolecular level.
In this paper we introduce structural heterogeneity, a persistent homology-based characteristic for semi-organised soft matter systems. Structural heterogeneity allows one to measure the deviation of a soft matter system from being in a homogeneous or uniform state at a mesoscopic scale. In particular, we use structural heterogeneity to analyse the time-evolution of the structural organisation of a nematic liquid crystal doped with gold nanoparticles 33 in the course of a phase transition process. We use persistent homology to reveal the structural organisation at the mesoscopic scale, when the analysed system consists of a number of micron-size molecular ensembles with different order parameter. Furthermore, along with the structural heterogeneity, we construct a vector representation of the topological descriptors of the system to visualise them as points in a Euclidean space. This representation allows us to characterise algorithmically the dynamical behaviour of the system. A major outcome of this analysis is the development of a persistent homology-based framework to quantify the structural changes experienced by a soft matter system during a thermodynamical process. In the context of liquid crystals, the results obtained from our framework can potentially lead to more elaborate free energy landscapes for nanoparticle-loaded materials and to provide a different perspective on the Landau-de Gennes theory of phase transitions between nematic and isotropic phases. The importance of our pipeline is, however, far more general: it shows that persistent homology can be used as a powerful quantitative method to characterise the complex phase dynamics of non-homogeneous soft materials.

Results and discussion
Structural heterogeneity. The goal of this section is to define structural heterogeneity as a topological characteristic for soft matter systems. Structural heterogeneity is based on persistent homology, a topological tool used to extract meaningful information from the shape of the data. To help with the discussion, we start by describing the physical properties and the topological features of a soft matter system model, Fig. 1a. This figure shows a cross section of a confined liquid crystal system placed between two cross-polarisers; a grey-scale picture of the whole system is showed in Fig. 1b, where each pixel (square) represents a 2D projection of Fig. 1a. In this set-up light passes through the polariser at the top, interacts with an ensemble of liquid crystal molecules, to finally cross the polariser at the bottom. The higher the order of the molecular ensemble, the higher the intensity value of the pixel. A magenta arrow and a bar represent the polarisation and the intensity of the light, respectively. In the picture, there are pixels of high intensity values surrounded by loops of pixels of lower intensity, which are generated by highly ordered molecular ensembles surrounded by loops of highly disordered molecules. This picture might indicate that the system is in a state where two distinct mesophases coexist. From this analysis, one can see that the quantification of the topological features present in the images of a semi-organised system may be used to characterise it.
We now introduce persistent homology for image analysis. An expository introduction to persistent homology is found in Supplementary Note 1.1. Starting with a grey-scale picture X as in Fig. 1b, and a number i, with 0 ≤ i ≤ 255, we define a partial picture X ðiÞ as the union of pixels in X with light intensity not greater than i; changing the value of i creates a set of partial pictures parametrised by light intensity. The topological features of X , are analysed by keeping track of the appearance and disappearance of the topological features in the partial pictures X ðiÞ as i increases, Fig. 1c. There are two types of topological features to analyse: connected pieces, or 0-cycles, and loops of pixels, or 1-cycles. Each topological feature α observed in the partial pictures is represented by a point (b α , d α ) in the Euclidean plane, where b α is the value of i when α appears for the first time, and d α when it disappears. The values b α and d α are called the birth and the death of α, respectively. The collection of all the points in the plane with coordinates (b α , d α ) representing topological features observed in fX ðiÞg is called the persistence diagram of X , PDðX Þ, (see Fig. 1d). The most relevant physical information is contained in the 1-cycles. The value d α − b α is called the persistence of the topological feature α. The persistence of a 1-cycle measures the difference in order between the inside and the rim of the loop of pixels.
If X is a picture representing a physical state of a system, and DðX Þ is its corresponding persistence diagram, we define the structural heterogeneity of X , SHðX Þ, as the sum of the persistence values over all 1-cycles α in DðX Þ, Structural heterogeneity measures the deviation of a soft matter system from being in a homogeneous state. We used structural Fig. 1 Construction of topological descriptors. a Semi-ordered rod-shaped molecules inside a capillary placed between a pair of 90 ∘ -crossed polarisers at 45 ∘ to their axes. The bottom solid magenta arrow represents the final polarisation and amplitude of incident light having passed through the polarisers and the liquid crystal; the top solid magenta arrow represents the input polarisation and the intermediate stage is marked in the dashed magenta arrow. b A grey-scale picture X (top) representing a state where two mesophases coexist and the colour map bar (bottom) given by light intensity of the pixel; the orientation of the magenta bars is determined by the axis of the lower polariser, and the bar lengths correspond to the average intensity of transmitted light. c Some partial pictures X ðiÞ of X ; the 1-loops of the filtration are marked (purple, blue, green). d The persistence diagram of X , showing three 1-cycles with the colour corresponding to their loops of pixels associated to them (purple, blue and green). e-g Experimental grey-scale picture of the liquid crystal filled capillary at different stages in the evolution of the system (bottom) with their corresponding persistence diagrams (top); zoomed in-sets of the capillary within the yellow rectangles; 0-cycles are marked red in the persistence diagram, whereas 1-cycles are marked blue. heterogeneity to quantify the deviation of a soft matter system from being in either a totally nematic or a totally isotropic phase during a phase transition: the bigger the number of ordered molecular clusters surrounded by disordered molecular loops, the higher the value of structural heterogeneity.
The analysed systems consisted of capillaries of various inner diameters, filled with a nematic liquid crystal containing uniformly dispersed gold nanospheres 33 (see Supplementary Note 2 for further details on the experimental set-up). The capillaries were rapidly heated, letting the composite material reach the isotropic state, and then cooled back to the nematic phase. During the heating process, isotropic domains formed and grew in size, expelling nanoparticles into the adjacent nematic zones. This led to the self-assembly of nanospheres into a onedimensional periodic structure along the capillary. Then the isotropic domains merged, forming an isotropic state with nonhomogeneous particle density. During the isotropic-nematic process, nematic domains first nucleated in regions with high nanoparticle concentration, and then expanded to the rest of the capillary. All phase transitions were video-captured under imaging conditions where the nematic and isotropic domains appear bright and dark, respectively. Each video frame was digitised using integer grey-scale levels that implicitly represent the liquid crystal order, from 0 (black, isotropic phase) to 255 (white, nematic phase). We obtained a persistence diagram for each video frame of the analysed systems (see Supplementary Movies 1-3). For illustration, we present in Fig. 1e-g the persistence diagrams of the nematic-isotropic phase transition (top) at t = 5.0, t = 23.9 and t = 38.6 s, along with their corresponding video frames (bottom). 0-cycles are showed in red and 1-cycles are showed in blue.
We start the discussion of the structural heterogeneity of the liquid crystal nanocomposites by analysing the structural heterogeneity plot of the nematic-isotropic phase transition in a capillary of 6 μm, Fig. 2a. In the first seconds of the recording, that is, before the phase transition starts, the molecular organisation in the liquid crystal is uniform; during this period the structural heterogeneity looks roughly constant. The formation of isotropic regions, and, hence, the transition of the system from nematic to a nematic-isotropic phase (N -Iso), corresponds to an increase in structural heterogeneity up to a maximum; a short period of stabilisation in structural heterogeneity follows, where no new isotropic domains appear and the existing ones increase in size. The width of the N -Iso region (and of the structural heterogeneity plateau) increases with the diameter of the capillary, Fig. 2a, c. As the phase transition approaches its end, the nematic domains start collapsing until they vanish. The system then becomes homogeneous, reaching an isotropic state. We note that the structural heterogeneity values of the nematic states and those of the isotropic states are different, even though in both cases, the system looks homogeneous, Fig. 2c. The statistical analysis of the persistence of the 1-cycles of two persistence diagrams, one corresponding to the nematic phase and one corresponding to the isotropic phase (see Supplementary Note 3), shows that the difference observed in the structural heterogeneity values between these two frames is due to a larger number of 1-cycles having small persistence in the frames associated to the nematic phase. This is because in the nematic phase the molecules have orientational ordering, unlike the isotropic phase. In consequence the light transmittance of the capillary is more sensitive to slight fluctuation in the orientation of the molecules in the nematic than in the isotropic phase. This causes a variation in pixel intensities across the capillary and, therefore, a larger number of 1-cycles with short persistence compared to the observed in the isotropic state.
The observed dependence of the phase transition time on the capillary diameter (see Fig. 2d-f) can be explained by a phenomenon related to phase separation: the growing area of the isotropic phase is the source of nanoparticle movement at the interface between the nematic and the isotropic phases, locally increasing their concentration in the nematic phase. This movement slows down the rate of the phase transition considerably. Therefore, in Fig. 2c we can see a clear flat area between the beginning and the end of the phase transition. For smaller diameters, this process is shorter because the nanoparticles are moved over shorter distances (the period of the periodic structure depends on the diameter of the capillary 33 ).
The differences between the nematic-isotropic and isotropicnematic processes are evidenced by the comparison between Fig. 2a, b. In the nematic-isotropic transition we can observe one local maximum, whereas in the isotropic-nematic process we can observe two well-defined local maxima at t = 2.9 s and t = 14.3 s. We analysed in more detail the persistence diagrams in a small neighbourhood near the observed maxima in the cooling process. Figure 3a, b show the distribution of the deaths and births of the 1-cycles. The distributions of the births and deaths of the most persistent 1-cycles in the persistence diagrams near the first maximum show a Gaussian-like behaviour, as opposed to the sharp distribution of deaths observed at the second maximum. This difference suggests that the nanocomposite inside the capillary is less structured at the first maximum than at the second one, consistent with a random nucleation process of the nematic phase. To confirm whether this is the case we have also studied the life expectancy, i.e. the persistence, of the 1-cycles. Figure 3c, d show the distribution of the persistences of 1-cycles, using linear-log plots, for the isotropic-nematic phase transition, along with the corresponding distributions of pixel intensities. The time intervals considered are 3 ± 0.5 s and 14 ± 0.5 s. The distribution of pixel intensities shows that in the interval 3 ± 0.5 s, intensity values are in general lower than the ones observed in the interval 14 ± 0.5 s, once again compatibly with the presence of random nucleation regions at the first maximum and a wide area phase transition at the second. The distributions in Fig. 3c, d are dominated by the many noiseinduced short-lived cycles. However, the dominant contribution to the dynamics and the structural heterogeneity is from longer lived cycles. The distributions of death and births and pixel intensity observed at the first maximum might suggest that the increment of light intensity across the capillary is more similar to a random process. A sharp distribution, by the contrary, might indicate that the phase transition occurring in the second maximum the phase transition occurs uniformly across the capillary. Figure 3e, f show an estimated contribution of all 1-cycles of given persistence to the structural heterogeneity during the isotropic-nematic phase transition. These plots were obtained from the plots in Fig. 3c, d by multiplying each bin height by typical persistence of 1-cycles in that bin. Figure 3f shows that the structural heterogeneity value in the second maximum has a strong contribution coming from 1-cycles with persistence of 5, approximately. In contrast, Fig. 3e shows that in the first maximum there are many fewer 1-cycles with persistence ≥5, and the persistence of 1-cycles is more sparse than in the second maximum. These results are a further indication that the first maximum corresponds to the appearance and disappearance of relatively short-lived 1 cycles induced by random nucleation of the nematic phase. In summary, our analysis of the persistence diagrams suggests that structural heterogeneity detects a hysteresis behaviour, in agreement with experimental observations reported in 33 . In order to continue our investigation on the physical interpretation of the observed maxima in the structural heterogeneity plots, and on the differences between the nematic-isotropic and isotropic-nematic processes, we introduce the concept of topological pathway.
Topological pathways of dynamical processes. To start, we use the bottleneck distance to quantify the differences between persistence diagrams. This is defined as follows. For persistence diagrams D 1 and D 2 , which are subsets of the plane R 2 , we consider a bijective matching ϕ of points of D 1 to points of D 2 . We also allow matching any of the points of D 1 or D 2 to its nearest point on the x = y line; a matching like that always exists, even if D 1 and D 2 have different numbers of points. The cost of a matching ϕ of diagrams D 1 and D 2 , denoted Cost(ϕ), is the largest distance by which a point in D 1 has to be moved to be matched with a point in D 2 . Then the bottleneck distance is If two persistence diagrams are close in this distance, then so are the topological features of the corresponding video frames 34 . Since the topological features of a video frame depend on the physical state of the system, the smaller the bottleneck distance between two persistence diagrams is, the more similar the states of the system associated to them are.
For each pair of persistence diagrams we computed their bottleneck distance. Figure 4a, b show the distance matrices obtained, where blue corresponds to pairs of persistence diagrams that are practically identical, and red the most different. The distance matrix of the nematic-isotropic transition (see Fig. 4a) shows that in the first 15 s of the recording, approximately, the states of the system are almost identical. Distances between persistence diagrams of video frames at t > 15 s and at t < 15 s are large. The yellow-cyan area in the center of Fig. 4a corresponds to a period in which the distances between persistence diagrams start decreasing. From the analysis of the video frames and the structural heterogeneity values, we conclude that, in this short time period, nematic and isotropic phases coexist, and the number of isotropic remains the same. Moreover, the observed period increases with the capillary diameter (see Supplementary Note 4). The distance matrices of the nematic-isotropic and the isotropicnematic phase transitions look substantially different, confirming the differences highlighted by structural heterogeneity.
The bottleneck distance allows us to regard the set of persistence diagrams as a non-Euclidean metric space. In particular, the set of persistence diagrams of a dynamical process can be regarded as a metric space in its own right equipped with this metric. The metric space defined by the persistence diagrams corresponding to phase transitions frame will be called the non-Euclidean topological pathway. We used the classical multidimensional scaling to embed the non-Euclidean topological pathway into an Euclidean space (see Supplementary Note 5), that is, classical multidimensional scaling allowed us to associate Euclidean coordinates to each persistence diagram 35 . This is a useful method to analyse geometric and dynamical features that might not be easily detectable from distance matrices such as those matrices showed in Fig. 4a, b. The validity of classical multidimensional scaling for the analysis of the distance matrices obtained from the video frames was confirmed by noting that Euclidean distances between persistence diagrams assigned by the classical multidimensional scaling are minimally distorted with respect to the corresponding bottleneck distances (see Supplementary Note 5.1). We call the persistence diagram orbit under the classical multidimensional scaling the Euclidean topological pathway. In Fig. 4c we show 3D projections of the nematic-isotropic (red) and isotropic-nematic (blue) non-Euclidean topological pathways and topological pathways. Here, the topological pathways were projected onto the three-principal coordinates, which correspond to those coordinates of the classical multidimensional scaling with the largest positive eigenvalues. The first thing to notice in these graphs is that the red topological pathway is bigger than the blue topological pathway. This is explained as follows: the nanoparticles travel longer distances when the systems is heated than when it is cooled 33 . Since the dynamics of the whole system depends on the dynamics of the nanoparticles, the longer the distances travelled by these, the bigger the observed distances between persistence diagrams.
The topological pathway of the nematic-isotropic process shows one loop-like trajectory (see Fig. 4d), whereas the isotropicnematic process shows two (see Fig. 4e). A loop-like shape indicates that at the beginning of the phase transition, the topology of the system starts changing, and moves away from its starting point. Once the structural heterogeneity reaches its maximum, the system moves back close to its starting point. Moreover we notice that the number of loops in the topological pathways account for the number of thick curves coming out from the diagonal in Fig. 4a, b and the number of local maxima in Fig. 2a, b. Thus the number of curves account for the number of loops in the topological pathways.
All these results lead to the conclusion that the isotropicnematic phase transition should be considered as a two-stage process. On cooling the sample, the phase transition to the nematic phase occurs first in the nanoparticle-rich regions (see Fig. 5b), which generates light scattering across the capillary. The phase transition in these regions ends at the beginning of the phase transition in the small nanoparticle-poor regions (see Fig. 5c). The second stage of the transition process is smoother (see Fig. 5d, e). It may be influenced by dispersed nanoparticles, which initiate the phase transition process (see Fig. 5c).
Finally, it is worth mentioning that the bottleneck distance is just one distance function of a family called the (p, q)-Wasserstein distance functions. One can equip the set of persistence diagrams with any of these distance functions to regard this set as a metric space. We computed the (1,1)-Wasserstein distance matrix for the heating process in the capillary of 6 μm, and carried out a classical multidimensional scaling analysis of the resulting distance matrix. The shape of the topological pathway obtained from the (1, 1)-Wasserstein distance is similar to that obtained from the bottleneck distance, namely, one loop-like curve (see Supplementary Note 6). One advantage of bottleneck distance is that, Fig. 4 Bottleneck distance matrices and 3D representation of the topological pathways of the 6 μm capillary. The bottleneck distance matrices associated to (a) the nematic-isotropic and (b) the isotropic-nematic phase transitions; the frame rate is 10 fps. c 3D-projections of the heating (red) and cooling (blue) Euclidean topological pathways. The three-principal axes correspond to the three coordinates of the Euclidean embedding with the largest positive eigenvalues. d Nematic-isotropic and (e) isotropic-nematic Euclidean topological pathways. In d and e colour codes time from beginning (blue) to the end (red). computationally, it is less expensive than other (p, q)-Wasserstein distances.
In the next section we present an algorithmic quantitative analysis that is particularly powerful when visual inspection is not practical. For that purpose we measure the velocity and curvature of the topological pathways.
Algorithmic analysis of the system dynamics. The pathway velocity v t measures the rate of change of the system topology: where x t s is the first coordinate of the topological pathway at time t s. The pathway curvature k t measures how much the topological pathway is bending at a given time t s. It is defined as the inverse of the radius of the circle interpolating x (t−2)s , x t s and x (t+2)s , where x t s are the Euclidean coordinates of the topological pathway at time t s. We express this radius as a function of the pairwise distances between x (t−2)s , x t s and x (t+2)s ; therefore, we may more generally compute pathway curvature given any distance matrix (see Supplementary Note 7).
We use these two numerical descriptors to identify algorithmically the physical states that are relevant in the dynamical behaviour of the soft nanocomposite.
The curvature of the nematic-isotropic and isotropic-nematic topological pathways and non-Euclidean topological pathways are shown in Fig. 6a, d. The velocity of the nematic-isotropic and isotropic-nematic topological pathways are shown in Fig. 6b, e. These figures should be compared with the structural heterogeneity and distance matrix plots in Fig. 2a, b and Fig. 4a, b, respectively. We first consider the heating process. The formation of isotropic bubbles leads to a rapid increase of v t , Fig. 6b. As new isotropic bubbles form, the velocity increases, reaching a maximum; during the N-Iso phase, when only the size but not the number of the domains changes, v t decreases to zero. Towards the end of the phase transition, the number of domains decreases and v t grows in absolute value. The curvature plots of the topological pathway and the non-Euclidean topological pathway (see Fig. 6a) supports this observation, having their maximum value in the state with the highest structural heterogeneity.
The isotropic-nematic process shows a different behaviour, Fig. 6d-f. There are two time periods when v t becomes negative in agreement with the two loop-like trajectories in Fig. 4e. Furthermore, v t is zero at three different isolated points that are also critical points of the structural heterogeneity plot. The local maxima in the curvature plots, Fig. 6d, correspond to nematic domain formation around the nanospheres in the first stage of the phase transition, Fig. 6f(1), a transition state with a minimum in the structural heterogeneity, Fig. 6f(2), and a state in the second stage of the phase transition with maximum structural heterogeneity, Fig. 6f(3). It is important to highlight the good agreement between the maxima observed in the curvature plots obtained from the bottleneck distance matrices and from classical multidimensional scaling. This shows that, under the validity conditions of the classical multidimensional scaling, the topological pathway can provide a good approximation of the dynamical change of the system topology.
To conclude this analysis, we point out that topological pathways might probe the energy landscape on which the dynamics of the phase transitions under nonequilibrium conditions takes place: zero velocity points and associated topological configurations can be considered as metastable states of the topological pathways, reachable through connecting saddle states with activation barriers. Although the nematic-isotropic phase transition is considered in a number of theories 36 , to the best of our knowledge, the theories of mesoscopic nonequilibrium thermodynamics 37 have not yet been applied to its study. However, an evolution model based on the Fig. 6 The top and bottom rows represent the nematic-isotropic and isotropic-nematic transitions, respectively, for the 6 μm capillary. a, d The curvature of the topological pathways, while (b, e) are their velocities plots. The Euclidean topological pathways and non-Euclidean topological pathways are represented by the red circles and the black crosses respectively. c, f Zoomed-in images of the capillaries with colormap representing the light intensity, increasing from blue (total darkness) to red (maximum brightness). The maximum of curvature in (a), indicated by (1), corresponds to the transition point when the structural heterogeneity reaches its maximum and (c) the nematic domains begin to collapse. The three curvature maxima in (d) correspond to the same-numbered pictures in (f): (1) is the early start of nematic domain formation; (2) is their further development; (3) is the early start of the ordered nematic phase. These three stages of the dynamics are also illustrated schematically in Fig. 5b-d. consideration of the multi-dimensional potential energy landscape has been recently demonstrated to interpret complex phenomenology in disordered glasses 38 , while the sublevelset persistent homology has been used to understand the topology of the potential energy landscapes of n-alkanes 39 . The analysis presented in this paper can potentially be used to provide the necessary experimental details for the development of a mesoscopic model of nonequilibrium phase transitions in nematic liquid crystal-based systems, which could be based on the Landau-de Gennes theory 40 combined with multiscale nonequilibrium thermodynamics 41,42 .

Conclusions
Structural heterogeneity is a robust topological characteristic that can qualitatively and quantitatively detect subtle variations in the physical state of a soft matter system as it undergoes a dynamical process. In the particular case of the system analysed in this work, structural heterogeneity detects a hysteresis behaviour in its phase transitions and reveals a two-stage process for the isotropicnematic phase transition. Additional tools, such as the topological pathway, opens up the possibility of an algorithmic study of the system dynamics: the critical points of the pathway, which can be easily detected numerically either in terms of velocity or curvature, correspond to moments of significant topological and, hence, physical upheaval for the system.
An important outcome of this study is a framework for the quantitative analysis of complex soft matter systems. As shown in Fig. 7, the framework starts from experimental images of the timeevolving system, followed by the acquisition of their persistence diagrams. With this new data one can compute the structural heterogeneity and the topological pathway, from which we can analyse physical features of the system. This procedure can be automated and applied to large datasets for which visual analysis may not be practical, as well as to systems where the experimental information is not limited to images and may also include biological, chemical and structural information 29,43,44 . It is straightforward to implement our developed analytical framework in the study of other 1D and 2D soft matter systems. Our methods can also be extended to 3D systems, however, this would require complex data acquisition methods and significant computational resources.

Methods
Image analysis and data processing. We analysed video data of nematicisotropic and isotropic-nematic phase transitions for capillaries of different diameters filled with liquid crystal nanocomposites reported earlier in 33 (see Supplementary Note 2 for experimental details). The video frames were transformed to grey scale in Matlab 45 using the function rgb2gray. We used the open source GUDHI 46 to compute the normalised persistent diagrams (see Supplementary Note 1.2 for details in the normalisation method) of the video frames, and all pairwise bottleneck distances in dimension 1 (for details on the computations see 47,48 ).
The input data in the computations of the bottleneck distance matrix was the corresponding to the capillaries of 6 and 20 μm for both the nematic-isotropic and the isotropic-nematic phase transitions. All persistence diagrams were normalised in the same way for each video according to a scaling factor (see Supplementary Note 1.2 for details on the normalisation procedure). In order to optimise the computation time of distance matrices, a multithreaded algorithm was programmed in Python. The code was run over 8 cores on a 2.4 GHz Intel Core i9 processor. Six distance matrices were obtained. The first one (DB6) was associated to the data corresponding to both processes heating and cooling in the capillary of 6 μm. The second distance matrix corresponded to the data associated to the heating process in the capillary of 20 μm (DB20h). From the matrix D6, we obtained two additional matrices by restricting to blocks within the matrix. Each block contained only the data associated to either the heating (DB6h) or the cooling (DB6c) processes. We also obtained the Wasserstein distance matrices of the heating (DW6h) and cooling (DW6h) processes in the capillary of 6 μm.
The topological pathways corresponding to the bottleneck distance matrices were obtained via the Matlab function cmdscale. The sizes of the distance matrices and their corresponding embedding dimensions are reported in Supplementary  Table 1. For visualisation we plotted the first three-principal components of the Euclidean embedding, that is, the coordinates of the topological pathways with the largest positive eigenvalues. The curvature values of both the the topological pathways and non-Euclidean topological pathways were computed using a code implemented in Matlab (see Supplementary Note 7 for details on the curvature method). The computation time to obtain the structural heterogeneity values and the bottleneck distance matrix from a video containing 400 frames was~3.5 h. In particular, the computation time of the bottleneck distance matrix from the persistent homology data was~2 h; the computation time to obtain the Wasserstein distance matrix for the same video was~7.5 h.

Data availability
The datasets generated and analysed during the current study are available from the corresponding author on reasonable request. Fig. 7 Framework for the topological characterisation of soft matter systems. The evolution of the physical system is captured using time-dependent persistent homology, which is summarised through structural heterogeneity and the topological pathway.