#!/usr/bin/env bash

#resize TMS spots left, right
foreach * : maskfilter IN/2_nifti/tms_hand_l_mask_roi.nii.gz dilate -npass 3 IN/2_nifti/tms_hand_l_mask_roi_3.nii.gz; foreach * : maskfilter IN/2_nifti/tms_hand_r_mask_roi.nii.gz dilate -npass 3 IN/2_nifti/tms_hand_r_mask_roi_3.nii.gz

#draw roi in pons "roi_pons.mif"
#use roi_pons and tms spot for tractography left,right
foreach * : tckgen IN/5_dwi/wm_norm.mif -seed_im IN/2_nifti/tms_hand_l_mask_roi_3.nii.gz -incl IN/5_dwi/roi_pons.mif -cuto .1 -minl 100 IN/5_dwi/tms_hand_l_norm.tck

#tractography
foreach * : tckgen IN/5_dwi/wm_norm.mif -seed_im IN/2_nifti/tms_hand_r_mask_roi_3.nii.gz -incl IN/5_dwi/roi_pons.mif -cuto .1 -minl 100 IN/5_dwi/tms_hand_r_norm.tck

#resample tractograms left, right
tckresample tms_hand_l_norm.tck -line 100 x,y,z(pons_coords) x,y,z(tms_coords) tms_hand_l_norm_resampled_100.tck

tckresample tms_hand_r_norm.tck -line 100 x,y,z(pons_coords) x,y,z(tms_coords) tms_hand_r_norm_resampled_100.tck
