### This repository belongs to the publication ""


# Environment setup
`conda create -n <env_name> python=3.9` 

`conda activate <env_name>`

`pip install -r requirements.txt`

# Data
The data contains of the following:
#### Natural movie stimulus
* stimulus frames: all frames of the stimulus, down-sampled to 300x350 pixels
* fixation file: file that specify which frame is loaded and the center of the frame
* response file: dictionary containing cell responses for all cells for all frames across all trials
* pre-computed STAs: STAs for each cell precomputed from the white noise stimulus
* training config: config file specifying the response file, the cells and the crop to be used

The expected file structure is the following:
```
---stimuli
    |--- img_file_0
    |--- ....
    |--- img_file_n
---responses
    |--- config file
    |--- response file dataset1
    |--- response file dataset2
---fixations
    |--- fixation file 
---stas
    |--- sta cell 0
    |--- ...
    |--- sta cell n
   ```


#### White noise stimulus
* training config file for white
* stimulus frames: all frames of the stimulus, down-sampled to 300x350 pixels
* response file: dictionary containing cell responses for all cells for all frames across all trials
* pre-computed STAs: STAs for each cell pre-computed from the white noise stimulus
* training config: config file specifying the response file, the cells and the crop to be used
```
---non_repeating_stimulus
    |--- trial_001
      |--- all_images.npy
    |--- ....
    |--- trial_n
       | --all_images.npy
---repeating_stimulus
    |--- all_images.npy
---responses (same directory as for nm stimulus)
    |--- config file
    |--- response file dataset1
    |--- response file dataset2
---stas (same directory as for nm stimulus)
    |--- sta cell 0
    |--- ...
    |--- sta cell n
```

# Training

To train an LN model on natural movie, run the `ln_model_factorized_marmoset_nm.py`
To train an LN model on white noise, run the `ln_model_factorized.py`

For finetuning, run the 
* `train_multiretinal_ln_wn_for_nm.py` for models trained on white noise and to be finetuned on natural movies
* `train_multiretinal_ln_nm_for_wn.py` for models trained on natural movies to be finetuned on white noise

# Evaluation & analysis
Models can be evaluated using `evaluations/ln_model_performance.py`
Sizes are estimated using functions in `evaluations/sizes_estimations.py`
The power spectra of the stimulus, filtered stimulus and filters is in `poser_spectrum_analysis.py` for rank 1 LN models and `power_spectrum_3d.py` for rank2 LN models.
The analysis of LN model performance and size and is in `notebooks/adaptation_paper_figers.ipybn`

