This repository hosts the analysis code used in preprocessing, analyzing and visualizing the data that is reported in this preprint: https://www.biorxiv.org/content/10.1101/2024.03.02.583127v3 The preprocessed data to reproduce the figures as well as the raw data can be found in this repository: https://osf.io/g8b9v/
The project investigates how multiple visual cortex maps prepare for the representation of an upcoming stimulus upon endogenous (voluntary) attentional cues. We collected fMRI data from 8 observers (the 9th observer was excluded from further analysis) across 4 scan sessions (around ~1 hour of data in each scan collected across 10 runs). Observers completed a trial-based orientation discrimination task with an attentional cue. On every trial, observers received an attentional cue and as they waited for the appearance of upcoming stimuli (target and distractors) a mapping stimulus appeared at a random, unpredictable location. We measured the BOLD response to the mapping stimuli for different attention conditions (see the paper for more details on the protocol).
- Download the data: https://osf.io/g8b9v/
- clone this repository inside the "attentionpRF" folder downloaded from OSF:
cd /path/to/osf/attentionpRF
git clone https://github.com/ekintuncok/Attention_pRF
- go to Attention_pRF/figures folder, run the corresponding figure script
- You don't need to download any of the dependencies (listed below) to be able to reproduce the paper figures. When you run a script from the figures folder, you will initially be asked to either provide the path where all dependencies lie (should be in the same main folder!) or input a "0" to indicate that you just want to look at the processed data. This information will be saved after it's run one time so that you can continue to the next figures. Have fun!
The code in this repository is largely on MATLAB.
- Version: MATLAB '23.2.0.2409890 (R2023b)'
- Dependencies: make sure these toolboxes are added to path to successfully run data pre-processing and/or get the manuscript figures.
- GLMDenoise: https://github.com/cvnlab/GLMdenoise
- Vistasoft: https://github.com/vistalab/vistasoft
- MRItools: https://github.com/WinawerLab/MRI_tools
- prfVista: https://github.com/WinawerLab/prfVista
- cvncode: https://github.com/cvnlab/cvncode
- knkutils: https://github.com/cvnlab/knkutils
Behavior data are shared in the preprocessed and raw format in the OSF repository. For making the paper figure 2A and 2B, run directly figures/fig2_A_B_dprime_RT.m script on the preprocessed data in BehaviorAnalyzed folder. Analysis scripts explained below in detail.
- s0_run_subject_analysis : calls the function "analyze_subject.m" to compute d prime and extract response times from each observer
- (func) analyze_subject : main function that computes reported behavior measurements (d prime, RT) for each observer), then plots these values with an error estimation based on within-subject variability. The output from this stage is saved separately for each observer. These files are in the OSF data directory BehaviorAnalyzed/sub-wlsubj***. Note that the first subject's data (wlsubj049) were collected with a slightly different design output. Therefore, their data were analyzed separately.
- (func) bootstrap_behavior: bootstraps the responses of each observer to calculate the error (in function analyze_subject)
- save_group_data : loops through the subject data and concatenates them to create a group level data matrix. These files are in the OSF data directory BehaviorAnalyzed/behavioral_sensitivity.mat and BehaviorAnalyzed/reaction_time.mat
- check_resp_rate : calculate the proportion of missed trial responses to report in the descriptives of the paper
Eye data are shared in the preprocessed and raw format in the OSF repository. For making the paper figure 2C, run directly figures/fig2_C_averageGaze.m script on the preprocessed data in EyeAnalyzed folder. Analysis scripts explained below in detail.
- attpRF_eye_convert : converts the EDF files saved for each run to mat files, marking the time stamps of interests and blinks within the recorded stream.
- attpRF_eye_extract : runs further cleaning on the converted data by averaging the gaze position estimated within a period of time (such as between the trial onset and the onset of the mapping stimulus), adds information like trial and session number.
- calculate_proportion_of_deviation : computes the proportion of trials during which the observer's gaze deviated from the central fixation point within the boundary we allowed at the psychophysics experiment outside the scanner. We calculated this metric because eye tracking is a passive method in the scanner, as trials cannot be aborted. Details of this descriptive statistics is available in the manuscript.
- (func) get_proportion_deviated : the function that calculates the gaze distance from the center and convert it to percentage of trials that satisfies it
fMRI data are shared in the preprocessed and raw format in the OSF repository. For making the paper figures 4, 5, 6, 7 and 8, run directly the scripts inside the figures folder with the corresponding name on the preprocessed data in the derivatives folder in OSF. Scripts are explained in more detail below.
We used NYU High Performance Computing resources to run the GLM on our data. This folder hosts the scripts to run GLM on the cluster.
- run_GLM : Uses the wrapper function MRI_tools/BIDS/bidsGLM.m to run GLMdenoise on the data. Script can be modified by changing the toolbox directories.
- glm.sbatch : batch script to run the GLM on the NYU HPC cluster.
We used NYU High Performance Computing resources to run the pRF model on our data. This folder hosts the scripts to run pRF models on the cluster.
- run_pRF_model : Uses prfVista/prfVistasoft.m to fit pRF model to the GLM output from the first stage (see below how the GLM output was prepared for this stage).
- prf.sbatch : batch script to run the pRF models on the NYU HPC cluster.
-
s0_attentionpRF : main script that adds the needed toolboxes to path, defines the main data and figure folders, assigns subject and session lists, some basic indexing information (columns that represent attend up vs down, etc.
-
s1_attpRF_prepareforGLM : prepares the data for GLMdenoise, which is the first stage analysis in the pipeline. This script doesn't have to run on the processed data that is used to make the figures. Only to be used for repeating the entire analysis pipeline. - (func) gii2nii : For each observer, it converts the GIFTI fMRI files to NIFTI ang MGZ files. MGZ files are inputted to GLMdenoise
- (func) BIDSformatdesign : For each observer, it creates a design matrix to be inputted to GLMdenoise. This function is based on the winawerlab MRItools repository.
-
s3_attpRF_visualizeprfsolutions : takes in the output from the pRF model for different conditions and converts those files to .mgz files. Later on, these mgr files are used in the analysis pipeline as well as for visualizations on the surface of each observer. Additionally, it hosts functions to get pRF parameter histograms and flat maps of surface overlaid with eccentricity and polar angle estimates (can call it for both atlas-based and hand-drawn ROIs).
- (func) getpRFparameterdist : plots histograms of pRF output
- (func) _getFlatMaps : plots model estimates on each observer's native surface