Hi - here's some additional code - I *think* this is the relevant code for what you're asking about. Cheers.
% temporary version of vars, useful for various null tests below grotvars=inormal(vars); grotvars(:,std(grotvars)<1e-10)=[]; grotvars(:,sum(isnan(grotvars)==0)<20)=[]; % permutation testing grotRp=zeros(Nperm,Nkeep+1); clear grotRpval; nullNETr=[]; nullSMr=[]; nullNETv=[]; nullSMv=[]; for j=1:Nperm j [grotAr,grotBr,grotRp(j,1:end-1),grotUr,grotVr,grotstatsr]=canoncorr(uu1,uu2(PAPset(:,j),:)); grotRp(j,end)=mean(grotRp(j,1:end-1)); nullNETr=[nullNETr corr(grotUr(:,1),NET)']; nullSMr=[nullSMr corr(grotVr(:,1),grotvars(PAPset(:,j),:),'rows','pairwise')']; nullNETv=[nullNETv sum(corr(grotUr,NET).^2,2)]; nullSMv=[nullSMv sum(corr(grotVr,grotvars(PAPset(:,j),:),'rows','pairwise').^2,2)]; end Ncca=sum(grotRpval<0.05) % number of significant CCA components % how does the % variance explained compare with the null scenario? grot1=[ sum(corr(grotU,NET).^2,2) prctile(nullNETv,5,2) mean(nullNETv,2) prctile(nullNETv,95,2) sum(corr(uu1,NET).^2,2) ] * 100 / size(NET,2); grot2=[ sum(corr(grotV,grotvars,'rows','pairwise').^2,2) prctile(nullSMv,5,2) mean(nullSMv,2) prctile(nullSMv,95,2) ... sum(corr(uu2,grotvars,'rows','pairwise').^2,2) ] * 100 / size(grotvars,2); I=1:20; figure; subplot(2,1,1); hold on; for i=1:length(I) rectangle('Position',[i-0.5 grot1(i,2) 1 grot1(i,4)-grot1(i,2)],'FaceColor',[0.8 0.8 0.8],'EdgeColor',[0.8 0.8 0.8]); end plot(grot1(I,3),'k'); plot(grot1(I,1),'b'); plot(grot1(I,1),'b.'); % plot(grot1(I,5),'g'); % turned off showing the PCA equivalent plots subplot(2,1,2); hold on; for i=1:length(I) rectangle('Position',[i-0.5 grot2(i,2) 1 grot2(i,4)-grot2(i,2)],'FaceColor',[0.8 0.8 0.8],'EdgeColor',[0.8 0.8 0.8]); end plot(grot2(I,3),'k'); plot(grot2(I,1),'b'); plot(grot2(I,1),'b.'); % plot(grot2(I,5),'g'); > On 27 Apr 2017, at 09:00, Eleanor Wong <eleanor.w...@utah.edu> wrote: > > Hi HCP group, > > I have a question regarding how to compute the variance explained after > running CCA on the HCP data using the code from > http://www.fmrib.ox.ac.uk/datasets/HCP-CCA/ > <http://www.fmrib.ox.ac.uk/datasets/HCP-CCA/>. I ran it on the 461 subject > subset with dimensionality reduced to 100 dimensions. The result from the > code is very similar to the weights provided on the webpage for the HCP900 > dataset, but I was unable to compute the % variance explained in the graphs > of figure 1c) of paper > http://www.nature.com/neuro/journal/v18/n11/full/nn.4125.html > <http://www.nature.com/neuro/journal/v18/n11/full/nn.4125.html>. I tried > looking at the variance of the scores on the top CCA component divided by the > sum of the variance of the scores across all components for the subject > measures and the network data, with the Matlab command: > var(grotU(:,1))/sum(var(grot(U)) but that did not give similar results. > > Thank you for your help. > > Best, > Eleanor > _______________________________________________ > HCP-Users mailing list > HCP-Users@humanconnectome.org > http://lists.humanconnectome.org/mailman/listinfo/hcp-users > --------------------------------------------------------------------------- Stephen M. Smith, Professor of Biomedical Engineering Head of Analysis, Oxford University FMRIB Centre FMRIB, JR Hospital, Headington, Oxford OX3 9DU, UK +44 (0) 1865 222726 (fax 222717) st...@fmrib.ox.ac.uk http://www.fmrib.ox.ac.uk/~steve <http://www.fmrib.ox.ac.uk/~steve> --------------------------------------------------------------------------- Stop the cultural destruction of Tibet <http://smithinks.net/> _______________________________________________ HCP-Users mailing list HCP-Users@humanconnectome.org http://lists.humanconnectome.org/mailman/listinfo/hcp-users