registration_file = op.join(out_dir, 'ACPC2fsnative_register.dat')
# 1) Generate registration file .dat
cmd = ["bbregister",
"--s", participant,
"--sd", fs_path,
"--mov", template_file,
"--reg", registration_file,
"--init-fsl",
"--t1"
]
print("Running:", " ".join(cmd))
subprocess.run(cmd, check=True, env={**os.environ, "SUBJECTS_DIR": fs_path})
#2) Apply ACPC2fsNative registration and project density map to surface
hemisphere = ['L', 'R']
roi = ['LeftMTxWMxLGN', 'RightMTxWMxLGN']
for h, hemi in enumerate(hemisphere):
mask = roi[h]
density_map = op.join(analysis_path, 'tdi_maps', 'dipy_tdi_maps', participant, f"{participant}_ses-concat_desc-{mask}_tdi_map.nii.gz")
# density_img = nib.load(density_map)
# print(density_img.affine)
# Output file name
out_file = os.path.join(out_dir, f"{participant}_hemi-{hemi}_space-fsnative_label-{mask}_tdi_on_surf.mgh")
if hemi == 'L':
hm = 'lh'
else:
hm = 'rh'
# Build mri_vol2surf command
cmd = [
"mri_vol2surf",
"--mov", density_map,
"--regheader", participant,
"--hemi", hm,
"--reg", registration_file,
"--surf", "white",
"--projfrac", "0",
"--sd", fs_path,
"--out", out_file
]
# Run the command
print("Running:", " ".join(cmd))
subprocess.run(cmd, check=True, env={**os.environ, "SUBJECTS_DIR": fs_path})