Actualizar MSI_julia-python_mapping.md
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# Deep Learning in Mass Spectrometry Imaging: A Hybrid Julia-Python Workflow for the Automated Anatomical Mapping of *Datura innoxia*
|
# Deep Learning in Mass Spectrometry Imaging: A Hybrid Julia-Python Workflow for the Automated Anatomical Mapping of *Datura innoxia*
|
||||||
|
|
||||||
**Authors:** Carlos Daniel Sierra Álvarez, Juan Francisco Moreno Luna, José Jovani Martínez, José Julián Sierra Álvarez.
|
**Authors:** Carlos Daniel Sierra Álvarez, Juan Francisco Moreno Luna, José Julián Sierra Álvarez, José Jovani Martínez.
|
||||||
**Affiliation:** Advanced Genomics Unit, Cinvestav, km 9.6 Libr. Nte. Irapuato-León, Irapuato, 36824, Gto., Mexico.
|
**Affiliation:** Advanced Genomics Unit, Cinvestav, km 9.6 Libr. Nte. Irapuato-León, Irapuato, 36824, Gto., Mexico.
|
||||||
**Keywords:** MSI, Julia Language, Deep Learning, SimCLR, Contrastive Learning, Group Normalization, *Datura innoxia*, Spatial Metabolomics.
|
**Keywords:** MSI, Julia Language, Deep Learning, SimCLR, Contrastive Learning, Group Normalization, *Datura innoxia*, Spatial Metabolomics.
|
||||||
|
|
||||||
@@ -43,14 +43,14 @@ $$I_{norm}(x, y) = \min\left(1, \frac{I_{raw}(x, y)}{T}\right)$$
|
|||||||
|
|
||||||
This transformation ensures that 98% of the chemical signal is represented within a standardized dynamic range, effectively enhancing the contrast of parenchymal and vascular structures. By suppressing the influence of extreme outliers, TrIQ provides a morphologically consistent input for the subsequent contrastive learning phase, preventing the neural network from over-fitting to instrumental artifacts.
|
This transformation ensures that 98% of the chemical signal is represented within a standardized dynamic range, effectively enhancing the contrast of parenchymal and vascular structures. By suppressing the influence of extreme outliers, TrIQ provides a morphologically consistent input for the subsequent contrastive learning phase, preventing the neural network from over-fitting to instrumental artifacts.
|
||||||
|
|
||||||
3. **Spatial Standardization (Pristine Coordinate Mapping):** To ensure compatibility with the deep learning backbone, each normalized ion map was spatially embedded into a standardized **256 $\times$ 256 pixel** matrix using strict **Zero-Padding**, completely avoiding any sub-pixel interpolation. In MSI, the physical laser ablation grid serves as an absolute spatial ground truth. Standard computational interpolation (such as bilinear resizing) forces anisotropic stretching—disproportionately warping the leaf morphology—and introduces artificial floating-point values at the sharp boundaries of the tissue mask. By mapping the raw $161 \times 106$ coordinates directly into the center of a zero-matrix, we preserved the true, undistorted anatomical geometry of the leaf while achieving the uniform dimensionality required by the convolutional layers. As a demonstration of this high-throughput pipeline, the Julia engine parsed the raw `.ibd` binaries, applied TrIQ, and exported 588 padded individual ion slices in less than 16 seconds.
|
3. **Spatial Standardization (Pristine Coordinate Mapping):** To ensure compatibility with the deep learning backbone, each normalized ion map was spatially embedded into a standardized **256 $\times$ 256 pixel** matrix using strict **Zero-Padding**, completely avoiding any sub-pixel interpolation. In MSI, the physical laser ablation grid serves as an absolute spatial ground truth. Standard computational interpolation (such as bilinear resizing) forces anisotropic stretching —disproportionately warping the leaf morphology— and introduces artificial floating-point values at the sharp boundaries of the tissue mask. By mapping the raw $161 \times 106$ coordinates directly into the center of a zero-matrix, we preserved the true, undistorted anatomical geometry of the leaf while achieving the uniform dimensionality required by the convolutional layers. As a demonstration of this high-throughput pipeline, the Julia engine parsed the raw `.ibd` binaries, applied TrIQ, and exported 588 padded individual ion slices in less than 16 seconds.
|
||||||
|
|
||||||
### 2.4 Self-Supervised Representation Learning (Python)
|
### 2.4 Self-Supervised Representation Learning (Python)
|
||||||
We implemented a Contrastive Learning (SimCLR) scheme in PyTorch (Paszke et al., 2019), adapting the framework to the unique properties of mass spectrometry imaging.
|
We implemented a Contrastive Learning (SimCLR) scheme in PyTorch (Paszke et al., 2019), adapting the framework to the unique properties of mass spectrometry imaging.
|
||||||
|
|
||||||
1. **Model Architecture and VRAM Optimization:** A custom **Fully Convolutional Contrastive Network** was engineered to replace standard heavy computer vision backbones. Crucially, all standard batch normalization blocks were replaced with **Group Normalization (GroupNorm)** layers (8 groups per layer). In datasets characterized by massive empty, zero-padded backgrounds, standard Batch Normalization calculates running statistics that become overwhelmingly biased by the blank space, leading to gradient instability and the artificial clustering of the background mask. Group Normalization computes statistics per individual image slice, mathematically neutralizing the static background and forcing the network to optimize strictly on the high-variance internal biological structures. The network concludes with an Adaptive Average Pooling layer and a 2-layer MLP to project the spatial features into a 128-dimensional latent space (Table 1).
|
1. **Model Architecture and VRAM Optimization:** A custom **Fully Convolutional Contrastive Network** was engineered to replace standard heavy computer vision backbones. Crucially, all standard batch normalization blocks were replaced with **Group Normalization (GroupNorm)** layers (8 groups per layer). In datasets characterized by massive empty, zero-padded backgrounds, standard Batch Normalization calculates running statistics that become overwhelmingly biased by the blank space, leading to gradient instability and the artificial clustering of the background mask. Group Normalization computes statistics per individual image slice, mathematically neutralizing the static background and forcing the network to optimize strictly on the high-variance internal biological structures. The network concludes with an Adaptive Average Pooling layer and a 2-layer MLP to project the spatial features into a 128-dimensional latent space (Table 1).
|
||||||
|
|
||||||
To enable training on consumer-grade hardware (NVIDIA RTX 3050 Mobile, ~4 GB VRAM), a gradient accumulation strategy was employed. Rather than fitting an effective batch of 32 images simultaneously into GPU memory—which would trigger a CUDA out-of-memory error—the engine processes 8 images physically per step and accumulates gradients over 4 consecutive forward passes before executing a single optimizer update, as described in the Hugging Face documentation (Hugging Face, 2025). This is mathematically equivalent to training with a true batch size of 32 while using only a quarter of the VRAM.
|
To enable training on consumer-grade hardware (NVIDIA RTX 3050 Mobile, ~4 GB VRAM), a gradient accumulation strategy was employed. Rather than fitting an effective batch of 32 images simultaneously into GPU memory —which would trigger a CUDA out-of-memory error— the engine processes 8 images physically per step and accumulates gradients over 4 consecutive forward passes before executing a single optimizer update, as described in the Hugging Face documentation (Hugging Face, 2025). This is mathematically equivalent to training with a true batch size of 32 while using only a quarter of the VRAM.
|
||||||
|
|
||||||
**Table 1. Training hyperparameters and model configuration for the SimCLR-MSI workflow.**
|
**Table 1. Training hyperparameters and model configuration for the SimCLR-MSI workflow.**
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user