/* MELODIC - Multivariate exploratory linear optimized decomposition into independent components melreport.cc - report generation Christian F. Beckmann, FMRIB Analysis Group Copyright (C) 1999-2013 University of Oxford */ /* Part of FSL - FMRIB's Software Library http://www.fmrib.ox.ac.uk/fsl fsl@fmrib.ox.ac.uk Developed at FMRIB (Oxford Centre for Functional Magnetic Resonance Imaging of the Brain), Department of Clinical Neurology, Oxford University, Oxford, UK LICENCE FMRIB Software Library, Release 5.0 (c) 2012, The University of Oxford (the "Software") The Software remains the property of the University of Oxford ("the University"). The Software is distributed "AS IS" under this Licence solely for non-commercial use in the hope that it will be useful, but in order that the University as a charitable foundation protects its assets for the benefit of its educational and research purposes, the University makes clear that no condition is made or to be implied, nor is any warranty given or to be implied, as to the accuracy of the Software, or that it will be suitable for any particular purpose or for use under any specific conditions. Furthermore, the University disclaims all responsibility for the use which is made of the Software. It further disclaims any liability for the outcomes arising from using the Software. The Licensee agrees to indemnify the University and hold the University harmless from and against any and all claims, damages and liabilities asserted by third parties (including claims for negligence) which arise directly or indirectly from the use of the Software or the sale of any products based on the Software. No part of the Software may be reproduced, modified, transmitted or transferred in any form or by any means, electronic or mechanical, without the express permission of the University. The permission of the University is not required if the said reproduction, modification, transmission or transference is done without financial return, the conditions of this Licence are imposed upon the receiver of the product, and all original and amended source code is included in any transmitted product. You may be held legally responsible for any copyright infringement that is caused or encouraged by your failure to abide by these terms and conditions. You are not permitted under this Licence to use this Software commercially. Use for which any financial return is received shall be defined as commercial use, and includes (1) integration of all or part of the source code or the Software into a product for sale or license by or on behalf of Licensee to third parties or (2) use of the Software or any derivative of it for research with the final aim of developing software products for sale or license to a third party or (3) use of the Software or any derivative of it for research with the final aim of developing non-software products for sale or license to a third party, or (4) use of the Software to provide any service to an external organisation for which payment is received. If you are interested in using the Software commercially, please contact Isis Innovation Limited ("Isis"), the technology transfer company of the University, to negotiate a licence. Contact details are: innovation@isis.ox.ac.uk quoting reference DE/9564. */ #include "newimage/newimageall.h" #include "utils/log.h" #include "melreport.h" #include "melhlprfns.h" #include "miscmaths/miscprob.h" namespace Melodic{ void MelodicReport::IC_rep(MelGMix &mmodel, int cnum, int dim, Matrix ICstats){ if( bool(opts.genreport.value()) ){ addlink(mmodel.get_prefix()+".html",num2str(cnum)); IChtml.setDir(report.getDir(),mmodel.get_prefix()+".html"); {//start IC page IChtml << "
" << endl << "" << "" << endl; } {//output IC stats if(ICstats.Storage()>0&&ICstats.Nrows()>=cnum){ IChtml << fixed << setprecision(2) << std::abs(ICstats(cnum,1)) << " % of explained variance"; if(ICstats.Ncols()>1) IChtml << "; " << std::abs(ICstats(cnum,2)) << " % of total variance"; if(ICstats.Ncols()>2&&opts.addsigchng.value()){ IChtml << "
" < " << endl;
}
}
volume4D " << endl;
}
{//plot time course
IChtml << " " << endl < " << endl;
if(melodat.get_numfiles()>1 && melodat.explained_var.Storage()>0
&& melodat.explained_var.Ncols()>=cnum && opts.varvals.value())
IChtml << "Rank-1 approximation of individual time courses explains "
<< std::abs(melodat.explained_var(cnum)) << "% of variance. " << endl;
}//time series plot
if(!opts.pspec.value())
{//plot frequency
miscplot newplot;
RowVector empty(1);
empty = 0.0;
int fact = int(std::pow(10.0,int(std::log10(float(melodat.get_Tmodes(0).Nrows())))));
if(opts.logPower.value())
newplot.add_ylabel(string("log-Power"));
else
newplot.add_ylabel(string("Power"));
Matrix fmixtc = calc_FFT(melodat.get_Tmodes(cnum-1).Column(1), opts.logPower.value());
newplot.set_Ylabel_fmt("%.0f");
newplot.set_yrange(0.0,1.02*fmixtc.Maximum());
newplot.grid_swapdefault();
newplot.set_xysize(750,150);
if(opts.tr.value()>0.0){
newplot.add_xlabel(string("Frequency (in Hz / ")+num2str(fact)+ " )");
newplot.timeseries(empty | fmixtc.t(),
report.appendDir(string("f")+
num2str(cnum)+".png"),
string("Powerspectrum of timecourse"),
fact/(opts.tr.value()*melodat.get_Tmodes(0).Nrows()), 150,0,2);
}else{
newplot.add_xlabel(string("Frequency (in cycles); ")
+"frequency(Hz)=cycles/("
+num2str(melodat.get_Tmodes(0).Nrows())
+"* TR); period(s)=("
+num2str(melodat.get_Tmodes(0).Nrows())
+"* TR)/cycles"
);
newplot.timeseries(fmixtc.t(),
report.appendDir(string("f")+num2str(cnum)+".png"),
string("Powerspectrum of timecourse"));
}
write_ascii_matrix(report.appendDir(string("f")
+num2str(cnum)+".txt"), fmixtc);
IChtml << " ";
IChtml << " " << endl;
}//frequency plot
{//add T-mode GLM F-stats for full model fit & contrasts
if(melodat.Tdes.Storage() > 0 &&
melodat.glmT.get_beta().Nrows() == melodat.Tdes.Ncols()){
IChtml << " " << endl;
}
if(cnum <= (int)melodat.get_Smodes().size())
{//plot subject mode
Matrix smode;
smode = melodat.get_Smodes(cnum-1);
if(smode.Nrows() > 1){
IChtml << " " << endl < " << endl;
}
{//add S-mode GLM F-stats for full model fit & contrasts
if(melodat.Sdes.Storage() > 0 &&
melodat.glmS.get_beta().Nrows() == melodat.Sdes.Ncols()){
IChtml << " " << endl;
}
}//subject mode plot
if(mmodel.get_threshmaps().Storage()>0&&
(mmodel.get_threshmaps().Ncols() == mmodel.get_data().Ncols())&&
(mmodel.get_threshmaps().Nrows()>1))
{//Output other thresholded IC map
for(int tctr=2; tctr<=mmodel.get_threshmaps().Nrows(); tctr++){
tempVol.setmatrix(mmodel.get_threshmaps().Row(tctr),melodat.get_mask());
volume " << endl;
}
}
{ //finish IC page
IChtml<< " Temporal mode
" <<
"
GLM β's F-test on
full model fit ";
if(melodat.Tcon.Storage() > 0)
IChtml << "Contrasts"< " << endl;
}
}
IChtml << "" << endl;
for(int ctr=1;ctr <= melodat.Tdes.Ncols();ctr++)
IChtml << " PE(" < " << endl;
for(int ctr=1;ctr <= melodat.Tdes.Ncols();ctr++)
IChtml << melodat.glmT.get_beta().Column(cnum).Row(ctr) << " " << endl;
if(melodat.Tcon.Storage() > 0 &&
melodat.Tdes.Ncols() == melodat.Tcon.Ncols()){
IChtml << fixed << setprecision(2) << "
" < F = "<< melodat.glmT.get_f_fmf().Column(cnum) <<
" " << endl;
else
IChtml << fixed << setprecision(5) << " p < " <<
melodat.glmT.get_pf_fmf().Column(cnum) <<
"
dof1 = " << melodat.Tdes.Ncols() << "; dof2 = "
<< melodat.glmT.get_dof() << "
" <
(uncorrected for #comp.)
(uncorrected for #comp.)" < " << endl;
for(int ctr=1; ctr <= melodat.Tcon.Nrows() ; ctr++)
IChtml <<" z =
" <
" <
" << endl;
else
IChtml << fixed << setprecision(5) <<" p < " << melodat.glmT.get_p().Column(cnum).Row(ctr) <<
"
" << endl;
IChtml << " Sessions/Subjects mode
" <<
"
GLM β's F-test on
full model fit ";
if(melodat.Scon.Storage() > 0)
IChtml << "Contrasts"< " << endl;
}
}
IChtml << "" << endl;
for(int ctr=1;ctr <= melodat.Sdes.Ncols();ctr++)
IChtml << " PE(" < " << endl;
for(int ctr=1;ctr <= melodat.Sdes.Ncols();ctr++)
IChtml << melodat.glmS.get_beta().Column(cnum).Row(ctr) << " " << endl;
if(melodat.Scon.Storage() > 0 && melodat.Sdes.Storage() > 0 &&
melodat.Sdes.Ncols() == melodat.Scon.Ncols()){
IChtml << fixed << setprecision(2) << "
" < F = "<< melodat.glmS.get_f_fmf().Column(cnum) <<
" " << endl;
else
IChtml << fixed << setprecision(5) << " p < " <<
melodat.glmS.get_pf_fmf().Column(cnum) <<
"
dof1 = " << melodat.Sdes.Ncols() << "; dof2 = "
<< melodat.glmS.get_dof() << "
" <
(uncorrected for #comp.)
(uncorrected for #comp.)" < " << endl;
for(int ctr=1; ctr <= melodat.Scon.Nrows() ; ctr++)
IChtml <<" z =
" <
" <
" << endl;
else
IChtml << fixed << setprecision(5) <<" p < " << melodat.glmS.get_p().Column(cnum).Row(ctr) <<
"
" << endl;
IChtml << "
This page produced automatically by "
<< " MELODIC Version "
<< version << " - a part of FSL - "
<< "FMRIB Software Library." << endl
<< "