From 922ae74e2e77938eb797d6677b677e3acd86c86d Mon Sep 17 00:00:00 2001 From: Carlos Date: Tue, 28 Jul 2026 03:29:18 +0200 Subject: [PATCH] Subir archivos a "/" --- MSI_julia-python_mapping.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MSI_julia-python_mapping.md b/MSI_julia-python_mapping.md index 5a5bac3..fd099c0 100644 --- a/MSI_julia-python_mapping.md +++ b/MSI_julia-python_mapping.md @@ -97,9 +97,9 @@ We conducted direct surface analysis of *Datura innoxia* leaves using an LD-LTP- ## 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 1E) [@van_der_maaten_visualizing_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. A global statistical analysis across 1,394 discovered isotopic pairs yielded a mean latent distance of $0.2879$, compared to $0.5979$ for random ion pairs, achieving profound statistical significance (Welch's t-test, $p < 10^{-300}$). Of these, 540 pairs passed strict structural validation (Cosine Similarity $\geq 0.80$), including Atropine (*m/z* 290.08) and its $+1$ isotope (*m/z* 291.08) with a similarity of 0.9067. 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. A global statistical analysis across 1,394 discovered isotopic pairs yielded a mean latent distance of $0.2879$, compared to $0.5979$ for random ion pairs, achieving profound statistical significance (Welch's t-test, $p < 10^{-300}$). Of these, 540 pairs passed strict structural validation (Cosine Similarity $\geq 0.80$), including Atropine (*m/z* 290.08) and its $+1$ isotope (*m/z* 291.17) with a cosine similarity of 0.9968. 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_demystifying_2020]. Our data provides an elegant empirical refutation of this hypothesis. Atropine (*m/z* 290.08) and its $+1$ isotope (*m/z* 291.08) 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_simple_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.9067 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_demystifying_2020]. Our data provides an elegant empirical refutation of this hypothesis. Atropine (*m/z* 290.08) and its $+1$ isotope (*m/z* 291.17) 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_simple_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 cosine similarity of 0.9968 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.9863$ with Atropine *m/z* 290.08) 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. Notably, the scopolamine signal identified by MS/MS at *m/z* 304.17 appears in the imaging data across multiple binned channels spanning the isotopic envelope (\textit{m/z} 304.00 to 304.42, bin spacing $\sim$0.08--0.09). The pipeline independently generates an ion image at the exact \textit{m/z} 304.17 bin (\texttt{ion\_304.17.png}), which receives direct structural validation from the MS/MS fragmentation pattern. In the clustering, the lower-mass bins (303.83--304.08) are assigned to Cluster 7 while the higher-mass bins (304.17--304.42) are assigned to Cluster 2, reflecting subtle spatial intensity variations across the isotopic distribution at the tissue level. Both clusters capture vascular-related patterns (Section 4.3), confirming that the spectral binning inherent to MSI acquisition preserves biological coherence in the clustering despite the technical splitting of a single molecular species across multiple channels. @@ -165,7 +165,7 @@ Three clusters are characterized by broad spatial distributions that span the en The spatial distribution of key tropane alkaloids reveals distinct but complementary anatomical patterns that reflect their biosynthetic relationships and functional roles. Scopolamine (*m/z* 304.00) and Atropine (*m/z* 290.08), both assigned to Cluster 7, exhibit a co-localized midrib and laminar island distribution, consistent with their shared biosynthetic pathway. Cuscohygrine (*m/z* 225.92), in Cluster 3, displays a striking vascular architecture from primary to secondary veins extending from the petiole to the leaf tip. 6-Hydroxyhyoscyamine (*m/z* 306.25), in Cluster 2, follows a vascular distribution throughout the leaf. Tropine (*m/z* 142.08) in Cluster 9 shows broad parenchymal distribution as a key biosynthetic precursor of tropane alkaloids. Tropinone (*m/z* 140.17), assigned to Cluster 0, shows vascular-apical distribution essential for downstream alkaloid synthesis. The co-localization of scopolamine and atropine within Cluster 7 (cosine similarity 0.9863), alongside the distinct vascular assignments of cuscohygrine (Cluster 3), tropine (Cluster 9), and tropinone (Cluster 0), demonstrates that the self-supervised encoder successfully discriminates between subtle variations in spatial topography while capturing genuine biosynthetic and metabolic relationships. ## 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_msinet_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 k-means (k = 10). Under these conditions, the SimCLR pipeline achieved a Silhouette Score of 0.3225, compared to the PCA baseline of 0.1476, while the Calinski-Harabasz Index rose from 248.26 to 1231.21. The Davies-Bouldin Index for SimCLR was 0.9362 versus 1.5962 for PCA, confirming that the combination of contrastive feature learning produces massive improvements in spatial separation. Furthermore, the SimCLR embeddings exhibited exceptional stability across multiple random seeds, with a mean Silhouette Score of 0.3226 $\pm$ 0.0003 and an Adjusted Rand Index (ARI) of 0.9324 between runs, indicating that the learned representations are highly reproducible and independent of stochastic initialization. +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_msinet_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 k-means (k = 10). Under these conditions, the SimCLR pipeline achieved a Silhouette Score of 0.3496, compared to the PCA baseline of 0.1476, while the Calinski-Harabasz Index rose from 248.26 to 1212.54. The Davies-Bouldin Index for SimCLR was 0.9389 versus 1.5962 for PCA, confirming that the combination of contrastive feature learning produces massive improvements in spatial separation. Furthermore, the SimCLR embeddings exhibited exceptional stability across multiple random seeds, with a mean Silhouette Score of 0.3499 $\pm$ 0.0006 and an Adjusted Rand Index (ARI) of 0.9351 between runs, indicating that the learned representations are highly reproducible and independent of stochastic initialization. While PCA relies on magnitude-dependent variance—essentially grouping ions based on their absolute 'brightness' and pixel-to-pixel correlation—it is highly sensitive to the dynamic range of the detector and often fails to resolve low-abundance metabolites that do not contribute significantly to the total variance. In contrast, the custom SimCLR architecture prioritizes the underlying spatial topographies (morphological fingerprints) of the ion images. This allows the model to project ions with vastly different absolute intensities but identical anatomical 'silhouettes'—such as a primary alkaloid and its trace-level isotopes or precursors—into adjacent coordinates within the latent space. By decoupling chemical distribution from absolute abundance, this workflow captures the structural integrity of the tissue, offering a more robust and biologically grounded segmentation that traditional linear or intensity-based algorithms cannot easily achieve.