There are some awesome tutorials out there -- the info dump here is no way meant to substitute those. The pages here are more oriented towards Q&A and little info bytes I've found particularly helpful.
Check out the Brain Imaging Data Structure (BIDS) standard on suggestions on how to organize your MRI data and associated files and support ease of data sharing.
Things I learned the hard way:
Always keep an untouched copy of your original data in its organized state (e.g. after having converted
You should in general always follow the coding practice of modularity, and here that means not only writing your scripts as separate files, but also modularize your scripts by the different steps even within preprocessing, and label the scripts in the order you would run them.
Motivations
Some steps take forever and you will expect needing to run different steps several times with minor tweaks, so better to run only the particular step you intend to run
For example, you could have a convention like <studyID>_<order#>_<descripCat>_<finerDescrip> for naming your separate scripts (note: in some platforms, you cannot start files with a number, hence it is handy to have a study ID prefix.
a configuration file for variables (paths, which subjects to run, your image parameters) that you reuse for each of the stages
Number your scripts in the order you would run them helps (me at least) in organizing them
For an intro to MRI physics, beautifully explained, check out the lecture series by neuroradiologist Prof. Michael Lipton at the Albert Einstein College of Medicine -- all 56 lectures on YouTube (textbook Totally Accessible MRI out, too -- and he makes MRI physics exactly that: accessible):
= size of space covered by a slice in mm^3
= (x voxel size in mm * x image size in voxels) * (y voxel size in mm * y image size in voxels) * (z voxel size in mm * z image size in voxels)
to find it in SPM: [bb,vx]=spm_get_bbox('img.nii')
MRI scanner accessory that houses the radio frequency (RF) receivers (antennae). The number of channels correspond to the number of receivers, e.g. a 32-channel head coil has 32 RF receivers (head coils have receivers on the base on which the head rests and the top part that clicks into space, with different arrangements -- in 32-channel head coils, the receivers are probably physically looped to maximize being able to separate signal from simultaneously acquired slices).
shorter TE means move across k-space faster
K-space is a 2-D matrix of spatial frequencies derived from the MRI signal, where each unique spatial frequency (intensity and phase, stored as a complex number) corresponds to every pixel in the image (use Fourier transform to map the spatial frequencies to physical spatial locations, i.e. reconstructing the image). How these spatial frequencies are ordered does not matter -- if Cartesian, then left side of each row is the spatial frequency early during the echo, and the right side of each row at the end. Because the signal is highest in the center of the echo, the middle of each row of the k-space matrix has the highest values. In 2D Fourier Transform imaging, each row corresponds to an applied phase-encoding gradient. Spacing in k-space reflects the field-of-view (the extent of the image).
k is the convention for spatial frequency or wavenumber in the natural sciences (k = 1 / lambda, where lambda = wavelength), or the number of waves per given unit of distance. The American Society of Spectroscopy proposed the unit for wavenumber to be the kayser (K), where 1 K = 1 cm^-1 after German physicist Heinrich Kayser. The unit never caught on but referring to spatial frequency/wavenumber as k stuck.
The center of the k-space plot is at time 0, when there was no dephasing/phase shifts for phase encoding -- all the other points on the plot reflect the signal amplitude when phase shifts have become, which means there are more frequencies in the signal => some frequencies of the signal will cancel each other out => smaller amplitude => darker
Learn more about k-space on the mriquestions.com as explained by radiologist Dr. Allen Elster (very clear and pedagogically strong explanations of everything MRI related; always offered in basic and more advanced versions). Also get his explanation as to why the MRI signal is already ready for k-space (teaser: because we perturb the main magnetic field B0 and create magnetic gradients, we can localize signal).
Also perhaps helpful is xrayphysics.com's MRI simulation and explanations about k-space.
What we need to do to keep track of what signal came where --
select a slice (for each slice/2D image of the volume we're measuring, we need to:)
phase encoding (apply phase-encoding gradient along one axis, usually the y-axis, which then allows us to identify the row in k-space we're on)
frequency encoding (=readout; apply phase-encoding gradient along another axis, usually the x-axis -- now we know which column in k-space)
helps form an echo
xrayphysics.com has little interactive graphics showing phase encoding and frequency encoding
As images are 3D, we have to keep track of the system we use to describe how we represent a location in an image and how that maps onto the real live object that the image represents.
Usually (not always in older files), the NII header has info on how to map voxel coordinates to real-world/anatomically meaningful coordinates.
Voxel coordinates are conventionally represented as image voxels and referred to as (i, j, k) coordinates and are the indices of the matrix representing the image (each element in the matrix being a voxel). The coordinates refer to the center of the voxel.
Real-world/anatomically meaningful coordinates are (x, y, z) oordinates and are in units of mm.
Earlier NII files do not necessarily contain this mapping, but most NII headers contain 1 or 2 matrices (qform, sform) encoding this mapping -- but note that different MRI visualization/analysis tools may read/modify different matrices differently.
Why two matrices?
qform
"q" as the transformation matrix can be represented as a quaternion, i.e. 4-uple
mapping specifying in-plane scaling, rotation, shift
better representation for mapping between image coordinates to position in magnet bore (magnet coordinates),
i.e. [x_img, y_img, z_img, 1]' * [4x4 qform matrix] = [x_mag, y_mag, z_mag, 1]'
sform
mapping allowing scaling and shearing
better representation for aligning to a standard reference/template
If a qform/sform matrix exists, there is a code (qform_code, sform_code) that is saved with the matrix in the NII header:
0 = transformation never has been set
1 = transformation into magnet coordinates
3 = transformation into Talairach coordinates
Check out Justin Gardner's informative page detailing the role of both qform and sform (and why aligning images is important especially when images have been acquired in different sessions).
The convention for both matrices is
+x = Right (x-coordinate increases as we move anatomically towards the right)
+y = Anterior (y-coordinate increases as we move anatomically towards the front/more anteriorly)
+z = Superior (z-coordinate increases as we move anatomically towards the top/more superiorly)
In short-hand, we would say the orientation of an image file is "RAS+". The + is is not always written, but it removes the ambiguity that the letters represent the target direction where the coordinates become more positive -- although this orientation labeling has become standard, before the time when this convention became more or less universal, some people were following the opposite convention, namely that that the letters represented the SOURCE and not the target (and that's why sometimes you will also see "RAS-") -- this ambiguity can be disastrous because LEFT vs. RIGHT can be erroneously swapped and go undetected. In terms of whether it is "+" or "-" depends on the qform/sform code (if positive, then "normal").
"Anatomical" means the LEFT side of an image is anatomically the LEFT.
"Radiological" means the LEFT side of an image is anatomically the RIGHT (back in the day when X-ray films, being negatives,
One sanity check if you are uncertain which side of an image is anatomically LEFT, in an axial/horizontal slice, the left visual cortex tends to be larger than the right in most people.