---
# System prepended metadata

title: ACPC path

---

# ACPC path

**ACPC alignment steps performed for T1w and T2w**
*Step 1: Register cropped T1/2 to MNI template*
`flirt -interp spline -ref INFANT_MNI_T1_1mm.nii.gz -in cropped/T1w/sub-<>_0000.nii.gz -omat resized/ACPC_align/T1w_crop2acpc.mat -searchrx -45 45 -searchry -30 30 -searchrz -30 30`

*Step 2: Invert crop matrix and concatenate w/ MNI registration matrix*
`convert_xfm -inverse cropped/T1w/crop2full.mat -omat resized/ACPC_align/T1w_full2crop.mat`

`convert_xfm -omat resized/ACPC_align/T1w_full2acpc.mat -concat resized/ACPC_align/T1w_crop2acpc.mat resized/ACPC_align/T1w_full2crop.mat`

*Step 3: Convert crop+MNI registration matrix to rigid body*
`aff2rigid resized/ACPC_align/T1w_full2acpc.mat resized/ACPC_align/T1w_acpc2rigidbody.mat`

*Step 4: Apply rigid body matrix to average T1/2*
`applywarp --rel --interp=spline -i averaged/sub-<>_0000.nii.gz -r INFANT_MNI_T1_1mm.nii.gz --premat=resized/ACPC_align/T1w_acpc2rigidbody.mat -o resized/ACPC_align/ACPC_aligned_T1w.nii.gz`

**Register ACPC-aligned T2w to ACPC-aligned T1w**
`flirt -ref resized/ACPC_align/ACPC_aligned_T1w.nii.gz -in resized/ACPC_align/ACPC_aligned_T2w.nii.gz -omat resized/ACPC_align/cropT2tocropT1.mat -out resized/ACPC_align/ACPC_T2w_registered_to_T1w.nii.gz -cost mutualinfo -searchrx -15 15 -searchry -15 15 -searchrz -15 15 -dof 6`

**T1w: apply final matrix to average T1w**
*Step 1: Copy T1w_acpc2rigidbody.mat to crop_T1w_to_BIBS_template.mat*
*Step 2: Apply crop_T1w_to_BIBS_template.mat to average T1 to make preBIBSnet_final_0000.nii.gz*
**NOTE THAT THIS STEP IS REDUNDANT WITH STEP 4 ABOVE**
`applywarp --rel --interp=spline -i averaged/sub-<>_0000.nii.gz -r INFANT_MNI_T1_1mm.nii.gz --premat=resized/ACPC_align/crop_T1w_to_BIBS_template.mat -o resized/ACPC_align/preBIBSnet_final_0000.nii.gz`

**T2w: apply final matrix (including T2-T1 registration) to average T2w**
*Step 1: Concatenate ACPC-aligned T2w rigid body matrix to T2-to-T1 registration mat to make T2w_to_rigidbody.mat*
`convert_xfm -omat resized/ACPC_align/T2w_to_rigidbody.mat -concat resized/ACPC_align/cropT2tocropT1.mat resized/ACPC_align/T2w_acpc2rigidbody.mat`
*Step 2: Copy T2w_to_rigidbody.mat to crop_T2w_to_BIBS_template.mat*
*Step 3: Apply crop_T2w_to_BIBS_template.mat to average T2 to make preBIBSnet_final_0001.nii.gz*
`applywarp --rel --interp=spline -i averaged/sub-<>_0001.nii.gz -r INFANT_MNI_T2_1mm.nii.gz --premat=resized/ACPC_align/crop_T2w_to_BIBS_template.mat -o resized/ACPC_align/preBIBSnet_final_0001.nii.gz`