#!/bin/bash

cd /mnt/c/Users/gargy/OneDrive/Desktop/7TAMI/cropped/

# 2.generate the affine matrix with flirt first:
flirt -in c7TAMI_T1w_30_cropped.nii \
      -ref $FSLDIR/data/standard/MNI152_T1_1mm_brain.nii.gz \
      -omat anat2mni_affine.mat

# 3. Run FNIRT
fnirt --in=c7TAMI_T1w_30_cropped.nii \
      --aff=anat2mni_affine.mat \
      --ref=$FSLDIR/data/standard/MNI152_T1_1mm_brain.nii.gz \
      --refmask=$FSLDIR/data/standard/MNI152_T1_1mm_brain_mask_dil.nii.gz \
      --config=T1_2_MNI152_2mm \
      --cout=anat2mni_warp \
      --iout=anat2mni_fnirt.nii.gz

# 4. Invert the warp
invwarp -w anat2mni_warp.nii.gz -o mni2anat_warp.nii.gz -r c7TAMI_T1w_30_cropped.nii
