@@ -139,16 +139,34 @@ void PCAPlot::TsqContributionPlot(BarPlot **bar_plots) {
139139 for (size_t j = 0 ; j < orig_x->col ; j++) {
140140 // normalize to avoid dwarf everthing.
141141 double diff = ((orig_x->data [i][j]-colaverage->data [j])/colscaling->data [j]) - ((reconstructed_mx->data [i][j]-colaverage->data [j])/colscaling->data [j]);
142- double squared_diff = diff * diff;
143- sum_squared_diff += squared_diff;
144- spe_contributions.last ()->data [j] = squared_diff;
142+ if (std::isfinite (diff)) {
143+ double squared_diff = diff * diff;
144+ sum_squared_diff += squared_diff;
145+ spe_contributions.last ()->data [j] = std::isfinite (squared_diff) ? squared_diff : 0.0 ;
146+ }
145147 }
146148 spe.push_back (sum_squared_diff);
147149 }
148150
151+ /* READY FOR MIGRATION TO NEW libscientific release
152+ dvector *spe;
153+ initDVector(&spe);
154+ matrix *contributions;
155+ initMatrix(&contributions);
156+ PCATsqContributions(
157+ orig_x,
158+ projects->value(pid)->getPCAModel(mid)->Model(),
159+ nlv,
160+ spe,
161+ contributions);
162+
163+ // conversion to be accepted by barplot
164+ QList<dvector *> spe_contributions;
165+ */
149166 QStringList windowtitles;
150167 for (size_t i = 0 ; i < orig_x->row ; i++){
151168 windowtitles.append (QString (" %1 - Sample %2 - Total SPE = %3" ).arg (projectname).arg (objnames[i]).arg (QString::number (spe[i], ' f' , 4 )));
169+ // spe_contributions.append(getMatrixRow(contributions, i)); READY FOR MIGRATION TO NEW libscientific release
152170 }
153171
154172 auto temp_plot = std::make_unique<BarPlot>(
0 commit comments