-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c2e954b
Showing
11 changed files
with
1,128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Windows image file caches | ||
Thumbs.db | ||
ehthumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
# ========================= | ||
# Operating System Files | ||
# ========================= | ||
|
||
# OSX | ||
# ========================= | ||
|
||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
stemFolder = pwd; | ||
load([stemFolder filesep 'dummy'],'data'); | ||
|
||
cfg_neighb = []; | ||
cfg_neighb.method = 'template'; | ||
cfg_neighb.template = 'CTF275_neighb.mat'; | ||
neighbours = ft_prepare_neighbours(cfg_neighb, data); | ||
|
||
%% Gender-Dosage test data set | ||
% Test data set from: http://personality-project.org/r/r.guide/r.anova.html | ||
|
||
% Indep 2x2 ANOVA: factors Gender & dosage on alertness level | ||
|
||
% Design matrix for the test data | ||
design(1,:) = [ones(1,2*4) ones(1,2*4)*2]; % First factor: Gender | ||
design(2,:) = repmat([ones(1,4) ones(1,4)*2],1,2); % Second Factor: Dosage | ||
|
||
data.powspctrm = [8 12 13 12 6 7 23 14 15 12 22 14 15 12 18 22]'; | ||
|
||
% Results given at the personality-project.org page | ||
|
||
% Df Sum Sq Mean Sq F value Pr(>F) | ||
% Gender 1 76.562 76.562 2.9518 0.1115 | ||
% Dosage 1 5.062 5.062 0.1952 0.6665 | ||
% Gender:Dosage 1 0.063 0.063 0.0024 0.9617 | ||
% Residuals 12 311.250 25.938 | ||
|
||
|
||
|
||
%% Specify configuration structure: the dummy data structure consists of a single channel, time bin and frequency of interest | ||
cfg = []; | ||
|
||
cfg.channel = {'MLC11'}; | ||
cfg.latency = [1 1]; | ||
cfg.frequency = [4 4]; | ||
cfg.avgovertime = 'no'; | ||
cfg.avgoverfreq = 'no'; | ||
cfg.avgoverchan = 'no'; | ||
|
||
cfg.method = 'montecarlo'; | ||
cfg.correctm = 'cluster'; | ||
cfg.clusteralpha = 1; % consider all clusters irrespectively of significance | ||
cfg.clusterstatistic = 'maxsum'; | ||
cfg.minnbchan = 0; % we are looking at one channel only | ||
|
||
cfg.statistic = 'indepAnova2way'; | ||
cfg.fac = 'iaxb'; % main effect Gender: 'a', main effect Dosage: 'b' and interaction: 'iaxb' | ||
cfg.tail = 1; % F-values can only take positive values | ||
cfg.clustertail = 1; | ||
cfg.design = design; | ||
cfg.neighbours = neighbours; | ||
cfg.numrandomization = 999; % number of permutations | ||
|
||
|
||
|
||
%% define permutation strategies | ||
main_exact_flag = 'yes'; | ||
switch cfg.fac | ||
case 'a' | ||
switch main_exact_flag | ||
case 'no' % unrestricted permutations across levels of both factors | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = []; | ||
case 'yes' % restricted permutations within levels of the other factor (exact test) | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = 2; | ||
end | ||
|
||
case 'b' | ||
switch main_exact_flag | ||
case 'no' | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = []; | ||
case 'yes' | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = 1; | ||
end | ||
|
||
case 'iaxb' % unrestricted permutations across levels of both factors | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = []; | ||
end | ||
|
||
stat = ft_freqstatistics(cfg, data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function stat = FtSimLink_indepANOVA(data,neighbours,y,design,statfun,fac,main_exact_flag) | ||
|
||
data.powspctrm = y'; % data based on a dummy structure | ||
|
||
% Specify configuration structure | ||
cfg = []; | ||
|
||
cfg.channel = {'MLC11'}; | ||
cfg.latency = [1 1]; | ||
cfg.frequency = [4 4]; | ||
cfg.avgovertime = 'no'; | ||
cfg.avgoverfreq = 'no'; | ||
cfg.avgoverchan = 'no'; | ||
|
||
cfg.method = 'montecarlo'; | ||
cfg.correctm = 'cluster'; | ||
cfg.clusteralpha = 0.05; % threshold for a data entry being a cluster candidate | ||
cfg.clusteralpha = 1; % show all clusters irrespectively of significance | ||
cfg.clusterstatistic = 'maxsum'; | ||
cfg.minnbchan = 0; % the dummy data has only one channel | ||
|
||
cfg.statistic = statfun; | ||
cfg.tail = 1; % F-values can only take positive values | ||
cfg.clustertail = 1; | ||
cfg.design = design; | ||
cfg.neighbours = neighbours; | ||
cfg.numrandomization = 999; % number of permutations | ||
cfg.fac = fac; | ||
|
||
% define permutations to be performed | ||
switch cfg.fac | ||
case 'a' % exact main a | ||
switch main_exact_flag | ||
case 'no' | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = []; | ||
case 'yes' | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = 2; | ||
end | ||
|
||
case 'b' % exact main b | ||
switch main_exact_flag | ||
case 'no' | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = []; | ||
case 'yes' | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = 1; | ||
end | ||
|
||
case 'iaxb' % a x b interaction | ||
cfg.ivar = [1 2]; | ||
cfg.wvar = []; | ||
cfg.uvar = []; | ||
cfg.cvar = []; | ||
end | ||
|
||
|
||
cfg.design = design'; | ||
stat = ft_freqstatistics(cfg, data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
How to set up Fieldtrip | ||
|
||
To perform a 2-way balanced, independent (between units of observation) permutation ANOVA: | ||
|
||
1.) put the ft_statfun_indepAnova2way.m file into the statfun folder of your current Fieldtrip version | ||
|
||
2.) the actual ANOVA calculations are done by the core function anova_cell_mod (adapted from Arnaud Delorme�s resampling statistical toolkit, https://de.mathworks.com/matlabcentral/fileexchange/27960-resampling-statistical-toolkit), which needs to go into the privat subfolder of the statfun folder | ||
|
||
3.) Next, you�ll have to modify some Fieldtrip functions. Note that the line numbers given below might be slightly different in your Fieldtrip version. They should give you an idea where to look, though. | ||
|
||
In ft_statistics_montecarlo: | ||
1. around line 120 (where the defaults for the main function are set), add the following line to set the default effect of interest to be the interaction: | ||
cfg.fac = ft_getopt(cfg, 'fac','iaxb'); | ||
|
||
2. starting at line 213, replace the assignment | ||
|
||
resample = resampledesign(cfg, design); | ||
|
||
with | ||
|
||
if isfield(cfg,'resample') | ||
resample = cfg.resample; | ||
else | ||
resample = resampledesign(cfg, design); | ||
end | ||
|
||
This will allow you to use some pre-computed, more complex permutation matrices (not necessary for an independent 2-way ANOVA, but e.g. for group x condition interactions in a mixed design) | ||
|
||
3. at approximately line 229 add | ||
|
||
tmpcfg.fac = cfg.fac; | ||
|
||
This configuration struct field will be used to indicate the factor or interaction of interest. This can be 'a' (first factor), 'b' (second factor) or 'iaxb' for the interaction | ||
|
||
4. then go to resampledesign (in the private folder of your Fieldtrip version) and change line 130 from | ||
|
||
resample = cat(2, blockres{:}); | ||
to | ||
resample(:,cat(2, blocksel{:})) = cat(2, blockres{:}); | ||
|
||
See the following bug note: http://bugzilla.fcdonders.nl/show_bug.cgi?id=1546 | ||
|
||
Now your Fieldtrip version is set up and ready to run permutation ANOVAs. | ||
|
||
You can take a look at the example script and the Sim_indepANOVA_* files (using FtSimLink_indepANOVA; you might want to decrease the number of Monte Carlo simulation to 10 in order to avoid very long running times). Before running the simulation scripts make sure that a copy of anova_cell_mod and the dummy structure are in your working directory (this won�t be necessary if you later run your own analysis in Fieldtrip). The set-up of the design matrix and of the independent and control variables cfg.ivar and cfg.cvar follows the same logic as for one-factorial designs in Fieldtrip (check out the tutorial http://www.fieldtriptoolbox.org/tutorial/cluster_permutation_timelock and http://www.fieldtriptoolbox.org/faq/how_can_i_use_the_ivar_uvar_wvar_and_cvar_options_to_precisely_control_the_permutations?s[]=design&s[]=matrix). | ||
|
||
|
||
The Sim_indepANOVA_* files exemplify how to perform exact permutation tests with restricted permutations and approximate tests on either the raw data or the residuals under a reduced model as described in �Permutation tests for multi-factorial analysis of variance. Marti Anderson and Cajo Ter Braak. Journal of Statistical Computation and Simulation Vol. 73, Iss. 2, 2003. | ||
|
||
You'll have to run the permutation ANOVA for each effect separately by specifying cfg.fac = 'a', 'b' or 'iaxb'. | ||
|
||
|
Oops, something went wrong.