\(\newcommand{L}[1]{\| #1 \|}\newcommand{VL}[1]{\L{ \vec{#1} }}\newcommand{R}[1]{\operatorname{Re}\,(#1)}\newcommand{I}[1]{\operatorname{Im}\, (#1)}\)

# Course material by topic¶

This is an arrangement of the material for the course by topic, rather than by teaching day.

## Python¶

- Brisk introduction to Python. See Introduction, Python, images;
- “for” and “while”, “break” and “else:”;
- Modules and scripts;
- Packages and namespaces;
- List comprehensions;
- Two double underscore variables;
- String literals in Python;
- Inserting values into strings;
- Docstrings;
- Kind-of True;
- Using assert for testing;
- Keyword arguments;
- Making and breaking file paths in Python. See: Git / github workflow, the Python path;
- Where does Python look for modules?. See: Git / github workflow, the Python path;
- Using PYTHONPATH;
- Python coding style.

## Numpy, arrays and images¶

- What is an image?. See Introduction, Python, images;
- NumPy introduction (from scipy lecture notes (SLN);
- numpy array object (SLN);
- array operations (SLN). See: Basic numpy exercises;
- Array reduction operations;
- Arrays as images, images as arrays. See: Arrays, images and plotting;
- Reshaping and three-dimensional arrays. See: Arrays, images and plotting;
- Index ordering and reshape in NumPy and MATLAB;
- Working with four dimensional images, masks and functions. See: 4D arrays, time series and diagnostics;
- Reshaping, 4D to 2D;
- Logical operations on boolean arrays;
- Reshaping 4D images to 2D arrays;
- Slicing with boolean vectors. See: Correlation, regression, statistics on brain images;
- Indexing with boolean masks.
- Vector and matrix dot products, “np.outer”;
- Testing for near equality with “allclose”;
- Numpy arange;
- Methods vs functions in NumPy;
- Subtracting the mean from columns or rows;
- Adding length 1 dimensions with newaxis;
- Diagonal matrices;
- numpy.tranpose for swapping axes;
- Random numbers with np.random;
- Removing length 1 axes with numpy.squeeze;
- Making coordinate arrays with meshgrid;
- Comparing arrays;
- Comparing floats and floating point error;
- Making floating points numbers print nicely.

## Git¶

Exercises:

## General statistics and math¶

- algebra of sums;
- vectors and dot products;
- vector projection;
- introduction to Principal Component Analysis. See: Vectors, projection and PCA;
- vector angles;
- correlation and projection. See Correlation, regression, statistics on brain images;
- matrix rank
- Inverse of a diagonal matrix;
- introduction to the General Linear Model. See Exploring the general linear model;
- cumulative density functions;
- A worked example of the general linear model;
- Subtracting the mean from a vector;
- Hypothesis tesing with the general linear model;
- tutorial on correlated regressors.
- tutorial on convolution.

## Image processing and spatial transformations¶

- Otsu’s method for binarizing images.
- rotation in 2D;
- Rotations and rotation matrices;
- Encoding zooms (scaling) with a diagonal matrix;
- coordinate systems and affine transforms;
- mutual information;
- The nibabel.affines module;
- Applying coordinate transforms with nibabel.affines.apply_affine.
- Resampling with scipy.ndimage;
- General resampling between images with scipy.ndimage.map_coordinates;
- Making and saving new images in nibabel;
- introduction to smoothing;
- smoothing as convolution.
- optimizing spatial transformations.

## Specific to FMRI¶

- Voxel time courses. See Correlation, regression, statistics on brain images;
- Modeling a single voxel;
- Convolving with the hemodyamic response function.
- Coordinate systems and affine transforms;
- The nibabel.affines module;
- Applying coordinate transforms with nibabel.affines.apply_affine;
- Sometimes, the NIfTI image stores the TR in the header;
- Registration with dipy and the Anterior cingulate exercise;
- Introducing nipype;
- See also: SPM slice timing exercise; Scripting of SPM analysis with nipype exercise.