-
Notifications
You must be signed in to change notification settings - Fork 3
/
Wrapper_ConvertTrk2Cell_indv_subjs.m
executable file
·45 lines (33 loc) · 1.33 KB
/
Wrapper_ConvertTrk2Cell_indv_subjs.m
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
%% Converts the whole brain tractography file to cell structure for matlab processing and stores the output in ${dir}/${subj}/Trk_2_Cell/All_fibers
addpaths;
readInputFile;
input_file_other_subjs;
%output_dir_traks_af = strcat(output_dir_tracks, 'All_fibers/'); %%CHANGE
output_dir_tracks = strcat(data_dir, 'Trk_2_Cell/All_fibers/');
if (exist(output_dir_tracks) == 0)
mkdir(output_dir_tracks)
end
%Read tracts
[header, tracks] = trk_read(trk_file_path);
tracks_new = trk_interp(tracks, number_of_points_per_track);
tracks_interp_str = trk_restruc(tracks_new);
disp('Completed reading Tract file');
track_cell = ConvertTrk2Cell(tracks_interp_str, Padding, voxDim);
file_name = strcat(output_dir_tracks, 'All_fibers.mat');
save(file_name, 'track_cell');
disp('All tracts converted');
%% Do the length thresholding
num_tracks = length(track_cell)
trk_length_vector = zeros(num_tracks, 1);
for i =1:num_tracks
track_i = tracks_cell{i};
trk_size = size(track_i);
numrows = trk_size(1);
if (numrows > 1 )
trk_length_vector(i) = TrackLength(track_i);
end
end
filtered_tracks_idx = find(trk_length_vector < length_threshold_max & trk_length_vector > length_threshold_min);
tracks_filtered = tracks_cell(filtered_tracks_idx);
%% Divide Tracks now
DivideTracks(tracks_filtered, num_tracks_per_bundle, output_dir_tracks);