Schema representations in distinct brain networks support narrative memory during encoding and retrieval
Code for the paper Masís-Obando, Norman, & Baldassano. Schema representations in distinct brain networks support narrative memory during encoding and retrieval
You should set up a parent folder with two subfolders, one called "SchemaBigFiles" (or whatever you want) and the other can be a clone of this repository which will be named "SchemaEncodeRecall".
ParentFolder # parent folder
│
├── SchemaBigFiles # folder for larger files that are generated from analysis
│ └──_PaperOutputData
│ ├── Brainmaps
│ ├── roi_percept_score
│ ├── roi_percept_score_predictions
│ ├── roi_recall_score
│ ├── roi_recall_score_predictions
│ ├── sl_percept_score
│ ├── sl_percept_score_model_comparisons
│ ├── sl_percept_score_predictions
│ ├── sl_recall_score
│ ├── sl_recall_score_model_comparisons
│ └── sl_recall_score_predictions
│
└── SchemaEncodeRecall # This Repository
├── _analysis # folder with scripts and notebooks
│ └── figs # folder for saved figure .pngs
│
└── _data # some of smaller size data
├── kmeans # folder for outputs used for kmeans analysis
├── ROIs # folder with different cortical and hippocampal ROIs
└── Rubrics # rubrics also available at https://osf.io/fxwg2/?view_only=d5b13bee9a2f4eb882d7533cbc1be1c4
Both encoding and recall neural data in BIDS format is available at OpenNeuro.
After downloading both the encoding and recall data, preprocess and obtain surface data in fsaverage6 resolution.
To run the searchlights and specific ROI analyses, the SLURM scheduler (on servers mantained by the Princeton Neuroscience Institute) was used. Scripts and commands (e.g., “sbatch”) in this repository include the necessary formulations to work on SLURM.
In some of the scripts below, module load pyger
was used to instantiate a virtual environment with python 3.6 installed.
Because the most recent date used to generate the code was 20211014, you will find that the commands in this repository contain this date.
Run code below through instructions chronologically.
Instructions for generating the main text results.
Memory Scores
- Run the jupyter notebook
00_MemoryPerformance_Fig1.ipynb
to generate the filenormalizedRubricScores_byStory.pkl
which contains the quantified memory performance for each story for each subject. - We will need this later for relating the neural scores to behavior.
Story and schema scores for searchlights and specific a priori ROIs
encoding searchlights
sbatch 02_PerceptionStorySchema_SLs_step1.sh 20211014 L within_modality
sbatch 02_PerceptionStorySchema_SLs_step1.sh 20211014 R within_modality
encoding ROIs
sh 02_PerceptionStorySchema_ROIs_step0.sh 20211014 within_modality
reinstatement searchlights
sbatch 02_RecallStorySchema_SLs_step1.sh 20211014 L within_modality
sbatch 02_RecallStorySchema_SLs_step1.sh 20211014 R within_modality
reinstatement ROIs
sh 02_RecallStorySchema_ROIs_step0.sh 20211014 within_modality
Searchlight analysis
- Open the jupyter notebook labeled:
_ImportSearchlightsGenerateMaps.ipynb
- Find the cell labeled Figure 2
- Run to save brainmaps in desired output directory
ROI analysis
- Open the jupyter notebook labeled:
_ImportROIsSeeResults.ipynb
- Find the cell labeled Figure 2
- Run to output violin plots
Predicting behavioral memory for story details with neural measures from encoding and recall.
encoding searchlights
sbatch 03_Predictions_SLs_step1.sh 20211014 L sl_percept_score within_modality
sbatch 03_Predictions_SLs_step1.sh 20211014 R sl_percept_score within_modality
reinstatement searchlights
sbatch 03_Predictions_SLs_step1.sh 20211014 L sl_recall_score within_modality
sbatch 03_Predictions_SLs_step1.sh 20211014 R sl_recall_score within_modality
encoding AND reinstatement ROIs:
- In
03_Predictions_ROIs_step0.sh
, make sure thatrois=( PMC mPFC PHC Ang SFG )
sh 03_Predictions_ROIs_step0.sh 20211014 within_modality
Searchlight analysis
- Open the jupyter notebook labeled:
_ImportSearchlightsGenerateMaps.ipynb
- Find the cell labeled Figure 3
- Run to save brainmaps in desired output directory
ROI analysis
- Open the jupyter notebook labeled:
_ImportROIsSeeResults.ipynb
- Find the cell labeled Figure 3
- Run to output violin plots
Regions with significant schema effects and positive associations with subsequent memory.
sh 03S2_SchemaBenefitModelComparisons_step1.sh 2021014
- In the notebook titled
ImportSearchlightsGenerateMaps
find the cell labeledFigure 4
- Run the cells under it.
- Files will be saved in the default or (your desired) directory.
Mediation analysis with mPFC subclusters.
- First we have to run the silhouette analysis and save out the clusters.
- Go to the jupyter notebook:
05_Kmeans.ipynb
and run all the cells. - The clusters will be saved into
/_data/
asmPFC_c0.h5
andmPFC_c1.h5
Run the encoding and reinstatement story and schema scores:
ENCODING
- Open
02_PerceptionStorySchema_ROIs_step0.sh
- Uncomment the second “rois” line argument that contains
rois=( mPFC_k2_c0 mPFC_k2_c1 )
- Run in terminal with:
sh 02_PerceptionStorySchema_ROIs_step0.sh 20211014 within_modality
REINSTATEMENT
- Open
02_RecallStorySchema_ROIs_step0.sh
- Uncomment the second “rois” line argument that contains
rois=( mPFC_k2_c0 mPFC_k2_c1 )
- Run in terminal with:
sh 02_RecallStorySchema_ROIs_step0.sh 20211014 within_modality
- Open
03_Predictions_ROIs_step0.sh
- Uncomment the second “rois” line argument that contains
rois=( mPFC_k2_c0 mPFC_k2_c1 )
- Run in terminal with:
sh 03_Predictions_ROIs_step0.sh 20211014 within_modality
- Open
_ImportROIsSeeResults.ipynb
- Find the section titled:
Figure5; mPFC cluster results
- Run the cells to output the bar graphs.
- Open the jupyter notebook
05_Mediation.ipynb
- Run all the cells
Instructions for generating the supplementary results.
Encoding and Reinstatement Story and Schema Within-Subjects
encoding searchlights
sbatch 02S1_PerceptionStorySchema_WithinSubj_SLs_step1.sh 20211014 L
sbatch 02S1_PerceptionStorySchema_WithinSubj_SLs_step1.sh 20211014 R
encoding ROIs
sh 02S1_PerceptionStorySchema_WithinSubj_ROIs_step0.sh 20211014
reinstatement searchlights
sbatch 02S1_RecallStorySchema_WithinSubj_SLs_step1.sh 20211014 L
sbatch 02S1_RecallStorySchema_WithinSubj_SLs_step1.sh 20211014 R
reinstatement ROIs
sh 02S1_RecallStorySchema_WithinSubj_ROIs_step0.sh 20211014
Searchlight Analysis
- Open the jupyter notebook labeled:
_ ImportSearchlightsGenerateMaps.ipynb
- Find the cell labeled Figure 2
- Uncomment the line
extra = within_modality_within_subj
- Run to save brainmaps in desired output directory
ROI Analysis
- Open the jupyter notebook labeled:
_ImportROIsSeeResults.ipynb
- Find the cell labeled Figure 2
- Uncomment the line
extra = within_modality_within_subj
- Run to output violin plots
Encoding and Reinstatement Story and Schema Across-Modality
encoding searchlights
sbatch 02_PerceptionStorySchema_SLs_step1.sh 20211014 L across_modality
sbatch 02_PerceptionStorySchema_SLs_step1.sh 20211014 R across_modality
reinstatement Searchlights
sbatch 02_RecallStorySchema_SLs_step1.sh 20211014 L across_modality
sbatch 02_RecallStorySchema_SLs_step1.sh 20211014 R across_modality
encoding ROIs
- In
02_PerceptionStorySchema_ROIs_step0.sh
, make sure thatrois=( PMC mPFC PHC Ang SFG )
sh 02_PerceptionStorySchema_ROIs_step0.sh 20211014 across_modality
reinstatement ROIs
- In
02_RecallStorySchema_ROIs_step0.sh
, make sure thatrois=( PMC mPFC PHC Ang SFG )
sh 02_RecallStorySchema_ROIs_step0.sh 20211014 across_modality
Searchlight Analysis
- Open the jupyter notebook labeled:
_ImportSearchlightsGenerateMaps.ipynb
- Find the cell labeled Figure 2
- Uncomment the line
extra = ‘across_modality’
- Run to save brainmaps in desired output directory
ROI Analysis
- Open the jupyter notebook labeled:
_ImportROIsSeeResults.ipynb
- Find the cell labeled Figure 2
- Uncomment the line
extra = ‘across_modality’
- Run to output violin plots
Predicting PMC reinstatement story scores with encoding schema scores across cortex.
- To find associations with PMC’s reinstatement story score and the rest of the brain’s encoding schema score, run the following line:
sbatch 03S1_SeedtoSL_step1.sh 20211014 PMC roi_recall_score story_effect SL sl_percept_score schema_effect
- A brainmap will be saved in the default directory
../../SchemaBigFiles/_PaperOutputData/Brainmaps’
Behavioral memory benefit of neural schema scores
sh 03S2_SchemaBenefitModelComparisons_step1.sh
Saves searchlight results under a folder called sl_percept_score_model_comparisons
and sl_recall_score_model_comparisons
for the benefit analysis at encoding and retrieval, respectively.
- Open the jupyter notebook labeled:
_ImportSearchlightsGenerateMaps.ipynb
- Find the cell labeled:
Figure 3 - Supplement 2
- Run the cell
- Brainmap will be saved in
../../SchemaBigFiles/_PaperOutputData
undermodel comparisons
Predicting behavioral memory for story details with neural measures from encoding and recall within-subjects.
encoding searchlights
sbatch 03_Predictions_SLs_step1.sh 20211014 L sl_percept_score within_modality_within_subj
sbatch 03_Predictions_SLs_step1.sh 20211014 R sl_percept_score within_modality_within_subj
reinstatement searchlights
sbatch 03_Predictions_SLs_step1.sh 20211014 L sl_recall_score within_modality_within_subj
sbatch 03_Predictions_SLs_step1.sh 20211014 R sl_recall_score within_modality_within_subj
ROIs
For both encoding and reinstatement:
sh 03_Predictions_ROIs_step0.sh 20211014 within_modality_within_subj
Searchlight ANALYSIS
- Open the jupyter notebook labeled:
_ImportSearchlightsGenerateMaps.ipynb
- Find the cell labeled Figure 3
- Uncomment the line
extra = 'within_modality_within_subj'
- Run to save brainmaps in desired output directory
ROI ANALYSIS
- Open the jupyter notebook labeled:
_ImportROIsSeeResults.ipynb
- Find the cell labeled Figure 3
- Uncomment the line
extra = 'within_modality_within_subj'
- Run to output violin plots
Predicting behavioral memory for story details with neural measures from encoding and recall across-modality.
encoding searchlights
sbatch 03_Predictions_SLs_step1.sh 20211014 L sl_percept_score across_modality
sbatch 03_Predictions_SLs_step1.sh 20211014 R sl_percept_score across_modality
reinstatement searchlights
sbatch 03_Predictions_SLs_step1.sh 20211014 L sl_recall_score across_modality
sbatch 03_Predictions_SLs_step1.sh 20211014 R sl_recall_score across_modality
ROIs
For both encoding and reinstatement:
-
In
03_Predictions_ROIs_step0.sh
, make sure thatrois=( PMC mPFC PHC Ang SFG )
-
sh 03_Predictions_ROIs_step0.sh 20211014 across_modality
Searchlight ANALYSIS
- Open the jupyter notebook labeled:
_ImportSearchlightsGenerateMaps.ipynb
- Find the cell labeled Figure 3
- Uncomment the line
extra = 'across_modality'
- Run to save brainmaps in desired output directory
ROI ANALYSIS
- Open the jupyter notebook labeled:
_ImportROIsSeeResults.ipynb
- Find the cell labeled Figure 3
- Uncomment the line
extra = 'across_modality'
- Run to output violin plots