-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfix_trk_files.py
62 lines (49 loc) · 2.45 KB
/
fix_trk_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from dipy.io.streamline import load_trk
import os
import shutil
from tract_handler import trk_fixer
from file_tools import mkcdir, getfromfile
from tract_handler import reducetractnumber, ratio_to_str, get_ratio
import random
from computer_nav import get_sftp, glob_remote
"""
TRK_folder = '/Users/alex/jacques/AMD_TRK_testing/TRK_MDT'
TRK_output = '/Users/alex/jacques/AMD_TRK_testing/TRK_MDT_fixed'
TRK_folder = '/Volumes/Data/Badea/Lab/human/AMD/TRK_MDT'
TRK_output = '/Volumes/Data/Badea/Lab/human/AMD/TRK_MDT_fixed'
TRK_folder = '/mnt/munin6/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_MDT/'
TRK_output = '/mnt/munin6/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_MDT_fixed/'
TRK_folder = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_MDT/'
TRK_output = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_MDT_fixed/'
TRK_folder = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/Centroids_MDT_non_inclusive_100/'
TRK_output = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/Centroids_MDT_non_inclusive_100_fixed/'
TRK_folder = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA/'
TRK_output = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_fixed/'
TRK_folder = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_MDT/'
TRK_output = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_MDT_fixed/'
TRK_folder = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_/'
TRK_output = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_fixed/'
"""
TRK_folder = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_/'
TRK_output = '/Volumes/Data/Badea/Lab/human/AD_Decode/Analysis/TRK_MPCA_fixed/'
remote=True
if remote:
username, passwd = getfromfile('/Users/jas/samos_connect.rtf')
inpath, outpath, atlas_folder, sftp = get_sftp(remote, username=username,password=passwd)
if not remote:
filelist = os.listdir(TRK_folder)
else:
filelist = glob_remote(TRK_folder,sftp)
filelist = sorted(filelist)
#filelist.reverse()
random.shuffle(filelist)
mkcdir(TRK_output)
for trk_name in filelist:
if trk_name.endswith('.trk'):
trk_path = os.path.join(TRK_folder,trk_name)
trk_newpath = os.path.join(TRK_output, trk_name)
if not os.path.exists(trk_newpath):
print(f'Beginning the fix of {trk_path}')
trk_fixer(trk_path, trk_newpath, verbose=True)
else:
print(f'Already fixed {trk_name}')