Python - Neuroimaging Workshop Philipps Universitaet Marburg, September 2019

Python is on its way to become the most used programming language in neuroscience. It is easy to understand, can be learned rather quickly and has a very strong and helpful community behind it. There exist many amazing neuroimaging software packages, such as nilearn & fmriprep, that facilitate the everyday life of a neuroscientist.

The goal of this 2-day workshop is to introduce participants to the basics of Python, to give them a short overview about relevant neuroimaging software packages, including statistics, functional connectivity, DTI, machine/deep learning and Nipype. A special focus will be on the latter, as it's an open-source software package, that provides a unified way of interfacing with most of the freely available neuroimaging software packages, such as SPM, FSL, AFNI, FreeSurfer, and ANTs.

The full content of this course, all notebooks and slides can be found on the github repository

Important 1

If you're running this notebook through a docker container, make sure that you used the -v flag to mount a folder on your system inside the container. Like this, you will have access to any output that you create within this container. For more, take a look at the Docker information.

Important 2

If you used the -v flag from above to mount the output folder, you can use the following command to save all notebooks (with your changes) and slides in the folder /output/. Just don't forget to run this cell before closing the docker container!

In [ ]:
# Save the workshop and nipype_tutorial content into your output folder
!cp -R /home/neuro/* /output/
In [ ]:
# Get the saved notebook from the output folder back into this docker image
!cp -R /output/* /home/neuro/

Day 1


09:00-10:00 How to set up your system, using Conda and Docker

There are many ways to create the right computational environment for your research. But if you want to use the newest technologies you will not get around using Docker or Conda.

10:00-10:15 Coffee & Tea Break

10:15-11:00 Introduction to Python and Jupyter Notebooks

This section is meant as a quick introduction to Jupyter Notebooks and Python. What are they, how do they work and why are they so cool?

11:00-12:00 Crash course in scientific toolboxes

One advantage of Python is the vast availability of toolboxes. There's a toolbox for almost everything! In this section, we want to introduce you to the main scientific toolboxes that every researcher should know.

12:00-13:00 Lunch

Python & Neuroimaging

13:00-14:00 How to handle your MRI data with Nibabel and Nilearn

It's liberating to have direct access to your neuroimaging data. Nibabel and Nilearn allow exactly that. With those two neuroimaging packages, you can consider the brain a simple 3D/4D matrix of datapoints and do with it whatever you want.

14:00-14:15 Coffee & Tea Break

14:15-17:00 Crash course in neuroimaging software toolboxes & machine learning

There are many different ways to analyze MRI data and many different software to do so. In this section, we want to show you some neuroimaging toolboxes written in Python that allow you to do things like diffusion imaging (Dipy), functional connectivity (Nilearn) or machine learning (Nilearn/PyMVPA). This list is by no means exhaustive and we will speak about much more software tomorrow morning.

15:45-16:00 Coffee & Tea Break

Day 2 (morning) - Machine learning continued and everything about Nipype

09:00-10:30 Machine learning continued

In the first session of the second day, we'll continue with some more machine learning. To this end, we'll explore a new dataset and its analyses using three different software packages: nilearn, PyMVPA and Keras.

10:30-10:45 coffee break

10:45-11:00 Introduction to Nipype

In this short introduction, we will show you what Nipype is and why you should use it. It contains a powerful short example that shows the strength behind Nipype.

11:00-12:00 Building blocks of Nipype: Interfaces & Workflows

Nipype can be learned very quickly, but it's nonetheless important that you know about some of the main building blocks.

12:00-13:00 Lunch

Day 2 (afternoon) - Nipype Hands-On

Use what you've learned!

The goal of this afternoon is that you get your hands dirty with Nipype. For this purpose, you will work on the Hands-on example from the Nipype Tutorial. It contains a complete task-based fMRI analysis, including pre-processing, 1st-level and 2nd-level analysis.

The goal of this hands-on is to show you a real case example of a pre-processing and analysis pipeline with Nipype. Don't hesitate to ask us if you have questions. And feel free to create your own pipeline from scratch if you want. We're happy to help you to get things going.

Important: Don't forget to use the -v flag to run the docker container. Like this, you will have access to changes in the notebook and possible output that you want to keep.

13:00-14:30 Pre-processing Hands-on

Note: Coffee & Tea break can be taken at any time during this lecture.

14:30-15:30 Analysis Hands-on

Note: Coffee & Tea break can be taken at any time during this lecture.

15:30-17:00 New innovations in the field

There are many new and innovative neuroimaging resources & softwares, such as BIDS, fmriprep, MRIQC, OpenNeuro, etc. And many of them wouldn't be possible without Nipype and the open-source neuroimaging community. In this section, we want to introduce you to some toolboxes. Because if you don't use them yet yourself, it's at least important that you've already heard about them.