# ---------------------------------------------------------------------------------   
if CALCULATE_U_STATS:
    
    # -- skip problems with already calculated U-stats
    if CALCULATE_ONLY_NEW_U_STATS:
        task_names = tstat.filter_calculated(mat_file_root,HCTSA_name_search_pattern = 'HCTSA_(.*)_N_70_100_reduced.mat')
        file_paths = [mat_file_root+"HCTSA_{0:s}_N_70_100_reduced.mat".format(s) for s in task_names]
    
    # -- calculate U-stats for all problems        
    else:
        file_paths = mat_file_paths
        _,task_names = tstat.get_calculated_names(mat_file_root,HCTSA_name_search_pattern = 'HCTSA_(.*)_N_70_100_reduced.mat')
    
    u_stat_file_paths = tstat.calculate_ustat_mult_tasks(mat_file_paths,task_names,ustat_data_out_folder,is_from_old_matlab = IS_FROM_OLD_MATLAB)  
    if CALCULATE_U_STATS_ALL_CLASSES_AVG:
        all_classes_avg = tstat.calculate_ustat_avg_mult_task(mat_file_paths,u_stat_file_paths,all_classes_avg_out_path ,is_from_old_matlab = IS_FROM_OLD_MATLAB)


  
  
# ---------------------------------------------------------------------------------
# -- Calculate the best features 
# ---------------------------------------------------------------------------------
# all_classes_avg_non_corr_path = intermediate_data_root + 'all_classes_avg_non_corr_no_time_picking.npy'
# ind_dict_non_corr_path = intermediate_data_root + 'ind_dict_non_corr_no_time_picking.pckl'
# corr_feat_mask_path = intermediate_data_root +'/mask_no_time_picking.npy'

# if CALCULATE_BEST_FEATURES:
#     if not CALCULATE_U_STATS_ALL_CLASSES_AVG:
#         all_classes_avg = np.load(all_classes_avg_path)
#         # -- get the filenames for all problems under investigation 
    # -- calculate U-stats for all problems
    else:
        file_paths = mat_file_paths
        _, task_names = tstat.get_calculated_names(
            mat_file_root,
            HCTSA_name_search_pattern='HCTSA_(.*)_N_70_100_reduced.mat')

    u_stat_file_paths = tstat.calculate_ustat_mult_tasks(
        mat_file_paths,
        task_names,
        ustat_data_out_folder,
        is_from_old_matlab=IS_FROM_OLD_MATLAB)
    if CALCULATE_U_STATS_ALL_CLASSES_AVG:
        all_classes_avg = tstat.calculate_ustat_avg_mult_task(
            mat_file_paths,
            u_stat_file_paths,
            all_classes_avg_out_path,
            is_from_old_matlab=IS_FROM_OLD_MATLAB)

# ---------------------------------------------------------------------------------
# -- Calculate the best features
# ---------------------------------------------------------------------------------
# all_classes_avg_non_corr_path = intermediate_data_root + 'all_classes_avg_non_corr_no_time_picking.npy'
# ind_dict_non_corr_path = intermediate_data_root + 'ind_dict_non_corr_no_time_picking.pckl'
# corr_feat_mask_path = intermediate_data_root +'/mask_no_time_picking.npy'

# if CALCULATE_BEST_FEATURES:
#     if not CALCULATE_U_STATS_ALL_CLASSES_AVG:
#         all_classes_avg = np.load(all_classes_avg_path)
#         # -- get the filenames for all problems under investigation
#         calced_names = tstat.get_calculated_names(mat_file_root)[0]