⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rri_mkperm_order.m

📁 绝对经典,老外制作的功能强大的matlab实现PLS_TOOBOX
💻 M
字号:
%RRI_MKPERM_ORDER Generate permutation sample order
%
%   Usage: perm_order = rri_mkperm_order(num_cond, num_subj_lst, nperm)
%
%   This is analogous to mkbootperm sortof....Instead of just making a new 
%   permutation of the design matrix (permuting all rows together), this function
%   gives new arrangements by permuting each subject separately.  This way,
%   there is no possibility of   scan  des     permdes
%				  1    2 0      2 0 <----
%				  2    2 0     -1 -1     |
%                                 3    2 0     -1 1      |  subj1 has same des
%				                         |
%				  1   -1 1      2 0 <----
%
%   See also MKSUBJPERM, RRI_PERM_ORDER
%

%   I (num_cond) - number of conditions per subject in each group
%   I (num_subj_lst) - a list contains number of subjects in all groups
%   I (nperm) - number of permutations
%   O (perm_order) - an index matrix of new order for stacked datamat
%
%   Modified on 23-OCT-2002 by Jimmy Shen to allow any number of groups
%				with different number of subjects
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function perm_order = rri_mkperm_order(num_cond, num_subj_lst, nperm)

    num_grp = length(num_subj_lst);

    %  initialize the perm_order to its size
    %
    perm_order = zeros(sum(num_subj_lst)*num_cond, nperm);
    rand('state',sum(100*clock));

    %  loop through nperm
    %
    for k=1:nperm

        %  loop through groups
        %
        for g=1:num_grp

            %  loop through subjects
            %
            for i=1:num_subj_lst(g)

                temp=randperm(num_cond);

                %  loop through scans
                %
                for j=1:num_cond

                    n = num_subj_lst(g);
                    span = sum(num_subj_lst(1:g-1)) * num_cond;

		    %  eg if there were 3 subj and 3 scans, go through perm_prder
		    %  1,4,7 in 1st loop, 2,5,8 in 2nd loop and 3,6,9 in 3rd loop
		    %  eg if temp is 2 3 1...give the 1st element of perm_order a
		    %  row number equivalent to the (2nd scan, 1st element=4) give
		    %  the 4th element(in the column) row of (3rd scan 1st element=7)
		    %  and give the 7th column element  1st scan and 1st element=1)
		    %  repeat this for the 2,5,8 col elements of perm_order where
		    %  temp=2,3,1 will give 2nd ele of perm_order 2nd scan &2nd ele=5.
		    %  etc for all the other nperms
                    %
                    perm_order(span+(j-1)*n+i,k)=span+(temp(j)-1)*n+i;

                end			%num_cond
	    end			%num_subj_lst
   	end		%num_grp
    end		% nperm

    return;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -