Analysis code for: "Opposite effects of acute sleep restriction on the dynamic and static functional connectivity network of young and old adult brains"
This page includes the analysis code for our manuscript entitled: "Young and old adult brains experience opposite effects of acute sleep restriction on the functional connectivity network" (preprint here). The analyses in this manuscript can be reproduced using the code included here. To do so, begin by (1) setting up your environment by following the instructions under "Environment installation instructions" (you can set up an environment either locally or on a high-performance computing cluster). Then, (2) run the code in the order specified under the "Order to run code" section.
Note: for each section follow the instructions in either the Local Bash or the HPC (Alliance Canada) Bash subsection.
git clone https://github.com/McIntosh-Lab/SleepyBrain_analyses.git
cd SleepyBrain_analyses
conda create -n neudorf_venv -c conda-forge python=3.10 numpy scipy nibabel nilearn matplotlib pillow pandas seaborn tqdm statsmodels plotnine networkx
conda activate neudorf_venv
pip install nctpy matlabengine=9.13.11 #matlab 2022b.2
cd python_packages
git clone https://github.com/netneurolab/neuromaps
cd neuromaps
pip install .
cd ../brainvistools
pip install .
cd ../PyNeudorf
pip install .
cd ../..cd ~/scratch
git clone https://github.com/McIntosh-Lab/SleepyBrain_analyses.git
cd SleepyBrain_analyses/python_packages
git clone https://github.com/netneurolab/neuromaps
cd ..
module load StdEnv/2020 matlab/2022b.2 python/3.10
python3.10 -m venv neudorf_venv
source neudorf_venv/bin/activate
#edit line below by finding matlabroot using `which matlab`, and substitute `matlab` executable with `glnxa64`
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cvmfs/restricted.computecanada.ca/easybuild/software/2020/x86-64-v3/Core/matlab/2022b.2/bin/glnxa64
pip install -r requirements_hpc.txtRscript install_packages.rmodule load StdEnv/2020 r/4.3.1 gcc/9.3.0 gdal/3.5.1 udunits/2.2.28
mkdir -p ~/.local/R/$EBVERSIONR
export R_LIBS=~/.local/R/$EBVERSIONR/
Rscript install_packages.rFollow instructions here and add plscmd folder to startup.m: https://github.com/McIntosh-Lab/PLS
git clone https://github.com/McIntosh-Lab/PLS
cp -r PLS/plscmd ~/matlab
echo "addpath(genpath('~/matlab/plscmd'))" >> ~/matlab/startup.mdata/data_processing/import_SleepyBrain_data.py- LEiDA toolbox in
leida-matlab-1.0/. You can changen_permutationsandn_bootstrapsto a higher number after testing. mean_centred_pls.mmodularity.mrsfMRI_sleep_deprivation_analyses.pyGM_sig_var_analyses.r,modularity_analyses.r, andPLS_usc_figures.rin no particular order.
Use sbatch submission scripts provided:
- Copy data (0_copy_data.sh):
sbatch 0_copy_data.sh
- Submit preprocessing (1_submit_preprocessing.sh):
sbatch 1_submit_preprocessing.sh
- Submit LEiDA (2_submit_leida.sh):
cd leida-matlab-1.0sbatch 2_submit_leida.shcd ...
- Submit MATLAB analyses (3_submit_matlab_analyses.sh):
sbatch 3_submit_matlab_analyses.sh
- Submit Python analyses (4_submit_python_analyses.sh):
- Change
RSCRIPT='/usr/bin/Rscript'at top ofrsfMRI_sleep_deprivation_analyses.pytoRSCRIPT='/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Core/r/4.3.1/bin/Rscript' sbatch 4_submit_python_analyses.sh
- Change
- Submit R analyses (5_submit_r_analyses.sh):
sbatch 5_submit_r_analyses.sh
- Submit null testing matlab script (6_submit_FC_null_array.sh; optional for FAIR review):
sbatch 6_submit_FC_null_array.sh