This repository contains the code for the paper: “Overcoming Output Dimension Collapse: How Sparsity Enables Zero-shot Brain-to-Image Reconstruction at Small Data Scales” by Kenya Otsuka, Yoshihiro Nagano, and Yukiyasu Kamitani (arXiv).
The repository consists of two main analysis pipelines:
- ODC on Real Data (
analysis/1_ODC_on_real_data/
) - Analysis of ODC using real brain imaging data - Sparse Regression (
analysis/2_sparse_regression/
) - Theoretical and simulation-based analysis of sparse regression
This project uses uv
for dependency management. Install dependencies with:
uv sync
- GPU with CUDA support (recommended)
- Sufficient RAM (recommended: 16GB+) for large matrix operations
Download the required datasets using the provided script:
uv run python scripts/download.py
This will automatically download and organize the following data:
- True features of each dataset in
data/features
- fMRI data (.h5) of each dataset in
data/fmri
- Model parameters in
data/models_shared
The script downloads data from:
- Deep Image Reconstruction@figshare
- brain-decoding-cookbook@figshare
- Spurious reconstruction from brain activity@figshare
# Step 1: Calculate best prediction
bash analysis/1_ODC_on_real_data/1_calculate_best_prediction/calculate_best_prediction.sh
# Step 2: Calculate brain prediction
bash analysis/1_ODC_on_real_data/2_calculate_brain_prediction/calculate_brain_prediction.sh
# Step 3: Reconstruction
bash analysis/1_ODC_on_real_data/3_reconstruction/iCNN.sh
# Step 4: Plot results
bash analysis/1_ODC_on_real_data/4_plot/calculate-mse.sh
Note: After running the shell script, you can plot the results:
analysis/1_ODC_on_real_data/4_plot/plot.py
- Plot results
# Step 1: Run simulations
bash analysis/2_sparse_regression/1_simulation/simulation.sh
Note: After running the shell script, you can plot the results:
analysis/2_sparse_regression/2_plot/plot_simulation.py
- Plot simulation resultsanalysis/2_sparse_regression/2_plot/plot_theory.py
- Plot theoretical results
- All scripts should be run from the project root directory
- The analysis pipelines take significant time to complete
- Use VS Code's Interactive Window for plotting scripts (execute
# %%
cells)
├── analysis/ # Analysis pipelines
│ ├── 1_ODC_on_real_data/ # Real data ODC analysis
│ └── 2_sparse_regression/ # Sparse regression analysis
├── src/overcoming_output_dimension_collapse/ # Library
├── assets/ # Generated results and data
├── data/ # Downloaded data
├── scripts/ # Data download script
└── README.md # This file