Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3d7fa0e
Replace regSynth with LAMAReg as default cross-modality registration
zihuaihuai Nov 5, 2025
b2406c4
Update micapipe_snakebids/config/snakebids.yml
zihuaihuai Nov 6, 2025
7ff3b7a
Update functions/03_MPC.sh
zihuaihuai Nov 6, 2025
fb31863
Update functions/03_MPC-SWM.sh
zihuaihuai Nov 6, 2025
64fa4be
Update functions/02_proc-dwi.sh
zihuaihuai Nov 6, 2025
a9766ba
Update functions/02_proc-dwi.sh
zihuaihuai Nov 6, 2025
fed9a0a
Update functions/02_proc-dwi.sh
zihuaihuai Nov 6, 2025
4dc39fe
Add secondary warpfield support for LAMAReg two-stage registration
zihuaihuai Nov 6, 2025
0430f1c
Add documentation for LAMAReg two-stage registration update
zihuaihuai Nov 6, 2025
e4f7f6e
Add comprehensive LAMAReg registration test suite
zihuaihuai Nov 6, 2025
c471746
Add complete project summary for LAMAReg integration
zihuaihuai Nov 6, 2025
ebf9010
Add guide for finding and preparing test data
zihuaihuai Nov 6, 2025
405bed7
Add HCP-specific test data setup script
zihuaihuai Nov 10, 2025
56b8a10
Fix run_all_tests.sh to properly handle test exit codes
zihuaihuai Nov 10, 2025
d035544
Fix run_all_tests.sh to use correct subdirectory paths
zihuaihuai Nov 10, 2025
970af01
Add diagnostic script to find available test files
zihuaihuai Nov 10, 2025
172b1a9
Fix setup script to use correct HCP file paths
zihuaihuai Nov 10, 2025
e111ce6
Fix setup script to find functional data in nested directories
zihuaihuai Nov 10, 2025
4a8ee0c
Enable actual LAMAReg execution in all tests
zihuaihuai Nov 10, 2025
84a07bf
Fix DWI test to actually execute LAMAReg command
zihuaihuai Nov 10, 2025
f133122
Remove set -e from DWI test to prevent silent exits
zihuaihuai Nov 10, 2025
dbb8662
Fix echo -e compatibility issues in DWI test
zihuaihuai Nov 10, 2025
75d072c
Simplify test_dwi_registration.sh: remove set -e, remove color codes,…
zihuaihuai Nov 10, 2025
e9f67ce
Major improvements to test_common.sh for better test reliability and …
zihuaihuai Nov 10, 2025
7d7db03
Fix DWI test: Use 3D image instead of 4D FOD for LAMAReg/SynthSeg
zihuaihuai Nov 10, 2025
6298f04
Update JSON metadata to reflect LAMAReg registration method
zihuaihuai Nov 10, 2025
acced46
Add dwi_fod_vol0.nii.gz to test script detection priority
zihuaihuai Nov 10, 2025
6a074a2
Fix run_all_tests.sh and add configurable threading (default 16 threads)
zihuaihuai Nov 10, 2025
92b3cb1
Update testing guide with run_all_tests.sh usage and threading info
zihuaihuai Nov 10, 2025
5f01d7e
Fix DICE score parsing to handle CSVs without headers
zihuaihuai Nov 11, 2025
1d575e8
Fix DICE score parsing - simplified and tested
zihuaihuai Nov 11, 2025
049589b
Add comprehensive integration completion notes and summary
zihuaihuai Nov 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 33 additions & 38 deletions functions/02_proc-dwi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ dwi_main=$8
dwi_rpe=$9
dwi_processed=${10}
rpe_all=${11}
regAffine=${12}
dwi_str=${13}
b0thr=${14}
bvalscale=${15}
synth_reg=${16}
dwi_upsample=${17}
PROC=${18}
dwi_str=${12}
b0thr=${13}
bvalscale=${14}
dwi_upsample=${15}
PROC=${17}
here=$(pwd)

#------------------------------------------------------------------------------#
Expand All @@ -54,10 +52,8 @@ Note "dwi_main :" "$dwi_main"
Note "dwi_rpe :" "$dwi_rpe"
Note "rpe_all :" "$rpe_all"
Note "dwi_acq :" "$dwi_str"
Note "Affine only :" "$regAffine"
Note "B0 threshold :" "$b0thr"
Note "bvalue scaling:" "$bvalscale"
Note "synth_reg :" "${synth_reg}"
Note "dwi_upsample :" "${dwi_upsample}"
Note "Processing :" "$PROC"
Note "Saving temporal dir :" "$nocleanup"
Expand Down Expand Up @@ -500,35 +496,34 @@ if [[ ! -f "$dwi_SyN_warp" ]] || [[ ! -f "$dwi_5tt" ]]; then N=$((N + 2))
T1nativepro_in_dwi_brain="${tmp}/${idBIDS}_space-dwi_desc-T1w_nativepro-brain.nii.gz"
Do_cmd fslmaths "$T1nativepro_in_dwi" -mul "$dwi_mask" "$T1nativepro_in_dwi_brain"

if [[ ${regAffine} == "FALSE" ]]; then
Info "Non-linear registration from T1w_dwi-space to DWI"
T1nativepro_in_dwi_NL="${proc_dwi}/${idBIDS}_space-dwi_desc-T1w_nativepro_SyN.nii.gz"
if [[ "${synth_reg}" == "TRUE" ]]; then
Info "Running label based non linear registrations"
b0_synth="${tmp}/b0_synthsegGM.nii.gz"
T1_synth="${tmp}/T1w_synthsegGM.nii.gz"
Do_cmd mri_synthseg --i "${T1nativepro_in_dwi}" --o "${tmp}/T1w_synthseg.nii.gz" --robust --threads "$threads" --cpu
Do_cmd fslmaths "${tmp}/T1w_synthseg.nii.gz" -uthr 42 -thr 42 -bin -mul -39 -add "${tmp}/T1w_synthseg.nii.gz" "${T1_synth}"

Do_cmd mri_synthseg --i "$dwi_b0" --o "${tmp}/b0_synthseg.nii.gz" --robust --threads "$threads" --cpu
Do_cmd fslmaths "${tmp}/b0_synthseg.nii.gz" -uthr 42 -thr 42 -bin -mul -39 -add "${tmp}/b0_synthseg.nii.gz" "${b0_synth}"

# Affine from func to t1-nativepro
Do_cmd antsRegistrationSyN.sh -d 3 -m "$T1_synth" -f "$b0_synth" -o "$dwi_SyN_str" -t s -n "$threads"
else
Info "Running volume based affine registrations"
Do_cmd antsRegistrationSyN.sh -d 3 -m "$T1nativepro_in_dwi_brain" -f "$fod" -o "$dwi_SyN_str" -t s -n "$threads"
fi
export reg="Affine+SyN"
trans_T12dwi="-t ${dwi_SyN_warp} -t ${dwi_SyN_affine} -t [${mat_dwi_affine},1]" # T1nativepro to DWI
trans_dwi2T1="-t ${mat_dwi_affine} -t [${dwi_SyN_affine},1] -t ${dwi_SyN_Invwarp}" # DWI to T1nativepro
if [[ -f "$dwi_SyN_warp" ]]; then ((Nsteps++)); fi

elif [[ ${regAffine} == "TRUE" ]]; then
Info "Only affine registration from T1w_dwi-space to DWI"; ((Nsteps++))
T1nativepro_in_dwi_NL="${proc_dwi}/${idBIDS}_space-dwi_desc-T1w_nativepro_Affine.nii.gz"
trans_T12dwi="-t [${mat_dwi_affine},1]"
trans_dwi2T1="-t ${mat_dwi_affine}"
Info "Non-linear registration from T1w_dwi-space to DWI with LAMAReg"
T1nativepro_in_dwi_NL="${proc_dwi}/${idBIDS}_space-dwi_desc-T1w_nativepro_SyN.nii.gz"

# LAMAReg registration with robust two-stage approach
dwi_SyN_output="${dwi_SyN_str}Warped.nii.gz"
dwi_fixed_parc="${dwi_SyN_str}_fixed_parc.nii.gz"
dwi_moving_parc="${dwi_SyN_str}_moving_parc.nii.gz"
dwi_registered_parc="${dwi_SyN_str}_registered_parc.nii.gz"
dwi_qc_csv="${dwi_SyN_str}_dice_scores.csv"

Do_cmd lamareg register \
--moving "${T1nativepro_in_dwi_brain}" \
--fixed "${fod}" \
--output "$dwi_SyN_output" \
--moving-parc "$dwi_moving_parc" \
--fixed-parc "$dwi_fixed_parc" \
--registered-parc "$dwi_registered_parc" \
--affine "${dwi_SyN_affine}" \
--warpfield "${dwi_SyN_warp}" \
--inverse-warpfield "${dwi_SyN_Invwarp}" \
--qc-csv "$dwi_qc_csv" \
--synthseg-threads "$threads" \
--ants-threads "$threads"

export reg="LAMAreg"
trans_T12dwi="-t ${dwi_SyN_warp} -t ${dwi_SyN_affine} -t [${mat_dwi_affine},1]" # T1nativepro to DWI
trans_dwi2T1="-t ${mat_dwi_affine} -t [${dwi_SyN_affine},1] -t ${dwi_SyN_Invwarp}" # DWI to T1nativepro
if [[ -f "$dwi_SyN_warp" ]]; then ((Nsteps++)); fi
fi

Info "Registering T1w-nativepro and 5TT to DWI-b0 space, and DWI-b0 to T1w-nativepro"
Expand Down
40 changes: 28 additions & 12 deletions functions/02_proc-flair.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,36 @@ fi
#------------------------------------------------------------------------------#
### FLAIR registration to nativepro ###
if [[ ! -f "$flair_nativepro" ]]; then ((N++))
# Register nativepro and flair
str_flair_affine="${dir_warp}/${idBIDS}_from-flair_to-nativepro_mode-image_desc-affine_"
Info "Running label based affine registrations"
flair_synth="${tmp}/flair_synthsegGM.nii.gz"
T1_synth="${tmp}/T1w_synthsegGM.nii.gz"
Do_cmd mri_synthseg --i "${T1nativepro}" --o "${tmp}/T1w_synthseg.nii.gz" --robust --threads "$threads" --cpu
fslmaths "${tmp}/T1w_synthseg.nii.gz" -uthr 42 -thr 42 -bin -mul -39 -add "${tmp}/T1w_synthseg.nii.gz" "${T1_synth}"
fslmaths "${flair_synthseg}" -uthr 42 -thr 42 -bin -mul -39 -add "${flair_synthseg}" "${flair_synth}"

# Affine from func to t1-nativepro
Do_cmd antsRegistrationSyN.sh -d 3 -f "$T1_synth" -m "$flair_synth" -o "$str_flair_affine" -t a -n "$threads" -p d
# Register nativepro and flair with LAMAReg
str_flair_affine="${dir_warp}/${idBIDS}_from-flair_to-nativepro_mode-image_desc-LAMAReg_"
Info "Running LAMAReg registration"

# LAMAReg registration with robust two-stage approach
flair_SyN_output="${str_flair_affine}Warped.nii.gz"
flair_fixed_parc="${str_flair_affine}_fixed_parc.nii.gz"
flair_moving_parc="${str_flair_affine}_moving_parc.nii.gz"
flair_registered_parc="${str_flair_affine}_registered_parc.nii.gz"
flair_qc_csv="${str_flair_affine}_dice_scores.csv"
flair_affine_mat="${str_flair_affine}0GenericAffine.mat"
flair_warpfield="${str_flair_affine}1Warp.nii.gz"
flair_inv_warpfield="${str_flair_affine}1InverseWarp.nii.gz"

Do_cmd lamareg register \
--moving "${flair_preproc}" \
--fixed "${T1nativepro}" \
--output "$flair_SyN_output" \
--moving-parc "$flair_moving_parc" \
--fixed-parc "$flair_fixed_parc" \
--registered-parc "$flair_registered_parc" \
--affine "$flair_affine_mat" \
--warpfield "$flair_warpfield" \
--inverse-warpfield "$flair_inv_warpfield" \
--qc-csv "$flair_qc_csv" \
--synthseg-threads "$threads" \
--ants-threads "$threads"

# Apply transformations
Do_cmd antsApplyTransforms -d 3 -i "$flair_preproc" -r "$T1nativepro_brain" -t "$str_flair_affine"0GenericAffine.mat -o "$flair_nativepro" -v -u float
Do_cmd antsApplyTransforms -d 3 -i "$flair_preproc" -r "$T1nativepro_brain" -t "$flair_affine_mat" -o "$flair_nativepro" -v -u float
((Nsteps++))
else
Info "Subject ${id} T2-FLAIR is registered to nativepro"; ((Nsteps++)); ((N++))
Expand Down
79 changes: 36 additions & 43 deletions functions/02_proc-func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -554,19 +554,11 @@ str_func_SyN="${dir_warp}/${idBIDS}_from-nativepro_func_to-${tagMRI}_mode-image_
SyN_func_affine="${str_func_SyN}0GenericAffine.mat"
SyN_func_warp="${str_func_SyN}1Warp.nii.gz"
SyN_func_Invwarp="${str_func_SyN}1InverseWarp.nii.gz"
regAffine="FALSE"
if [[ ${regAffine} == "FALSE" ]]; then
# SyN from T1_nativepro to t1-nativepro
export reg="Affine+SyN"
transformsInv="-t ${SyN_func_warp} -t ${SyN_func_affine} -t [${mat_func_affine},1]" # T1nativepro to func
transform="-t ${mat_func_affine} -t [${SyN_func_affine},1] -t ${SyN_func_Invwarp}" # func to T1nativepro
xfmat="-t ${SyN_func_affine} -t [${mat_func_affine},1]" # T1nativepro to func only lineal for FIX
elif [[ ${regAffine} == "TRUE" ]]; then
export reg="Affine"
transformsInv="-t [${mat_func_affine},1]" # T1nativepro to func
transform="-t ${mat_func_affine}" # func to T1nativepro
xfmat="-t [${mat_func_affine},1]" # T1nativepro to func only lineal for FIX
fi
# Always use nonlinear registration with LAMAReg
export reg="LAMAreg"
transformsInv="-t ${SyN_func_warp} -t ${SyN_func_affine} -t [${mat_func_affine},1]" # T1nativepro to func
transform="-t ${mat_func_affine} -t [${SyN_func_affine},1] -t ${SyN_func_Invwarp}" # func to T1nativepro
xfmat="-t ${SyN_func_affine} -t [${mat_func_affine},1]" # T1nativepro to func only lineal for FIX

# Registration to native pro
Nreg=$(ls "$mat_func_affine" "$fmri_in_T1nativepro" "$T1nativepro_in_func" 2>/dev/null | wc -l )
Expand All @@ -575,24 +567,29 @@ if [[ "$Nreg" -lt 3 ]]; then ((N++))
voxels=$(mrinfo "${fmri_mean}" -spacing); voxels="${voxels// /,}"
Do_cmd flirt -applyisoxfm "${voxels}" -in "${T1nativepro_brain}" -ref "${T1nativepro_brain}" -out "${t1bold}"

Info "Registering func MRI to nativepro"
bold_synth="${tmp}/func_brain_synthsegGM.nii.gz"
t1_synth="${tmp}/T1bold_synthsegGM.nii.gz"
Do_cmd mri_synthseg --i "${t1bold}" --o "${tmp}/T1bold_synthseg.nii.gz" --robust --threads "$threads" --cpu
Do_cmd fslmaths "${tmp}/T1bold_synthseg.nii.gz" -uthr 42 -thr 42 -bin -mul -39 -add "${tmp}/T1bold_synthseg.nii.gz" "${t1_synth}"

Do_cmd mri_synthseg --i "$fmri_brain" --o "${tmp}/func_brain_synthseg.nii.gz" --robust --threads "$threads" --cpu
Do_cmd fslmaths "${tmp}/func_brain_synthseg.nii.gz" -uthr 42 -thr 42 -bin -mul -39 -add "${tmp}/func_brain_synthseg.nii.gz" "${bold_synth}"

# Affine from func to t1-nativepro
centeralign="[${t1_synth},${bold_synth},0]"
Do_cmd antsRegistrationSyN.sh -d 3 -f "$t1_synth" -m "$bold_synth" -o "$str_func_affine" -t a -n "$threads" -p d -i ${centeralign}
Do_cmd antsApplyTransforms -d 3 -i "$t1_synth" -r "$bold_synth" -t ["$mat_func_affine",1] -o "${tmp}/T1bold_in_func.nii.gz" -v -u int

if [[ ${regAffine} == "FALSE" ]]; then
# SyN from T1_nativepro to t1-nativepro
Do_cmd antsRegistrationSyN.sh -d 3 -m "${tmp}/T1bold_in_func.nii.gz" -f "${bold_synth}" -o "$str_func_SyN" -t s -n "$threads" -p d #-i "$mat_func_affine"
fi
Info "Registering func MRI to nativepro with LAMAReg"

# LAMAReg registration with robust two-stage approach
func_SyN_output="${str_func_affine}Warped.nii.gz"
func_fixed_parc="${str_func_affine}_fixed_parc.nii.gz"
func_moving_parc="${str_func_affine}_moving_parc.nii.gz"
func_registered_parc="${str_func_affine}_registered_parc.nii.gz"
func_qc_csv="${str_func_affine}_dice_scores.csv"

Do_cmd lamareg register \
--moving "${fmri_brain}" \
--fixed "${t1bold}" \
--output "$func_SyN_output" \
--moving-parc "$func_moving_parc" \
--fixed-parc "$func_fixed_parc" \
--registered-parc "$func_registered_parc" \
--affine "${SyN_func_affine}" \
--warpfield "${SyN_func_warp}" \
--inverse-warpfield "${SyN_func_Invwarp}" \
--qc-csv "$func_qc_csv" \
--synthseg-threads "$threads" \
--ants-threads "$threads"

Do_cmd rm -rf "${dir_warp}"/*Warped.nii.gz 2>/dev/null
# func to t1-nativepro
Do_cmd antsApplyTransforms -d 3 -i "$fmri_brain" -r "$t1bold" "${transform}" -o "$fmri_in_T1nativepro" -v -u int
Expand Down Expand Up @@ -726,26 +723,22 @@ if [[ ! -f "${func_surf}/${idBIDS}_hemi-R_surf-fsnative.func.gii" ]]; then
# convert affines
Do_cmd c3d_affine_tool -itk "${mat_func_affine}" -o "$tmp/affine1.mat"
mat_func_affine=$tmp/affine1.mat
if [[ ${regAffine} == "FALSE" ]]; then
Do_cmd c3d_affine_tool -itk "${SyN_func_affine}" -o "$tmp/affine2.mat" -inv
SyN_func_affine="$tmp/affine2.mat"
fi
Do_cmd c3d_affine_tool -itk "${SyN_func_affine}" -o "$tmp/affine2.mat" -inv
SyN_func_affine="$tmp/affine2.mat"
# apply registrations to surface
for HEMICAP in L R; do
Do_cmd wb_command -surface-apply-affine \
"${surf_dir}/${idBIDS}_hemi-${HEMICAP}"_space-nativepro_surf-fsnative_label-midthickness.surf.gii \
"${mat_func_affine}" \
"${func_surf}/${idBIDS}_hemi-${HEMICAP}"_space-func_surf-fsnative_label-midthickness.surf.gii
if [[ ${regAffine} == "FALSE" ]]; then
Do_cmd wb_command -surface-apply-affine \
"${func_surf}/${idBIDS}_hemi-${HEMICAP}"_space-func_surf-fsnative_label-midthickness.surf.gii \
"${SyN_func_affine}" \
"${func_surf}/${idBIDS}_hemi-${HEMICAP}"_space-func_surf-fsnative_label-midthickness.surf.gii
Do_cmd wb_command -surface-apply-warpfield \
"${func_surf}/${idBIDS}_hemi-${HEMICAP}"_space-func_surf-fsnative_label-midthickness.surf.gii \
Do_cmd wb_command -surface-apply-affine \
"${func_surf}/${idBIDS}_hemi-${HEMICAP}"_space-func_surf-fsnative_label-midthickness.surf.gii \
"${SyN_func_affine}" \
"${func_surf}/${idBIDS}_hemi-${HEMICAP}"_space-func_surf-fsnative_label-midthickness.surf.gii
Do_cmd wb_command -surface-apply-warpfield \
"${func_surf}/${idBIDS}_hemi-${HEMICAP}"_space-func_surf-fsnative_label-midthickness.surf.gii \
"${SyN_func_warp}" \
"${func_surf}/${idBIDS}_hemi-${HEMICAP}"_space-func_surf-fsnative_label-midthickness.surf.gii
fi
Do_cmd wb_command -volume-to-surface-mapping \
"${func_processed}" \
"${func_surf}/${idBIDS}_hemi-${HEMICAP}"_space-func_surf-fsnative_label-midthickness.surf.gii \
Expand Down
67 changes: 30 additions & 37 deletions functions/03_MPC-SWM.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ nocleanup=$5
threads=$6
tmpDir=$7
input_im=$8
mpc_reg=$9
mpc_str=${10}
synth_reg=${11}
reg_nonlinear=${12}
PROC=${13}
mpc_str=$9
PROC=${12}
export OMP_NUM_THREADS=$threads
here=$(pwd)

Expand Down Expand Up @@ -85,8 +82,6 @@ Note "Saving temporal dir : " "${nocleanup}"
Note "Parallel processing : " "${threads} threads"
Note "tmp dir : " "${tmpDir}"
Note "recon : " "${recon}"
Note "synth_reg : " "${synth_reg}"
Note "reg_nonlinear : " "${reg_nonlinear}"

# Timer
aloita=$(date +%s)
Expand Down Expand Up @@ -120,42 +115,40 @@ mat_qMRI2np_xfm="${str_qMRI2np_xfm}0GenericAffine.mat"
SyN_qMRI2np_warp="${str_qMRI2np_xfm}1Warp.nii.gz"
SyN_qMRI2np_Invwarp="${str_qMRI2np_xfm}1InverseWarp.nii.gz"

# Apply transformations
if [[ ${reg_nonlinear} == "TRUE" ]]; then
# SyN from T1_nativepro to t1-nativepro
reg="s"
transformsInv="-t [${mat_qMRI2np_xfm},1] -t ${SyN_qMRI2np_Invwarp}" # T1nativepro to qMRI
transforms="-t ${SyN_qMRI2np_warp} -t ${mat_qMRI2np_xfm}" # qMRI to T1nativepro T1nativepro to qMRI
else
reg="a"
transformsInv="-t [${mat_qMRI2np_xfm},1]" # T1nativepro to qMRI
transforms="-t ${mat_qMRI2np_xfm}" # qMRI to T1nativepro
fi
# Apply transformations - always nonlinear with LAMAReg
reg="s"
transformsInv="-t [${mat_qMRI2np_xfm},1] -t ${SyN_qMRI2np_Invwarp}" # T1nativepro to qMRI
transforms="-t ${SyN_qMRI2np_warp} -t ${mat_qMRI2np_xfm}" # qMRI to T1nativepro

synthseg_native() {
mri_img=$1
mri_str=$2
mri_synth="${tmp}/${mri_str}_synthsegGM.nii.gz"
Do_cmd mri_synthseg --i "${mri_img}" --o "${tmp}/${mri_str}_synthseg.nii.gz" --robust --threads "$threads" --cpu
Do_cmd fslmaths "${tmp}/${mri_str}_synthseg.nii.gz" -uthr 42 -thr 42 -bin -mul -39 -add "${tmp}/${mri_str}_synthseg.nii.gz" "${mri_synth}"
}
# LAMAReg registration with robust two-stage approach
qMRI_SWM_output="${str_qMRI2np_xfm}Warped.nii.gz"
qMRI_fixed_parc="${str_qMRI2np_xfm}_fixed_parc.nii.gz"
qMRI_moving_parc="${str_qMRI2np_xfm}_moving_parc.nii.gz"
qMRI_registered_parc="${str_qMRI2np_xfm}_registered_parc.nii.gz"
qMRI_qc_csv="${str_qMRI2np_xfm}_dice_scores.csv"

# Calculate the registrations
if [[ ! -f "$qMRI_warped" ]] || [[ ! -f "$mat_qMRI2np_xfm" ]]; then ((N++))
img_fixed="${T1nativepro}"
img_moving="${regImage}"

# Registration with synthseg
if [[ "${synth_reg}" == "TRUE" ]]; then
Info "Running label based affine registrations"
synthseg_native "${T1nativepro}" "T1w"
synthseg_native "${regImage}" "qT1"
img_fixed="${tmp}/T1w_synthsegGM.nii.gz"
img_moving="${tmp}/qT1_synthsegGM.nii.gz"
fi

# Registrations from t1-fsnative to qMRI
Do_cmd antsRegistrationSyN.sh -d 3 -f "$img_fixed" -m "$img_moving" -o "$str_qMRI2np_xfm" -t "${reg}" -n "$threads" -p d -i ["${img_fixed}","${img_moving}",0]
# Registration with LAMAReg
Info "Running LAMAReg registration"

Do_cmd lamareg register \
--moving "${regImage}" \
--fixed "${T1nativepro}" \
--output "$qMRI_SWM_output" \
--moving-parc "$qMRI_moving_parc" \
--fixed-parc "$qMRI_fixed_parc" \
--registered-parc "$qMRI_registered_parc" \
--affine "${mat_qMRI2np_xfm}" \
--warpfield "${SyN_qMRI2np_warp}" \
--inverse-warpfield "${SyN_qMRI2np_Invwarp}" \
--qc-csv "$qMRI_qc_csv" \
--synthseg-threads "$threads" \
--ants-threads "$threads"

rm "${dir_warp}/${idBIDS}"*_Warped.nii.gz

# Check if transformation file exist
Expand Down Expand Up @@ -234,7 +227,7 @@ if [[ ! -f "${MPC_fsLR5k}" ]]; then ((N++))
# Apply transformation to register surface to nativepro
wb_command -surface-apply-affine "${surf_swm}" "${wb_affine}" "${out_surf}"
# Apply Non-linear Warpfield to register surface to nativepro
if [[ ${reg_nonlinear} == "TRUE" ]]; then Do_cmd wb_command -surface-apply-warpfield "${out_surf}" "${SyN_qMRI2np_Invwarp}" "${out_surf}"; fi
Do_cmd wb_command -surface-apply-warpfield "${out_surf}" "${SyN_qMRI2np_Invwarp}" "${out_surf}"
# Sample intensity and resample to other surfaces fsaverage5, fsLR-32k and fsLR-5k
map_to-surfaces "${microImage}" "${out_surf}" "${out_feat}" "${HEMI}" "${label}" "${outDir}"
done
Expand Down
Loading
Loading