Windows

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.

Simply google "install VS code" and you will get the download link and instructions.

Anaconda Python

Anaconda 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. In particular, the conda 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.

Anaconda 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.

Important: After installing Anaconda on Windows, you need to find and run the Anaconda Prompt application in order for it to work from a command line. It will not work if you open any other Windows shell — you will instead be runnign some other version of Python, not have access to all the right packages, and generally be confused and frustrated. You can also run the main Anaconda GUI application.

Create a NCIL Python Data Science Environment

Anaconda allows you to create dedicated "environments", which are sets of Python packages. You could 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.

Install R

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

  2. Hit the Windows key and type envir - at this point it should pop up an option to ‘Edit the system environment variables’. Click on this (not 'Edit environment variables for your account).

    • You will see a system properties window, and near the bottom it has a button that says “Environment variables”. Click this button.

    • In the window that comes up, Double-click ‘Path’ in the ‘System variables’ section (NOT ‘User variables’). Then click “New” and enter the following:

      • C:\Program Files\R\R-4.3.0\bin\x64

      • (note that in the above, R-4.3.0 is the installed version of R. You will need to change the number to match whatever version you installed (which you can see by looking at the R installer app you downloaded - it updates faster than I can keep this file updated!)

    • Save/quit out of that series of windows for editing your environment variables

Install additional R packages

  • Open the newly-installed Anaconda Prompt as administrator (right-click on the app icon, then go to "more" , then run as Administrator)

When working on Windows, it's critical that you always use an Anaconda Prompt window and not a normal Windows shell to run Python, R, or Anaconda. The correct paths are only set in Anaconda Prompts; if you use a normal Windows shell some things might look like they're working, but ultimately you will have problems as not everything will be configured correctly

2. Run R from the command line in your Anaconda Prompt by typing:

R
  • Now, at the R prompt (>), run the following commands:

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 an Anaconda Prompt 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.

On Windows, if you want to switch to the NAS (server) to work, you need to know what letter the network drive is mapped to (see NCIL server access following the instructions here). This should show in File Explorer. To switch to the NAS drive, in the Anaconda Prompt window type the letter that the drive is mapped to, plus a colon. For example, if NCILNAS is mapped to W:, then you'd just type W: and hit enter

Last updated