# Experiment 1 (StudyForrest)
Contains scripts for connectopic and retinotopic analyses of the StudyForrest
dataset in Experiment 1.
We outline the contents of the repository below, in the (approximate) order
they need to be run.
> Many of the scripts make reference to a `basedir` variable - this should be
> set to the top-level directory containing all of the subject directories.
## preproc
Scripts used for setting up directory structure, and running initial
pre-processing stages.
> Note that we use our own Freesurfer reconstructions of the subject anatomies,
> rather than the ones provided with the StudyForrest repository (although they
> should be similar). This is because we were unable to get the Freesurfer
> surfaces in the StudyForrest repository to download successfully.
> The movie-watching and retinotopy timeseries were pre-processed in FEAT. The
> resulting *filtered_func_data* timeseries serve as the inputs to both the
> connectopy and retinotopy analysis pipelines.
* `unpack_data.sh` - Copies/symlinks data downloaded from the StudyForrest
repository into a nicer directory structure. This sets up the basic structure
of subject directories that further scripts rely on.
* `freesurfer_bbr.sh` - Runs boundary based registration between functional
volumes and Freesurfer surfaces.
* `fsl_bbr+fnirt.sh` - Runs volume registrations, first as boundary based
registrations between each subject's functional and anatomical volumes, then
as non-linear registrations between the anatomical volumes and MNI space.
* `xfm_aseg2vol.sh` - Transforms Freesurfer *aseg* atlas to volume spaces for
both the MNI brain and individual subjects. This is used to derive
white-matter and ventricular masks to be used for normalising the functional
timeseries (see *normalise_timeseries.py*), as well as a sub-cortical gray
matter mask to be used for masking the sub-cortical volume data (see
*xfm_normalised_timeseries2MNI_subcortex.sh*).
* `normalise_timeseries.py` - Normalises the pre-processed functional
timeseries (the *filtered_func_data* files produced by FEAT) by first
converting to percent signal change, and then regressing out the mean
white-matter and ventricular timeseries and motion parameters.
* `xfm_normalised_timeseries2surf.sh` - Transforms normalised timeseries onto
_fsaverage6_ cortical surface.
* `xfm_normalised_timeseries2MNI_subcortex.sh` - Transforms normalised
timeseries to MNI volume and then masks by subcortical gray matter.
## retinotopy
Scripts are used for performing travelling wave analyses of retinotopy data,
and allow defining V1 labels.
* `calc_phase_maps.sh` - Uses a combination of AFNI and Freesurfer to perform
travelling wave analysis on cortical surface. Also depends on
*fix_gifti_intent.py* and *fix_phaseshifts.py*.
* `display_in_freeview.sh` - Display phase maps in freeview for manual drawing
of V1 ROIs. These ROIs were saved out as Freesurfer label files.
* `restrict_maps_to_labels.py` - Once V1 labels have been defined, this script
restricts the phase maps to to those labels. The restricted maps serve as one
of the inputs to the connectopic mapping pipeline.
* `fix_gifti_intent.py`, `fix_phaseshifts.py` - Utility scripts used by the
*calc_phase_maps.sh* script.
## connectopy
Scripts for calculating connectivity fingerprints and performing connectopic
mapping.
* `utils/manifold.py` - Module contains assorted functions used for manifold
learning.
* `utils/surface.py` - Module contains assorted functions for loading and
saving surface data.
* `calc_connectivity_fingerprints.py` - Calculates the functional connectivity
fingerprints within V1 by correlating the normalised timeseries. Provides
options for measuring connectivity between V1 and all other cortical and
subcortical structures, just cortical structures, just subcortical
structures, cortical and subcortical structures substituted with noise, or
purely within V1.
* Various scripts perform connectopic mapping, each offering different
algorithms:
* `do_diffusion_map.py` - Diffusion maps
* `do_isomap.py` - Isomap
* `do_kernel_pca.py` - Kernal PCA, using polynomial and RBF kernels
* `do_linear_embedding.py` - PCA and ICA
* `do_LLE.py` - (M)LLE and LTSA
* `do_spectral_embedding.py` - Spectral Embedding
* `do_tSNE.py` - t-SNE
## stats
Runs statistical analyses on the prediction accuracies (absolute correlations
between retinotopic and connectopic maps).
* First, various scripts are used to extract the prediction accuracies
(correlations) from each connectopic mapping algorithm and compile the values
over subjects. The outputs are used as inputs to further statistical
analyses.
* `extract_corrs-spectral_embedding.py` - Extracts correlations from spectral
embedding algorithm. Dedicated script is needed to handle the different
graph types (weighted/unweighted $\times$ full/radius/kNN).
* `extract_corrs-kernel_pca.py` - Extracts correlations from kernel PCA
algorithm. Dedicated script is needed to handle the different kernel types
(polynomial and RBF).
* `extract_corrs-other_embeddings.py` - Extracts correlations for all other
connectopic mapping technqiues (PCA, ICA, MLLE, LTSA, Isomap, diffusion
maps, and t-SNE).
* `analyse_corrs-spectral_embedding.R` - Performs analysis of correlations
within spectral embedding algorithm. Runs a repeated-measures ANOVA with
factors for the map-type (eccentricity, polar angle) and graph type. Also
performs one-sample t-tests to test correlations in each case against zero.
* `analyse_corrs-other_embeddings.R` - Performs analysis of correlations for
all other algorithms (PCA, ICA, kernel PCA (polynomial and RBF), LLE, LTSA,
Isomap, diffusion maps, and t-SNE). Runs paired-samples t-tests to compare
correlations between map types (eccentricity, polar angle). Also performs
one-sample t-tests to test correlations in each case against zero.
* `compare_corrs_between_embeddings.R` - Compares correlations across
connectopic mapping algorithms via a repeated-measures ANOVA with factors for
the map and algorithm type.
* `compare_corrs_between_sources.R` - For spectral embedding, Isomap, and
diffusion map algorithms, compares correlations for connectopic maps based on
different connectivity sources (cortex+subcortex, cortex-only,
subcortex-only, within-V1, and cortex+subcortex substituted with noise).
Performs a repeated-measures ANOVA with factors for the algorithm type, map
type, and connectivity source.
* `cross_corr_embedding.py` - Calculates correlations between connectopic maps
produced by each connectopic mapping algorithm.
* `pyUtils.py`, `R_utils.R` - Utility scripts, contain functions used by other
scripts.