diff --git a/Hoja.png b/Hoja.png new file mode 100644 index 0000000..26c1f6e Binary files /dev/null and b/Hoja.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..889bb30 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Carlos Daniel Sierra Álvarez, Juan Francisco Moreno Luna + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8889813 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Deep Learning in Mass Spectrometry Imaging: A Hybrid Julia-Python Workflow + +This repository contains the computational pipeline for the automated anatomical mapping of *Datura innoxia* (toloache) using Mass Spectrometry Imaging (MSI). The workflow addresses the "two-language problem" by leveraging **Julia** for high-performance data preprocessing and **Python** for self-supervised representation learning. + +## Key Features +- **High-Performance Preprocessing**: Rapid `.imzML` ingestion and TrIQ normalization using Julia. +- **Self-Supervised Learning**: Contrastive learning (SimCLR) with an EfficientNet-B0 backbone implemented in PyTorch. +- **Empirical Clustering**: Automated anatomical segmentation using PCA and K-Means, optimized for vascular and parenchymal tissue differentiation. +- **CPU Optimized**: Designed to run on standard consumer hardware (no GPU required for inference). + +## Project Structure +- `scripts_julia/`: Julia scripts for mass slice extraction, TrIQ normalization, and image generation. +- `scripts_python/`: Python scripts for SimCLR training, feature extraction, and clustering. +- `Model/`: Contains the pre-trained weights (`msi_encoder_trained.pth`). +- `environment/`: Dependency list (`requirements.txt`). +- `Articule MSI/`: Manuscript draft and documentation. + +## Installation + +### Python +It is recommended to use a virtual environment: +```bash +pip install -r environment/requirements.txt +``` + +### Julia +Ensure you have Julia installed and the following packages: `MSI.jl`, `ImzML.jl`, `Images.jl`, and `DataFrames.jl`. + +## Usage Workflow + +1. **Preprocessing (Julia)**: + Run `scripts_julia/preparar_datos_simclr.jl` to convert `.imzML` data into normalized PNG ion maps. + +2. **Training (Optional)**: + Run `scripts_python/CNN_proof_1.py` to retrain the SimCLR encoder. + +3. **Clustering & Mapping**: + Use `scripts_python/cluster_msi_direct.py` to extract embeddings from the pre-trained model and generate the metabolic clusters. + +4. **Visualization**: + Run `scripts_python/visualizar_clusters.py` to generate the final cluster galleries. + +## Citation & Acknowledgments +This implementation is based on the methodology proposed by: +> Hu, H., Bindu, J. P., & Laskin, J. (2022). Self-supervised clustering of mass spectrometry imaging data using contrastive learning. *Chemical Science*, 13(1), 90-98. DOI: [10.1039/d1sc04077d](https://doi.org/10.1039/d1sc04077d) + +## License +This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details. diff --git a/msi_encoder_trained.pth b/msi_encoder_trained.pth new file mode 100644 index 0000000..b9e9396 Binary files /dev/null and b/msi_encoder_trained.pth differ diff --git a/region_interes.png b/region_interes.png new file mode 100644 index 0000000..090cc45 Binary files /dev/null and b/region_interes.png differ