Skip to content
Snippets Groups Projects
Commit 3b44dcdb authored by Mensen's avatar Mensen
Browse files

fixed issue with correlation for multiple dimensions (kind of slow now though...

fixed issue with correlation for multiple dimensions (kind of slow now though using reshape) | fixed type on lme permutations script
parent 8d8f446b
Branches master
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ function perm_table = ept_lme_permute(table, factors)
% for example:
% factors = struct(...
% 'name', {'stroke_id', 'spindle_type'}, ... % covariate names
% 'flag_within', [10, 1]); % flag_within
% 'flag_within', [0, 1]); % flag_within
% check for participant_id
if ~any(strcmp('participant_id', table.Properties.VariableNames))
......
......@@ -235,14 +235,18 @@ elseif nargin > 2;
DataFile{1, 2} = '';
Data{1} = DataFile1;
Data{2} = DataFile2;
aData = [Data{1}; Data{2}];
if type == 'i' || type == 'd'
aData = [Data{1}; Data{2}];
end
elseif isa(DataFile1, 'single')
fprintf(1, 'warning: single data converted to double for analysis');
DataFile{1, 2} = '';
Data{1} = double(DataFile1);
Data{2} = double(DataFile2);
aData = [Data{1};Data{2}];
if type == 'i' || type == 'd'
aData = [Data{1}; Data{2}];
end
else
fprintf(1, 'error: could not recognise data format (possibly single) \n');
......@@ -331,7 +335,10 @@ elseif type == 'c'
behavior_repeated = repmat(Data{2}, [1, data_size]);
% calculate the correlation coefficient (r) but call it T_Obs for consistency
T_Obs = (condition(Data{1})' * condition(behavior_repeated)) / sum(condition(Data{1}).^2);
temp_observed = [reshape(condition(Data{1}), nA, [])' ...
* reshape(condition(behavior_repeated), nA, [])] ...
/ reshape(sum(condition(Data{1}).^2), 1, []);
T_Obs = reshape(temp_observed, data_size);
end
......@@ -407,7 +414,11 @@ display('Calculating Permutations...')
behavior_repeated = repmat(behavior_perm, [1, data_size]);
% calculate the correlation coefficient (r) but call it T_Perm for consistency
T_Perm = (condition(Data{1})' * condition(behavior_repeated)) / sum(condition(Data{1}).^2);
temp_observed = [reshape(condition(Data{1}), nA, [])' ...
* reshape(condition(behavior_repeated), nA, [])] ...
/ reshape(sum(condition(Data{1}).^2), 1, []);
T_Perm = reshape(temp_observed, data_size);
else
error('Unrecognised analysis-type; see help file for valid inputs')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment