Home > fmri > simulate > counter_sim.m

counter_sim

PURPOSE ^

counter_sim.m

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 counter_sim.m

 Illustrates that there is no theoretical difference between counter.m and
 randperm.  Randperm is faster

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % counter_sim.m
0002 %
0003 % Illustrates that there is no theoretical difference between counter.m and
0004 % randperm.  Randperm is faster
0005 %
0006 %
0007 
0008 % 11/24/03  Petr Janata
0009 
0010 ntrials = 20;
0011 ncond = 4;
0012 total_trials = ncond*ntrials;
0013 
0014 % Create a list of 4 conditions, 20 trials each
0015 fprintf('Creating design matrix with randperm ...\n');
0016 X = reshape(ones(ntrials,1)*(1:ncond),total_trials,1);
0017 
0018 % Create a dummy coded matrix with conditions in columns.  Randomize assignment
0019 % of condition to each trial using randperm
0020 X = full(sparse(1:total_trials,X(randperm(total_trials)),1));
0021 
0022 % Eliminate the 4th condition
0023 X(:,ncond) = [];
0024 
0025 % Create a similar matrix using counter.m for the randomization
0026 fprintf('Creating desing matrix with counter ...\n');
0027 [c] = counter(ncond, ntrials*ncond);
0028 
0029 Y = full(sparse(1:total_trials,c,1));
0030 Y(:,ncond) = [];
0031 
0032 % Now dump the correlation matrix for each design matrix
0033 
0034 fprintf('Correlation matrix generated using randperm:\n')
0035 corrcoef(X)
0036 
0037 fprintf('\nCorrelation matrix generated using counter:\n')
0038 corrcoef(Y)

Generated on Wed 20-Mar-2019 04:00:51 by m2html © 2003