function convex_hull(matlab_dir,app_dir,parcellationPath,Sbj_ID,Scan_ID)

name=fullfile(parcellationPath,[Sbj_ID '-0' Scan_ID '_WM_SubCort_labels.nii']);   
nii = load_untouch_nii(name);
ICC=nii.img;

rh=zeros(size(ICC));
rh(1:round(size(rh,1)/2),:,:)=1;
lh=zeros(size(ICC));
lh(round(size(rh,1)/2):end,:,:)=1;

R=15;
N=0; % N must be 0, 4, 6, or 8.

ICC_r=ICC;
ICC_r(ICC>0 & rh==1)=1;
ICC_r(lh==1)=0;
se = strel('disk',R,N);
ICC_r=imclose(ICC_r,se);

ICC_l=ICC;
ICC_l(ICC>0 & lh==1)=1;
ICC_l(rh==1)=0;
se = strel('disk',R,N);
ICC_l=imclose(ICC_l,se);

ICC_CH=ICC;
ICC_CH(rh==1 & ICC_r==1)=1;
ICC_CH(lh==1 & ICC_l==1)=1;

nii.img=ICC_CH;
Cname=fullfile(parcellationPath,[Sbj_ID '-0' Scan_ID '_CH.nii']);   
save_untouch_nii(nii,Cname);

meshFileName_1 = fullfile(parcellationPath,[Sbj_ID '-0' Scan_ID '_CH_1.off']);   
meshFileName_2 = fullfile(parcellationPath,[Sbj_ID '-0' Scan_ID '_CH_2.off']); 
reconstructAndLabelConvexHull(Cname,meshFileName_1,meshFileName_2,matlab_dir,app_dir);
