fixed docker Julia issues, tested reproductability across all scripts through the docker

This commit is contained in:
Pixelguy14
2026-06-03 13:38:45 -06:00
parent 3143e29843
commit 242fc6a445
13 changed files with 410 additions and 183 deletions
+28 -20
View File
@@ -34,7 +34,7 @@ docker run -it --rm -v $(pwd):/app msi-hybrid-workflow
### Running the Container (GPU/CUDA Mode)
```bash
docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow
docker run -it --rm --shm-size=2gb --gpus all -v $(pwd):/app msi-hybrid-workflow
```
## Usage Workflow
@@ -42,15 +42,21 @@ docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow
### 1. Preprocessing (Julia)
Leverage Julia's performance and the **JuliaMSI** framework.
**Run the MSI Bridge (Normalization & PNG Export):**
**Run this clean runtime instantiation command one time to sync everything down to your local directory:**
```bash
docker run -it --rm -v $(pwd):/app msi-hybrid-workflow \
julia --threads auto --project=/app/environment scripts_julia/julia_msi_bridge.jl
julia --project=/app/environment -e 'using Pkg; Pkg.resolve(); Pkg.instantiate()'
```
**Run the MSI Bridge (Normalization & PNG Export):**
```bash
docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
julia --threads auto --project=/app/environment /app/scripts_julia/julia_msi_bridge.jl
```
**Optional: Plot Cluster Spectra:**
```bash
docker run -it --rm -v $(pwd):/app msi-hybrid-workflow \
docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
julia --threads auto --project=/app/environment scripts_julia/graph_cluster_spectra.jl
```
@@ -59,7 +65,12 @@ Train the SimCLR encoder to extract morphological features using CUDA.
**Run CNN Training (SimCLR):**
```bash
docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
docker run -it --rm \
--shm-size=2gb \
--gpus all \
-v $(pwd):/app \
-v msi_torch_cache:/root/.cache/torch \
msi-hybrid-workflow \
python3 scripts_python/CNN_proof_1.py
```
*Note: The script automatically detects CUDA and logs per-epoch RAM usage.*
@@ -67,6 +78,12 @@ docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
### 3. Clustering & Validation
Determine optimal clusters and perform quantitative validation.
**Generate Clusters:**
```bash
docker run -it --rm --shm-size=2gb --gpus all -v $(pwd):/app msi-hybrid-workflow \
python3 scripts_python/cluster_msi_direct.py
```
**Evaluate Clustering:**
```bash
docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
@@ -75,7 +92,7 @@ docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
**Quantitative Validation:**
```bash
docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
python3 scripts_python/quantitative_validation.py
```
@@ -84,28 +101,19 @@ Generate the final galleries and t-SNE maps.
**Generate t-SNE Maps:**
```bash
docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
docker run -it --rm --shm-size=2gb --gpus all -v $(pwd):/app msi-hybrid-workflow \
python3 scripts_python/graficar_tsne_msi.py
```
**Create Cluster Galleries:**
```bash
docker run -it --rm --gpus all -v $(pwd):/app msi-hybrid-workflow \
docker run -it --rm --shm-size=2gb --gpus all -v $(pwd):/app msi-hybrid-workflow \
python3 scripts_python/visualize_clusters.py
```
## Benchmarking & Hardware Realism
The pipeline is optimized for efficiency on consumer-grade hardware.
- **Julia Stage**: Uses `BenchmarkTools.jl` to profile binary parsing.
- **Python Stage**: Uses `psutil` and `CUDA` monitoring to track hardware overhead.
- **Determinism**: All stochastic steps are locked with `seed=42`.
## Julia-Python Bridge Details
The "two-language problem" is solved by an intermediate file-system bridge. Julia performs binary MSI parsing and **Threshold Intensity Quantization (TrIQ)**. The resulting data is saved as high-contrast 224x224 grayscale PNG images, allowing the Python PyTorch pipeline to consume it efficiently.
## Citation
If you use this workflow or the JuliaMSI framework, please cite:
> Sierra-Álvarez, J. J., et al. (2025). JuliaMSI: A high-performance graphical platform for mass spectrometry imaging data analysis. *Analytica Chimica Acta*, 1377, 344613. DOI: [10.1016/j.aca.2025.344613](https://doi.org/10.1016/j.aca.2025.344613)
## 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**.