nets_netweb.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. %
  2. % nets_netweb - create interactive web-page netmat viewer
  3. % Paul McCarthy & Steve Smith, 2014
  4. %
  5. % THIS DOES NOT WORK IN OCTAVE BECAUSE THE OCTAVE statistics PACKAGE IS MISSING THE cluster FUNCTION
  6. %
  7. % nets_netweb(netF,netP,DD,sumpics,netwebdir)
  8. % netF is typically the full-correlation group netmat (e.g. Znet1 or Mnet1)
  9. % netP is typically the partial-correlation group netmat (e.g. Znet2 or Mnet2)
  10. % DD is the list of good nodes (e.g. ts.DD - needed to map the current set of nodes back to originals)
  11. % sumpics is the name of the directory containing summary pictures for each component, without the .sum suffix
  12. % netwebdir is the name of the output folder created to contain the netweb web pages
  13. %
  14. % e.g.: nets_netweb(Znet1,Znet2,ts.DD,'groupICA_d60/melodic_IC','my_netweb')
  15. %
  16. function nets_netweb(netF,netP,DD,sumpics,netwebdir);
  17. % replicate functionality from nets_hierarchy
  18. grot=prctile(abs(netF(:)),99); netmatL=netF/grot; netmatH=netP/grot;
  19. usenet=netmatL; usenet(usenet<0)=0;
  20. N=size(netmatL,1); grot=prctile(abs(usenet(:)),99); usenet=max(min(usenet/grot,1),-1)/2;
  21. for J = 1:N, for I = 1:J-1, y((I-1)*(N-I/2)+J-I) = 0.5 - usenet(I,J); end; end;
  22. linkages=linkage(y,'ward');
  23. set(0,'DefaultFigureVisible','off');figure;[~,~,hier]=dendrogram(linkages,0,'colorthreshold',0.75);close;set(0,'DefaultFigureVisible','on');
  24. clusters=cluster(linkages,'maxclust',10)';
  25. % copy javascript stuff into place
  26. system(sprintf('mkdir -p %s; (cd %s/netjs; tar cf - *) | (cd %s; tar xf -)',netwebdir,fileparts(which('nets_netweb')),netwebdir));
  27. NP=sprintf('%s/data/dataset1',netwebdir);
  28. save(sprintf('%s/Znet1.txt',NP),'netF','-ascii');
  29. save(sprintf('%s/Znet2.txt',NP),'netP','-ascii');
  30. save(sprintf('%s/hier.txt',NP),'hier','-ascii');
  31. save(sprintf('%s/linkages.txt',NP),'linkages','-ascii');
  32. save(sprintf('%s/clusters.txt',NP),'clusters','-ascii');
  33. mkdir(sprintf('%s/melodic_IC_sum.sum',NP));
  34. for i=1:length(DD)
  35. system(sprintf('/bin/cp %s.sum/%.4d.png %s/melodic_IC_sum.sum/%.4d.png',sumpics,DD(i)-1,NP,i-1));
  36. end
  37. sprintf('now you can open the following in a web browser: %s/index.html',netwebdir)