240 likes | 263 Views
Learn how to clean up small motions and bring data into alignment for fMRI analysis using the AFNI software. Includes examples and solutions for inter-session alignment.
E N D
Intra-Subject Inter-Session Image Alignment for FMRI — the AFNI way Robert W. Cox NIMH / NIH / PHS / HHS
The Needs • Intra-scan / intra-session • Need to clean up small motions that produce signal changes which interfere with signal detection • Inter-session [same subject] • Need to bring data into alignment vs. larger motions, so can compare and contrast on a voxel-wise basis • Inter-subject [not discussed today] • Need to change brain shape/size to make subjects match (in some sense)
Intra-Session: EPI-to-EPI • Align 3D volumes based on matching signal intensities at each voxel • Find 6 rigid-body movement parameters for each volume (1 per TR) • Program 3dvolreg • Tries to match volumes on a weighted least-squares basis, using “gradient descent” (walk downhill) • Designed to find small movements; fast algorithm
+ Example of Intra-Session Motion t = 165 s again t = 170 s again
+ Example of Inter-Session Motion Day 1 Day 2 Day 3
The Need for Resampling (i.e., Interpolation) • Have data at horizontal- • vertical grid intersections • Need data on slanted • grid, at solid dots • Regions around pink • dots show original grid • areas we might use to • compute resampled • image values • Resampling usually • corrupts data, so should • not be done repeatedly
Intra-Session: EPI-to-SPGR • AFNI assumes xyz-coordinates (in mm, from scanner) are matched for datasets in same session (directory) • xyz-position of each 3D dataset is entered in program to3d [the centering controls] • Can interactively adjust position of SPGR with help of the Nudge Dataset plugin • Should use EPI closest in time to SPGR as base for EPI-to-EPI alignment
Inter-Session Alignment: The AFNI Way • Use 3dvolreg to align SPGRs between sessions • -twopass option is for finding larger movements • Rotation+shift parameters are stored in header of aligned SPGR for later use (the –rotparent option) • Use 3drotate or 3dvolreg to apply the same rotation+shift to EPI (or functional) data to bring from session 2 to session 1 • Follows AFNI basic assumption: xyz-coordinates of EPI and SPGRs are aligned • Can force output to lie on same grid as EPI from session 1, so that voxel-wise comparisons can be made (the -gridparent option)
Diagrammatically S1 S2 3dvolreg to3d to3d E1 E2 3dvolreg or 3drotate
Issues in Inter-Session Alignment • Subject’s head will be positioned differently • In orientation (rotation) and position • xyz-coordinates & anatomy don’t correspond • Anatomical coverage of EPI slices will differ • Geometrical relation between EPI & SPGR differs (i.e., xyz coordinate offsets aren’t same) • Slice thickness may vary between sessions (naughty naughty naughty)
Anatomical Coverage Differs— In the Scanner EPI slice package Day 1 Day 2 Same voxels aren’t same tissue
Anatomical Coverage Differs— After Rotation to Same Orientation Day 1 Day 2
+ Anatomical Coverage Differs— After Clipping to Day 2 xyz-Grid Day 1 Day 2 Same voxels still aren’t same tissue: – because EPI grids differed in xyz– need to shift Day 2 upwards
Another Coordinate problem:3drotate Occurs Around Center of Individual 3D Datasets EPI & SPGR before rotation
need to shift left Another Coordinate problem:3drotate Occurs Around Center of Individual 3D Datasets Rotate EPI & SPGR about SPGR center Rotate EPI & SPGR about individual centers Good: Bad:
Solutions to these Woes • Coordinate problems: • Add appropriate shift to E2 on top of rotation • Allow for xyz shifts between days (E1–E2), center shifts between EPI and SPGR (E1–S1 and E2–S2) • Derive using the matrix-vector algebra of 3D motion • Non-overlap problems: • Pad EPI datasets with extra slices of zeros so that aligned datasets can fully contain all regions • Zero padding can be done in to3d or 3dZeropad • 3dvolreg & 3drotate can zero pad to match a “grid parent” dataset
+ Day 1’s coverage Zero pad Anatomical Coverage Differs— The Need for Zero Padding Day 1 Day 2
S1 S2 E1 E2 Recipe • Create datasets with correct geometry! • Compute S2-to-S1 transformation: • 3dvolreg -twopass -twodup -clipit -zpad 4 -base S1+orig -prefix S2reg S2+orig • Rotation/shift parameters saved in S2reg+orig.HEAD • If not done before (in to3d), zero pad E1 datasets: • 3dZeropad -z 4 -prefix E1pad E1+orig • Register E1 datasets within the session: • 3dvolreg -clipit -base ’E1pad+orig[4]’ -prefix E1reg E1pad+orig
S1 S2 E1 E2 Recipe (continued) • Register E2 datasets within session • Correction for intra-scan head movements • At same time, execute larger rotation+shift to session 1 • Thereby avoiding repeated resampling • 3dvolreg -clipit -base ’E2+orig[4]’ -rotparent S2reg+orig -gridparent E1reg+orig -prefix E2reg E2reg+orig -rotparent is where the rotation+shift to session 1 comes from -gridparent defines output grid location of new dataset
S1 S2 E1 E2 Recipe (concluded) • -gridparent will shift and zeropad output dataset as needed to lie on top of E1reg+orig • Operating in this way means that datasets are only resampled once in going from session 2 un-registered to session 1 registered • It will not properly allow for different slice thicknesses between sessions! • In fact, 3dvolreg now rejects trying to match datasets with different grid spacings • Program 3dZregrid can be used to resample a dataset onto a different slice thickness [reasonability is open to question]
Recipe (addendum) 1 4 • AFNI stores slice-dependent time shifts in the dataset header file • After interpolation to a rotated grid, voxel values can no longer be said to come from a particular time offset, since data from different slices will have been combined • Before this interpolation, makes sense to time shift dataset to a common temporal origin • Use program 3dTshift, or-tshiftoption to 3dvolreg 2 5 3
S1 S2 E1 E2 Why Is This Relatively Clumsy? • AFNI is organized around individual datasets • One or more 3D arrays of numbers (sub-bricks) collected into a single file • Inter-session processing is a higher level of organization, requiring interaction between multiple files • To make it simpler will require imposing more structure into the storage, naming, and retrieval of datasets
Desiderata • Automated program to adjust EPI-to-SPGR coordinate offsets • e.g., Find shift that yields maximal overlap between EPI and “scalped” SPGR (3dIntracranial) — either volumetrically or at the brain surface • EPI reconstruction that corrects for gradient nonlinearity and static field inhomogeneity • Both of which distort images, making EPI-SPGR alignment problematic (manual or automated) • Scripts to semi-automate these procedures • Ziad Saad has developed some for his own purposes
Ziad Saad [FIM / LBC / NIMH] Michael Beauchamp [FBI / LBC / NIMH] For sample data, beta testing, and pointing out many of the problems Sally Durgerian [Neurology / MCW] For sample data and beta testing Thanks To