Mac OS

VS Code

VS Code is a fantastic editor for coding. It serves as an IDE (integrated development environment) and supports Jupyter notebooks and GitHub, which can make it a one-stop tool for data science.

The Get VS Code page in the Neural Data Science textbook has detailed instructions on how to instal the app and useful extensions.

Precursor installs

  1. Install Xquartz from https://www.xquartz.org

  2. Open the Terminal app (in Applications/Utilities) and install Xcode command line tools: xcode-select --install

Install Python using mamba

You may be familiar with Anaconda, as it's widely used — including in the Neural Data Science course. The install we do here is much smaller than all the files you would get if you installed Anaconda. but if you already have Anaconda, you can skip this step and go to Create a NCIL Python Environment.

Mamba (formerly known as conda) is an open-source package manager that allows you to install Python (and R), and all of the packages that you need to go with it. This is a much superior way of installing and managing Python than most of your other options. The mamba package manager tool will check for "dependencies" when you install Python packages, meaning that it ensures that all of the packages you install are versions that will work properly with each other.

Mamba also allows you to create multiple Python environments. An environment is a set of Python pacakges; so you can create different environments for, say, different versions of Python, or for different tasks. In general, you will probably only need one environment, and instructions for setting that up are below.

Intel Macs

Unless you have a newer Mac with an M1 or M2 processor, download Anaconda python from https://www.anaconda.com/download/#macos

  1. Get the most current version (whose number starts with 3. )

  2. Run the installer after it downloads

  3. This will install virtually all the basic Python packages you need for data science; however it will not install some of the specialized packages (like MNE) that we use in NCIL. Instructions for doing this come later.

Apple Silicon (M1, M2, etc. processors)

The default Anaconda installer doesn't (yet) install a version optimized for Apple Silicon. Instead, do the following:

  1. Download the miniforge installer for Apple silicon using this link (if it doesn't work, go to this page and find it).

  2. This will download a shell script — a kind of program you can run to do the install

  3. Open a Terminal and cd to your Downloads folder. Then run the following commands:

    • chmod +x ./Miniforge3-MacOSX-arm64.sh

    • bash ./Miniforge3-MacOSX-arm64.sh

    • You will need to accept the license agreement and specify where the package installs (your home folder is a good place)

Create a NCIL Python Data Science Environment

Anaconda allows you to create dedicated "environments", which are sets of Python packages. You coul do this, e.g., to have multiple different versions of Python (or packages) on your computer at the same time. In our case, creating an environment provides a convenient way to install all the extra Python packages you need for NCIL workflows at once.

Go to https://github.com/NeuroCognitiveImagingLab/NCIL_data_science_environments You can either click on the "Code" button and "download ZIP" (or clone the repo if you already know. how to use GitHub), or click on the ncil.yml file and copy & paste the contents into a new file on your computer.

The instructions for creating the conda (aka mamba) environment are in the GitHub repository README, so follow those.

R (no need to do this)

The NCIL data science environment you installed above includes R as well. These instructions are kept for now, just in case there are issues.

Intel Macs

  1. Get and run the installer from http://mirror.its.dal.ca/cran/

Apple Silicon

  1. Get and run the installer from http://mirror.its.dal.ca/cran/

    Ensure you scroll down and download the version with "arm" in the filename.

  2. In a Terminal, run the following two commands. These will install linear algebra libraries that will make your R code (especially linear mixed effects) orders of magnitude faster:

  • cd /Library/Frameworks/R.framework/Resources/lib/

  • ln -s -i -v libRblas.vecLib.dylib libRblas.dylib

Install Additional R Packages

Open a Terminal and type a capital R then Enter, to run R (this will not work in the R app or Rstudio)

  • At the R command prompt (>), enter the following commands (per https://irkernel.github.io/installation/), hitting Enter after each:

    • install.packages(c('IRkernel','repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'), repos='http://mirror.its.dal.ca/cran')

    • IRkernel::installspec()

    • install.packages(c('tidyverse','lme4','mgcv','itsadug','ggthemes','ez','car','likert','lattice','viridis','sjPlot','sjstats','ggeffects','emmeans','FactoMineR','party', 'psycho', 'partykit','randomForest','reshape2','see','arrow','caret','RANN','e1071','corrplot','ranger','githubinstall','stablelearner', 'languageserver', 'httpgd', 'stargazer'), repos='https://mirror.csclub.uwaterloo.ca/CRAN/')

Running Python and R in Jupyter Lab

  1. You should be good to go! You can launch Jupyter Lab and run both Python & R in Jupyter notebooks, by opening a Terminal window and running the command jupyter lab

Pro tip: You may find it easier to start jupyter lab in the folder that you want to work in (i.e., where your files are).

In the Terminal/Anaconda Prompt type cd followed by a space ('cd' means 'change directory'), then drag and drop the folder you want to go to into the Terminal window, then hit Enter.

Last updated