-
Notifications
You must be signed in to change notification settings - Fork 2
/
MI_findgood.m
34 lines (25 loc) · 1.05 KB
/
MI_findgood.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
function results = MI_findgood(MIshuff_structure)
%goes through every field of a shuffled mutual info structure and tells you the number of cells over 95% for each field
MI_shuff = MIshuff_structure;
% Get all field names of the MI_shuff structure
fieldNames = fieldnames(MI_shuff);
% Preallocate a vector to store the results
results = zeros(length(fieldNames), 1);
% Loop through each field name
for i = 1:length(fieldNames)
% Current field name
currentField = fieldNames{i};
% Perform the operation on the current field
currentData = MI_shuff.(currentField);
% Check if the field has at least 3 columns
if size(currentData, 2) >= 3
% Calculate the ratio
ratio = length(find(currentData(:,3) >= 0.95)) / length(currentData);
else
% Handle the case where there are less than 3 columns
ratio = NaN; % Assign NaN or some other value to indicate an error
fprintf('Field %s does not have enough columns.\n', currentField);
end
% Store the result in the results vector
results(i) = ratio;
end