Actualizar MSI_julia-python_mapping.md
This commit is contained in:
@@ -72,9 +72,9 @@ To enable training on consumer-grade hardware (NVIDIA RTX 3050 Mobile, ~4 GB VRA
|
|||||||
|
|
||||||
4. **Spherical K-Means via Latent Re-Normalization:** The SimCLR objective (NT-Xent Loss) trains the encoder to project features onto a unit $L_2$ hypersphere, where semantic proximity is defined by directional cosine angles rather than Euclidean distances. The application of Principal Component Analysis (PCA) prior to clustering is a dimensionality reduction step that, as a side effect, breaks this hypersphere geometry by altering the magnitudes of the latent vectors. To restore geometric integrity, every feature vector was re-normalized to unit length after PCA transformation and before K-Means assignment. This converts standard Euclidean K-Means into a functional **Spherical K-Means** (Hornik et al., 2012), ensuring that cluster centroids are determined by cosine similarity rather than arbitrary vector magnitudes—a critical requirement for correctly grouping ions with identical spatial silhouettes but different absolute intensities.
|
4. **Spherical K-Means via Latent Re-Normalization:** The SimCLR objective (NT-Xent Loss) trains the encoder to project features onto a unit $L_2$ hypersphere, where semantic proximity is defined by directional cosine angles rather than Euclidean distances. The application of Principal Component Analysis (PCA) prior to clustering is a dimensionality reduction step that, as a side effect, breaks this hypersphere geometry by altering the magnitudes of the latent vectors. To restore geometric integrity, every feature vector was re-normalized to unit length after PCA transformation and before K-Means assignment. This converts standard Euclidean K-Means into a functional **Spherical K-Means** (Hornik et al., 2012), ensuring that cluster centroids are determined by cosine similarity rather than arbitrary vector magnitudes—a critical requirement for correctly grouping ions with identical spatial silhouettes but different absolute intensities.
|
||||||
|
|
||||||
5. **Clustering and Optimization:** To determine the optimal number of clusters ($k$), we performed a multi-metric systematic sweep from $k = 2$ to $k = 20$ (Figure 1A). While global mathematical optima were observed at $k = 2$ and $k = 3$—corresponding to a coarse differentiation between the leaf tissue and the background—these configurations failed to resolve the specialized anatomical compartments of the leaf. We identified $k = 10$ as the functional optimum, supported by a Silhouette Score of 0.6894 (Figure 1B), a Davies-Bouldin Index of 0.6243 (Figure 1C), and a Calinski-Harabasz Index of 2054.20 (Figure 1D). This value represents a stable convergence point where the latent space successfully deconvolutes the hierarchical vascular architecture (midrib and secondary veins) and localized metabolic sequestration sites without incurring over-segmentation. Consequently, this choice prioritizes anatomical fidelity over mathematical parsimony, ensuring that the resulting metabolic map accurately reflects the complex tissue compartmentalization of *D. innoxia*.
|
5. **Clustering and Optimization:** To determine the optimal number of clusters ($k$), we performed a multi-metric systematic sweep from $k = 2$ to $k = 20$ (Figure 1A). While global mathematical optima were observed at $k = 2$ and $k = 3$ —corresponding to a coarse differentiation between the leaf tissue and the background— these configurations failed to resolve the specialized anatomical compartments of the leaf. We identified $k = 10$ as the functional optimum, supported by a Silhouette Score of 0.6894 (Figure 1B), a Davies-Bouldin Index of 0.6243 (Figure 1C), and a Calinski-Harabasz Index of 2054.20 (Figure 1D). This value represents a stable convergence point where the latent space successfully deconvolutes the hierarchical vascular architecture (midrib and secondary veins) and localized metabolic sequestration sites without incurring over-segmentation. Consequently, this choice prioritizes anatomical fidelity over mathematical parsimony, ensuring that the resulting metabolic map accurately reflects the complex tissue compartmentalization of *D. innoxia*.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -87,17 +87,17 @@ We conducted direct surface analysis of *D. innoxia* leaves using an LD-LTP-MS s
|
|||||||
### 3.2 Latent Space Geometry and Chemical Validation
|
### 3.2 Latent Space Geometry and Chemical Validation
|
||||||
The high-dimensional embeddings generated by the custom GroupNorm backbone were projected into a 2-D manifold using t-SNE (Figure 3) (Van der Maaten & Hinton, 2008). The resulting latent space exhibits a highly structured geometry, where ions are grouped not by their absolute intensity, but by their shared spatial topographies. A cornerstone of the validation for this self-supervised approach is the emergence of **Isotopic Coherence** within the latent manifold (Table 2). In MSI, a molecular species and its naturally occurring isotopes (e.g., $[M+H]^+$ and $[M+H+1]^+$) are fundamentally tied by an identical spatial distribution, providing a form of natural "ground truth" that requires no manual annotation.
|
The high-dimensional embeddings generated by the custom GroupNorm backbone were projected into a 2-D manifold using t-SNE (Figure 3) (Van der Maaten & Hinton, 2008). The resulting latent space exhibits a highly structured geometry, where ions are grouped not by their absolute intensity, but by their shared spatial topographies. A cornerstone of the validation for this self-supervised approach is the emergence of **Isotopic Coherence** within the latent manifold (Table 2). In MSI, a molecular species and its naturally occurring isotopes (e.g., $[M+H]^+$ and $[M+H+1]^+$) are fundamentally tied by an identical spatial distribution, providing a form of natural "ground truth" that requires no manual annotation.
|
||||||
|
|
||||||
To quantitatively validate this, we calculated the Cosine Similarity between the normalized feature vectors of known isotopic pairs. For example, Atropine ($m/z$ 290.02) and its $+1$ isotope ($m/z$ 291.00) yielded a Cosine Similarity of **$0.9898$**. A global statistical analysis across 513 discovered isotopic pairs yielded a mean latent distance of $0.3156$, compared to $0.7076$ for random ion pairs, achieving profound statistical significance (Welch's $t$-test, $p = 6.7932 \times 10^{-74}$). Although the SimCLR framework is entirely agnostic to the mass-to-charge (*m/z*) values or the chemical identity of the inputs, the encoder consistently projected isotopic pairs into tightly bound coordinates.
|
To quantitatively validate this, we calculated the Cosine Similarity between the normalized feature vectors of known isotopic pairs. For example, Atropine (*m/z* 290.02) and its $+1$ isotope (*m/z* 291.00) yielded a Cosine Similarity of **$0.9898$**. A global statistical analysis across 513 discovered isotopic pairs yielded a mean latent distance of $0.3156$, compared to $0.7076$ for random ion pairs, achieving profound statistical significance (Welch's $t$-test, $p = 6.7932 \times 10^{-74}$). Although the SimCLR framework is entirely agnostic to the mass-to-charge (*m/z*) values or the chemical identity of the inputs, the encoder consistently projected isotopic pairs into tightly bound coordinates.
|
||||||
|
|
||||||
**Disproving Background Mask Exploitation:** A common concern in applying deep learning to zero-padded imaging data is that the network may exploit the outer tissue boundary—an artifact shared identically by every single ion image—as a "shortcut" feature, rather than learning true internal biology (Purushwalkam & Gupta, 2020). Our data provides an elegant empirical refutation of this hypothesis. Atropine ($m/z$ 290.02) and its $+1$ isotope ($m/z$ 291.00) share a perfectly identical outer mask boundary but have fundamentally different absolute signal intensities due to natural isotopic abundance ratios. If the encoder were exploiting the mask, these two ions would appear identical regardless, yielding a trivially high similarity—providing no discriminative power. Instead, the NT-Xent loss function explicitly penalizes the encoder for relying on zero-variance features shared across all images in the negative pair denominator (Chen et al., 2020). Any feature constant across all ion images—including the outer mask—provides zero contrastive gradient, and is mathematically discarded in favor of internal morphological variations. The observed similarity of $0.9898$ therefore constitutes proof that the network has converged on the true shared spatial silhouette of the ion inside the tissue, not the common boundary around it.
|
**Disproving Background Mask Exploitation:** A common concern in applying deep learning to zero-padded imaging data is that the network may exploit the outer tissue boundary —an artifact shared identically by every single ion image— as a "shortcut" feature, rather than learning true internal biology (Purushwalkam & Gupta, 2020). Our data provides an elegant empirical refutation of this hypothesis. Atropine (*m/z* 290.02) and its $+1$ isotope (*m/z* 291.00) share a perfectly identical outer mask boundary but have fundamentally different absolute signal intensities due to natural isotopic abundance ratios. If the encoder were exploiting the mask, these two ions would appear identical regardless, yielding a trivially high similarity—providing no discriminative power. Instead, the NT-Xent loss function explicitly penalizes the encoder for relying on zero-variance features shared across all images in the negative pair denominator (Chen et al., 2020). Any feature constant across all ion images —including the outer mask— provides zero contrastive gradient, and is mathematically discarded in favor of internal morphological variations. The observed similarity of $0.9898$ therefore constitutes proof that the network has converged on the true shared spatial silhouette of the ion inside the tissue, not the common boundary around it.
|
||||||
|
|
||||||
Furthermore, this structural mapping revealed the phenomenon of **Inverse Mask Correlation** (Negative Space Co-Exclusion). The network successfully grouped ions that concentrate directly within the vascular bundle (positive distributions, e.g., Scopolamine $m/z$ 304.00, achieving a similarity of $0.8796$ with Atropine) with ions that are biologically excluded from the vein (negative distributions, appearing as dark shadows). Because the encoder projects all spatial maps onto an $L_2$ unit hypersphere, it recognizes that the sharp geometric boundary of a bright vein and the boundary of its complementary dark shadow are topologically equivalent structures. Such coherence confirms that the learned representations are anchored in global biological reality rather than technical artifacts.
|
Furthermore, this structural mapping revealed the phenomenon of **Inverse Mask Correlation** (Negative Space Co-Exclusion). The network successfully grouped ions that concentrate directly within the vascular bundle (positive distributions, e.g., Scopolamine *m/z* 304.00, achieving a similarity of $0.8796$ with Atropine) with ions that are biologically excluded from the vein (negative distributions, appearing as dark shadows). Because the encoder projects all spatial maps onto an $L_2$ unit hypersphere, it recognizes that the sharp geometric boundary of a bright vein and the boundary of its complementary dark shadow are topologically equivalent structures. Such coherence confirms that the learned representations are anchored in global biological reality rather than technical artifacts.
|
||||||
|
|
||||||
**Interpreting the Continuous Latent Manifold:** Reviewers from a computer vision background may expect an optimal unsupervised result to yield discrete, well-separated "blobs" in the t-SNE projection. The continuous, connected geometry observed in our manifold—resembling a smooth curve or "S-shape"—is not a sign of clustering failure; it is, in fact, the mathematically correct and expected projection of a continuous biological gradient (Diaconis et al., 2008). A *D. innoxia* leaf is not a collection of discrete, isolated tissue types; it is an anatomical continuum transitioning from the dense, alkaloid-rich midrib through the paravascular tissue into the diffuse parenchyma of the lamina. Because our encoder successfully learned the underlying structural morphology rather than arbitrary cluster membership, the t-SNE algorithm faithfully projects this continuous biological spectrum into a continuous geometric trajectory (Moon et al., 2019). The application of K-Means clustering ($k=10$) onto this manifold is then interpreted as the discretization of this gradient into biologically meaningful bands, not as the discovery of independent, non-overlapping chemical compartments.
|
**Interpreting the Continuous Latent Manifold:** Reviewers from a computer vision background may expect an optimal unsupervised result to yield discrete, well-separated "blobs" in the t-SNE projection. The continuous, connected geometry observed in our manifold—resembling a smooth curve or "S-shape"—is not a sign of clustering failure; it is, in fact, the mathematically correct and expected projection of a continuous biological gradient (Diaconis et al., 2008). A *D. innoxia* leaf is not a collection of discrete, isolated tissue types; it is an anatomical continuum transitioning from the dense, alkaloid-rich midrib through the paravascular tissue into the diffuse parenchyma of the lamina. Because our encoder successfully learned the underlying structural morphology rather than arbitrary cluster membership, the t-SNE algorithm faithfully projects this continuous biological spectrum into a continuous geometric trajectory (Moon et al., 2019). The application of K-Means clustering ($k=10$) onto this manifold is then interpreted as the discretization of this gradient into biologically meaningful bands, not as the discovery of independent, non-overlapping chemical compartments.
|
||||||
|
|
||||||
**Table 2. Representative metabolites identified in *D. innoxia* and their latent space assignment.**
|
**Table 2. Representative metabolites identified in *D. innoxia* and their latent space assignment.**
|
||||||
|
|
||||||
| $m/z$ Obs. | Identification | Formula $[M+H]^+$ | Cluster | Anatomical Significance |
|
| *m/z* Obs. | Identification | Formula $[M+H]^+$ | Cluster | Anatomical Significance |
|
||||||
| :--- | :--- | :--- | :--- | :--- |
|
| :--- | :--- | :--- | :--- | :--- |
|
||||||
| 290.02 | Atropine / Hyoscyamine | $C_{17}H_{24}NO_3$ | **9** | Ubiquitous parenchymal distribution with moderate terminal accumulation |
|
| 290.02 | Atropine / Hyoscyamine | $C_{17}H_{24}NO_3$ | **9** | Ubiquitous parenchymal distribution with moderate terminal accumulation |
|
||||||
| 304.00 | Scopolamine | $C_{17}H_{22}NO_4$ | **9** | Widespread distribution across the leaf with apical enrichment |
|
| 304.00 | Scopolamine | $C_{17}H_{22}NO_4$ | **9** | Widespread distribution across the leaf with apical enrichment |
|
||||||
@@ -111,7 +111,7 @@ Furthermore, this structural mapping revealed the phenomenon of **Inverse Mask C
|
|||||||
### 3.3 Chemical-Anatomical Segmentation in *D. innoxia*
|
### 3.3 Chemical-Anatomical Segmentation in *D. innoxia*
|
||||||
The unsupervised decomposition of the latent space yielded ten distinct molecular domains (Clusters 0–9), each representing a reproducible and spatially resolved chemical pattern across the *D. innoxia* leaf. These clusters capture the heterogeneity of ion distributions and reveal a structured organization of metabolites at the tissue level.
|
The unsupervised decomposition of the latent space yielded ten distinct molecular domains (Clusters 0–9), each representing a reproducible and spatially resolved chemical pattern across the *D. innoxia* leaf. These clusters capture the heterogeneity of ion distributions and reveal a structured organization of metabolites at the tissue level.
|
||||||
|
|
||||||
Rather than reflecting random variation, the observed spatial arrangements define consistent chemical domains characterized by differences in ion intensity, co-localization, and spatial continuity. In particular, the distribution of key ions such as atropine ($m/z \approx 290.02$) and scopolamine ($m/z \approx 304.0$) highlights the presence of chemically distinct regions associated with specific anatomical features, including the midrib, lamina, and apical tip (Figure 4, Table 3).
|
Rather than reflecting random variation, the observed spatial arrangements define consistent chemical domains characterized by differences in ion intensity, co-localization, and spatial continuity. In particular, the distribution of key ions such as atropine ($*m/z* \approx 290.02$) and scopolamine ($*m/z* \approx 304.0$) highlights the presence of chemically distinct regions associated with specific anatomical features, including the midrib, lamina, and apical tip (Figure 4, Table 3).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ Two clusters are defined by a primary spatial association with the apical region
|
|||||||
#### 3.3.3 Ubiquitous and Parenchymal Distributions (Clusters 2, 7, 9)
|
#### 3.3.3 Ubiquitous and Parenchymal Distributions (Clusters 2, 7, 9)
|
||||||
Three clusters are characterized by broad spatial distributions that span the entire leaf surface, reflecting compounds with constitutive or widespread parenchymal presence. **Cluster 2** exhibits the most uniform pattern, with detectable signal across the entire leaf surface without pronounced enrichment in any specific anatomical structure. This ubiquitous distribution is characteristic of primary metabolites or constitutive compounds involved in basal cellular processes. **Cluster 7** is dominated by large, well-defined islands distributed across the lamina with a minor presence at the apical tip. The island-like pattern within a broad distribution suggests localized zones of metabolic specialization or differential accumulation within a generally ubiquitous compound class. **Cluster 9** displays a heterogeneous pattern combining both large and small islands across the leaf surface with moderate enrichment at the tip, representing the most complex distribution among the ubiquitous group.
|
Three clusters are characterized by broad spatial distributions that span the entire leaf surface, reflecting compounds with constitutive or widespread parenchymal presence. **Cluster 2** exhibits the most uniform pattern, with detectable signal across the entire leaf surface without pronounced enrichment in any specific anatomical structure. This ubiquitous distribution is characteristic of primary metabolites or constitutive compounds involved in basal cellular processes. **Cluster 7** is dominated by large, well-defined islands distributed across the lamina with a minor presence at the apical tip. The island-like pattern within a broad distribution suggests localized zones of metabolic specialization or differential accumulation within a generally ubiquitous compound class. **Cluster 9** displays a heterogeneous pattern combining both large and small islands across the leaf surface with moderate enrichment at the tip, representing the most complex distribution among the ubiquitous group.
|
||||||
|
|
||||||
The spatial distribution of atropine ($m/z$ 290.02) and scopolamine ($m/z$ 304.0) within Cluster 9 provides a nuanced view of tropane alkaloid allocation in *D. innoxia*. Rather than being exclusively confined to the midrib, these compounds exhibit a broad distribution across the leaf in the form of large and small islands, with moderate enrichment at the apical tip. This pattern is consistent with the known biology of tropane alkaloids: synthesized in the roots and transported acropetally via the xylem, they are subsequently unloaded and stored within the leaf parenchyma, forming localized accumulation zones (chemical "islands") that may correspond to specialized storage compartments or idioblastic cells. The co-localization of atropine, scopolamine, cuscohygrine, and the atropine isotopic variant ($m/z$ 291.00) within the same cluster (Cluster 9) validates that the self-supervised encoder has captured genuine metabolic relationships rather than instrumental artifacts. By capturing this multi-compartmental distribution, the SimCLR-based segmentation effectively resolves the spatial continuum from vascular import to parenchymal storage to terminal accumulation.
|
The spatial distribution of atropine (*m/z* 290.02) and scopolamine (*m/z* 304.0) within Cluster 9 provides a nuanced view of tropane alkaloid allocation in *D. innoxia*. Rather than being exclusively confined to the midrib, these compounds exhibit a broad distribution across the leaf in the form of large and small islands, with moderate enrichment at the apical tip. This pattern is consistent with the known biology of tropane alkaloids: synthesized in the roots and transported acropetally via the xylem, they are subsequently unloaded and stored within the leaf parenchyma, forming localized accumulation zones (chemical "islands") that may correspond to specialized storage compartments or idioblastic cells. The co-localization of atropine, scopolamine, cuscohygrine, and the atropine isotopic variant (*m/z* 291.00) within the same cluster (Cluster 9) validates that the self-supervised encoder has captured genuine metabolic relationships rather than instrumental artifacts. By capturing this multi-compartmental distribution, the SimCLR-based segmentation effectively resolves the spatial continuum from vascular import to parenchymal storage to terminal accumulation.
|
||||||
|
|
||||||
#### 3.4 Advantages of Contrastive Learning over Linear Decomposition
|
#### 3.4 Advantages of Contrastive Learning over Linear Decomposition
|
||||||
Furthermore, the superiority of the self-supervised contrastive learning approach over traditional linear methods, such as Principal Component Analysis (PCA), lies in its fundamental shift from intensity-driven variance to morphological feature extraction (Shah et al., 2025). To establish a fair quantitative baseline, we compared SimCLR and PCA embeddings under identical conditions: both feature sets were projected to the same dimensionality via PCA and clustered using standard Euclidean $k$-means ($k = 10$) without the Spherical $k$-means re-normalization described in Section 2.4.4, ensuring a direct apples-to-apples comparison. Under these conditions, the SimCLR pipeline achieved a Silhouette Score of **0.508**, compared to the PCA baseline of 0.163, while the Calinski-Harabasz Index rose from 103.7 to **2147.4**. When the full optimized post-processing pipeline is applied (Spherical $k$-means with $L_2$ re-normalization, as described in Section 2.4.4–2.4.5), the Silhouette Score further improves to **0.6894** with a Davies-Bouldin Index of **0.6243**, confirming that the combination of contrastive feature learning and geometrically correct clustering produces massive improvements in spatial separation.
|
Furthermore, the superiority of the self-supervised contrastive learning approach over traditional linear methods, such as Principal Component Analysis (PCA), lies in its fundamental shift from intensity-driven variance to morphological feature extraction (Shah et al., 2025). To establish a fair quantitative baseline, we compared SimCLR and PCA embeddings under identical conditions: both feature sets were projected to the same dimensionality via PCA and clustered using standard Euclidean $k$-means ($k = 10$) without the Spherical $k$-means re-normalization described in Section 2.4.4, ensuring a direct apples-to-apples comparison. Under these conditions, the SimCLR pipeline achieved a Silhouette Score of **0.508**, compared to the PCA baseline of 0.163, while the Calinski-Harabasz Index rose from 103.7 to **2147.4**. When the full optimized post-processing pipeline is applied (Spherical $k$-means with $L_2$ re-normalization, as described in Section 2.4.4–2.4.5), the Silhouette Score further improves to **0.6894** with a Davies-Bouldin Index of **0.6243**, confirming that the combination of contrastive feature learning and geometrically correct clustering produces massive improvements in spatial separation.
|
||||||
|
|||||||
Reference in New Issue
Block a user