Skip to content

Commit 058f283

Browse files
committed
Make behavior what's permuted instead of data
1 parent 8140c1b commit 058f283

2 files changed

Lines changed: 31 additions & 25 deletions

File tree

+nla/+edge/+permutationMethods/+tree/PermutationNode.m

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
%PERMUTATIONNODE Node which defines one grouping of each permutatino tree
33
%
44
% node = permutationNode(level, input_data, permutation_groups)
5-
% node = One grouping of data for each permutation group. Each group contains the data (functional connectivity)
6-
% along with the index (column) the data is located and the original column
5+
% node = One grouping of data for each permutation group. Each group contains the data to be permuted
6+
% along with the index (column)
77
% level = The level of the tree. 0 is the root, 1 the first column of permutation groups, 2 the next...
8-
% input_data = The input data. Currently, this is the functional connectivity
8+
% input_data = The input data to be permuted
99
% permutation_groups = the columns from the csv file that characterizes the permutation groupings
1010
% Each column of the data is 1 permutation grouping.
1111
% Each row is one subject/data entry
@@ -16,12 +16,12 @@
1616
children = [] % Nodes that descend from the current node. The column to the right of the current level in permutation groups
1717
level = 0 % 0 is root, initial_data
1818
parent = false % if false, this is the root of the tree. If not, this is the node that came before
19-
data_with_indexes = {} % The data. 3 cell object. {data (some big array), current index, original index}
19+
data_with_indexes = {} % The data. 2 cell object. {data (some big array), original index}
2020
permutation_groups = [] % The groups that descend off of this one
2121
end
2222

2323
properties (SetAccess = immutable)
24-
original_data % matrix of size input_data.length x 3 with each row [data_value, current_index, original_index]
24+
original_data % matrix of size input_data.length x 3 with each row [data_value, original_index]
2525
end
2626

2727
methods
@@ -32,29 +32,25 @@
3232

3333
if isequal(level, 0)
3434
obj.permutation_groups = permutation_groups;
35-
obj.original_data = {input_data, [1:size(input_data, 2)], [1:size(input_data, 2)]};
35+
obj.original_data = {input_data, [1:size(input_data)]'};
3636
obj.data_with_indexes = obj.original_data;
3737
else
3838
size_permutation_groups = size(permutation_groups);
3939
if size_permutation_groups(2) > 1
4040
obj.permutation_groups = permutation_groups(:, 2:end);
4141
end
42-
functional_connectivity = input_data{1};
43-
index_length = size(input_data{2}, 2);
44-
current_index = [1:index_length];
45-
original_index = input_data{3};
46-
obj.original_data = {functional_connectivity, current_index, original_index};
42+
obj.original_data = {input_data{1}, input_data{2}};
4743
obj.data_with_indexes = obj.original_data;
4844
end
45+
4946
if ~isempty(obj.permutation_groups)
5047
group_numbers = unique(obj.permutation_groups(:, 1));
5148
for group_number = 1:numel(group_numbers)
5249
group_indexes = (obj.permutation_groups(:, 1) == group_numbers(group_number));
5350
temp_permutation_groups = obj.permutation_groups(group_indexes, :);
5451
group_input_data = obj.data_with_indexes{1};
5552
group_current_indexes = obj.data_with_indexes{2};
56-
group_original_indexes = obj.data_with_indexes{3};
57-
group_data = {group_input_data(:, group_indexes), group_current_indexes(group_indexes), group_original_indexes(group_indexes)};
53+
group_data = {group_input_data, group_current_indexes(group_indexes)};
5854
obj.children = [obj.children obj.createNodes(obj.level + 1, temp_permutation_groups, group_data, obj)];
5955
end
6056
end

+nla/+edge/+permutationMethods/MultiLevel.m

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,41 @@
3232
input_struct.permutation_groups = [];
3333
end
3434
obj.permutation_tree = nla.edge.permutationMethods.tree.PermutationTree(...
35-
input_struct.func_conn.v, input_struct.permutation_groups...
35+
input_struct.behavior, input_struct.permutation_groups...
3636
);
3737
tree_root = obj.permutation_tree.root_node;
3838
obj = obj.depthFirstSearch(tree_root);
3939
end
4040

4141
function permuted_input_struct = permute(obj, orig_input_struct)
4242
permuted_input_struct = orig_input_struct;
43-
permuted_transposed_functional_connectivity = zeros(size(orig_input_struct.func_conn.v'));
44-
43+
permuted_behavior = orig_input_struct.behavior(:,:);
4544
for node_index = 1:numel(obj.terminal_nodes)
4645
node = obj.terminal_nodes(node_index);
4746
current_indexes = node.data_with_indexes{2};
48-
original_indexes = node.data_with_indexes{3};
49-
data = node.data_with_indexes{1}'; % transpose to match dimensions of indexes
50-
47+
data = node.data_with_indexes{1};
5148
permuted_indexes = nla.helpers.permuteVector(current_indexes);
52-
sorted_original_indexes = sort(original_indexes, 2);
53-
original_indexes = original_indexes(permuted_indexes);
54-
data = data(permuted_indexes, :);
55-
node.data_with_indexes = {data', current_indexes, original_indexes};
56-
permuted_transposed_functional_connectivity(sorted_original_indexes, :) = data;
49+
permuted_behavior(current_indexes) = data(permuted_indexes);
5750
end
51+
permuted_input_struct.behavior = permuted_behavior;
52+
% permuted_transposed_functional_connectivity = zeros(size(orig_input_struct.func_conn.v'));
53+
54+
% for node_index = 1:numel(obj.terminal_nodes)
55+
% node = obj.terminal_nodes(node_index);
56+
% current_indexes = node.data_with_indexes{2};
57+
% original_indexes = node.data_with_indexes{3};
58+
% data = node.data_with_indexes{1}'; % transpose to match dimensions of indexes
59+
60+
% permuted_indexes = nla.helpers.permuteVector(current_indexes);
61+
% sorted_original_indexes = sort(original_indexes, 2);
62+
% original_indexes = original_indexes(permuted_indexes);
63+
% data = data(permuted_indexes, :);
64+
% node.data_with_indexes = {data', current_indexes, original_indexes};
65+
% permuted_transposed_functional_connectivity(sorted_original_indexes, :) = data;
66+
% end
5867

59-
permuted_input_struct.func_conn.v = permuted_transposed_functional_connectivity';
68+
% permuted_input_struct.func_conn.v = permuted_transposed_functional_connectivity';
69+
6070
end
6171

6272
function obj = depthFirstSearch(obj, node_input)

0 commit comments

Comments
 (0)