ROI_legends = "/mnt/paros_MRI/jacques/atlases/IITmean_RPI/IITmean_RPI_index.xlsx"
elif 'santorini' in computer_name:
    # mainpath = '/Users/alex/jacques/'
    mainpath = '/Volumes/Data/Badea/Lab/human/'
    ROI_legends = "/Volumes/Data/Badea/ADdecode.01/Analysis/atlases/IITmean_RPI/IITmean_RPI_index.xlsx"
elif 'blade' in computer_name:
    mainpath = '/mnt/munin6/Badea/Lab/human/'
    ROI_legends = "/mnt/munin6/Badea/Lab/atlases/IITmean_RPI/IITmean_RPI_index.xlsx"
else:
    raise Exception('No other computer name yet')

# target_tuple = (24,1)
# target_tuple = [(58, 57)]
# target_tuples = [(64, 57)]

ratio_str = ratio_to_str(ratio)
print(ratio_str)
if ratio_str == '_all':
    folder_ratio_str = ''
else:
    folder_ratio_str = ratio_str.replace('_ratio', '')
# target_tuple = (9,77)

_, _, index_to_struct, _ = atlas_converter(ROI_legends)

if project == 'AMD':
    mainpath = os.path.join(mainpath, project)
    groups = [
        'Initial AMD', 'Paired 2-YR AMD', 'Initial Control',
        'Paired 2-YR Control', 'Paired Initial Control', 'Paired Initial AMD'
    ]
            trk_fixer(trk_path, trk_newpath, verbose=True)
        else:
            print(f'Already fixed {trk_name}')

trk_folder = TRK_output
new_trk_folder = '/mnt/paros_MRI/jacques/AD_Decode/Analysis/TRK_MPCA_neworient_fixed_100/'
mkcdir(new_trk_folder)
ratio = 100
filelist = os.listdir(trk_folder)
#filelist = sorted(filelist)
filelist.reverse()
for filepath in filelist:
    filename, f_ext = os.path.splitext(filepath)
    ratio1 =get_ratio(filepath)
    ratio2 = int(ratio1*ratio)
    filename2 = filename.replace(ratio_to_str(ratio1),ratio_to_str(ratio2))
    newfilepath = os.path.join(new_trk_folder, filename2 + f_ext)
    if not os.path.exists(newfilepath):
        print(f'Downsampling from {os.path.join(trk_folder,filepath)} to {newfilepath} with ratio {str(ratio)}')
        #print(f'{filename} converted to {filename2 + f_ext}')
        reducetractnumber(os.path.join(trk_folder,filepath), newfilepath, getdata=False, ratio=100, return_affine= False, verbose=False)
        print(f'succesfully created {newfilepath}')
    else:
        print(f'already created {newfilepath}')

"""
if testing:
    trk_test = '/Users/alex/jacques/AMD_TRK_testing/TRK/H21850_stepsize_2_ratio_100_wholebrain_pruned.trk'
    trk_new = '/Users/alex/jacques/AMD_TRK_testing/TRK/H21850_ratio100_fixed.trk'
    trk_fixer(trk_test, trk_new, verbose=True)
else: