atlas_stattk.cal_between_subj_relation('dice', atlastk.between_dice)
#########################################################################
dist_func = lambda x, y:atlastk.dist(x, y, atlas_deposite.img_resolution)
atlas_stattk.cal_multi_roi_relation('peak_distance', dist_func, atlastk.RoiStatTk.get_subject_peak)
hausdorff_func = lambda x, y: atlastk.hausdorff(x, y, atlas_deposite.img_resolution)
atlas_stattk.cal_multi_roi_relation('hausdorff_distance', hausdorff_func, atlastk.RoiStatTk.get_subject_label)

t4 = time.time() - t3
print 'atlas object construction done: %f sec' % t4
#########################################################################
atlas_stattk.cal_prob_maps()
atlas_stattk.save_prob_maps(probmapdir)
atlas_stattk.cal_max_prob_map(0, mapno=0, save=True, filename=probmapdir+'maxprob_thr0.nii.gz')
#########################################################################
mat_dir = '/nfs/j3/userhome/huangtaicheng/workingdir/parcellation_MT/BAA/results/yang_test/sub/data'
atlastk.output_mats(atlas_stattk, mat_dir, 'MT', MT_con, MT_con_key,'motion-fix' , 5.0, 0, 160)














atlas_stattk.cal_anat_relations('overlap', atlastk.multi_left_overlap, 'HOcort_thr0', anat_img)
#atlas_stattk.cal_anat_relations('jaccard', atlastk.multi_jaccard, 'HOcombo', anat_img)
#atlas_stattk.cal_anat_relations('dice', atlastk.multi_dice, 'HOcombo', anat_img)

#multi_hausdorff_func = lambda label, anat, aids, nid: atlastk.multi_hausdorff(label, anat, aids, nid, atlas_deposite.img_resolution)
#atlas_stattk.cal_anat_relations('dice', multi_hausdorff_func, 'HOcombo', anat_img)

##--------------------------------- Relationship between different subject (for each ROI) ------------------------------
atlas_stattk.cal_between_subj_relation('dice', atlastk.between_dice)

##--------------------------------- Relationship between different ROIs (for each subject)------------------------------
dist_func = lambda x, y:atlastk.dist(x, y, atlas_deposite.img_resolution)
atlas_stattk.cal_multi_roi_relation('peak_distance', dist_func, atlastk.RoiStatTk.get_subject_peak)
hausdorff_func = lambda x, y: atlastk.hausdorff(x, y, atlas_deposite.img_resolution)
atlas_stattk.cal_multi_roi_relation('hausdorff_distance', hausdorff_func, atlastk.RoiStatTk.get_subject_label)

t4 = time.time() - t3
print  'ROI relationship done: %f sec' % t4

#--------------------------------- Probmaps and MaxProbMap -------------------------------------------------------
atlas_stattk.cal_prob_maps()
atlas_stattk.save_prob_maps(probmapdir)
atlas_stattk.cal_max_prob_map(0, mapno=0, save=True, filename=probmapdir+'maxprob_thr0.nii.gz')

#---------------------------------- Output -------------------------------------------------------
mat_dir = '/nfs/t3/workingshop/yangzetian/Atlas/2006ObjectAtlas/data/mats'
atlastk.output_mats(atlas_stattk, mat_dir)

rint 'Total time: %f sec' % (time.tim:e()-t0)