14 mainwindow(mainwindow)
28 if (command ==
"GA (fixed elemental contribution)")
32 if (command ==
"GA (disregarding targets)")
36 if (command ==
"Levenberg-Marquardt")
40 if (command ==
"Levenberg-Marquardt-Batch")
45 if (command ==
"OM-Size Correct")
53 if (command ==
"CovMat")
58 if (command ==
"CorMat")
67 if (command ==
"DFAOnevsRest")
72 if (command ==
"DFAM")
77 if (command ==
"SDFA")
83 if (command ==
"SDFAM")
88 if (command ==
"SDFAOnevsRest")
98 if (command ==
"KS-individual")
102 if (command ==
"CMB Bayesian")
106 if (command ==
"CMB Bayesian-Batch")
110 if (command ==
"Test CMB Bayesian")
123 if (command ==
"Bracketing Analysis")
128 if (command ==
"Bracketing Analysis Batch")
133 if (command ==
"BoxCox")
138 if (command ==
"Outlier")
143 if (command ==
"EDP")
148 if (command ==
"EDPM")
152 if (command ==
"ANOVA")
157 if (command ==
"Error_Analysis")
162 if (command ==
"Source_Verify")
167 if (command ==
"AutoSelect")
181 if (NegativeCheckResults.size()>0)
184 for (
unsigned int i=0; i<NegativeCheckResults.size(); i++)
186 message += QString::fromStdString(NegativeCheckResults[i]+
"\n");
188 QMessageBox::warning(
mainwindow,
"SedSAT3",message, QMessageBox::Ok);
198 for (map<
string,vector<string>>::iterator it = negative_elements.begin(); it!=negative_elements.end(); it++)
200 if (it->second.size()>0)
201 { message +=
"For target sample '" + QString::fromStdString(it->first) +
":\n";
202 for (
unsigned int i=0; i<it->second.size(); i++)
204 message += QString::fromStdString(
"\t" + it->second[i]) +
"\n";
211 { QMessageBox::warning(
mainwindow,
"SedSAT3",message, QMessageBox::Ok);
221 bool organic_size_correction;
222 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
224 organic_size_correction =
true;
225 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
227 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
233 organic_size_correction =
false;
237 arguments.at(
"Sample"),
238 organic_size_correction,
239 Data()->GetElementInformation()
248 GA = std::make_unique<CGA<SourceSinkData>>(&corrected_data);
250 GA->SetRunTimeWindow(rtw);
251 GA->SetProperties(arguments);
252 GA->InitiatePopulation();
257 ResultItem result_contribution =
GA->Model_out.GetContribution();
263 ResultItem result_modeled_vs_measured =
GA->Model_out.GetObservedvsModeledElementalProfile();
268 ResultItem result_modeled_vs_measured_isotope =
GA->Model_out.GetObservedvsModeledElementalProfile_Isotope();
273 ResultItem result_calculated_means =
GA->Model_out.GetCalculatedElementMeans();
278 ResultItem result_estimated_means =
GA->Model_out.GetEstimatedElementMean();
283 ResultItem result_calculated_mu =
GA->Model_out.GetCalculatedElementMu();
288 ResultItem result_estimated_mu =
GA->Model_out.GetEstimatedElementMu();
293 ResultItem result_calculated_sigma =
GA->Model_out.GetCalculatedElementSigma();
298 ResultItem result_estimated_sigma =
GA->Model_out.GetEstimatedElementSigma();
313 bool organic_size_correction;
314 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
316 organic_size_correction =
true;
317 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
319 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
325 organic_size_correction =
false;
329 arguments.at(
"Sample"),
330 organic_size_correction,
331 Data()->GetElementInformation()
339 arguments.at(
"Sample"),
344 GA = std::make_unique<CGA<SourceSinkData>>(&corrected_data);
346 GA->SetRunTimeWindow(rtw);
347 GA->SetProperties(arguments);
348 GA->InitiatePopulation();
353 ResultItem result_contribution =
GA->Model_out.GetContribution();
371 arguments.at(
"Sample"),
376 GA = std::make_unique<CGA<SourceSinkData>>(
Data());
378 GA->SetRunTimeWindow(rtw);
379 GA->SetProperties(arguments);
380 GA->InitiatePopulation();
385 ResultItem result_calculated_means =
GA->Model_out.GetCalculatedElementMeans();
388 ResultItem result_estimated_means =
GA->Model_out.GetEstimatedElementMean();
391 ResultItem result_calculated_stds =
GA->Model_out.GetCalculatedElementSigma();
394 ResultItem result_estimated_stds =
GA->Model_out.GetEstimatedElementSigma();
404 bool organic_size_correction;
405 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
407 organic_size_correction =
true;
408 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
410 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
416 organic_size_correction =
false;
422 arguments.at(
"Sample"),
423 organic_size_correction,
424 Data()->GetElementInformation()
433 if (arguments.at(
"Softmax transformation") ==
"true")
467 bool organic_size_correction;
468 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
470 organic_size_correction =
true;
471 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
473 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
479 organic_size_correction =
false;
487 std::map<std::string, std::vector<std::string>> negative_elements;
489 if (arguments.at(
"Softmax transformation") ==
"true")
493 organic_size_correction,
501 organic_size_correction,
506 if (negative_elements.size() > 0)
518 contributions_result_item.
SetName(
"Levenberg-Marquardt-Batch");
519 contributions_result_item.
SetResult(contributions);
537 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
538 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
546 arguments.at(
"Sample")
551 results.
SetName(
"Corrected Elemental Profiles for Target" + arguments.at(
"Sample"));
553 for (
size_t i = 0; i < result_items.size(); i++)
563 if (arguments.at(
"Organic Matter constituent") ==
"" &&
564 arguments.at(
"Particle Size constituent") ==
"")
566 QMessageBox::information(
569 "At least one of Organic Matter constituent and Particle Size constituent must be selected",
577 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
585 double p_value_threshold = QString::fromStdString(arguments.at(
"P-value threshold")).toDouble();
587 if (arguments.at(
"Equation") ==
"Linear")
590 arguments.at(
"Organic Matter constituent"),
591 arguments.at(
"Particle Size constituent"),
599 arguments.at(
"Organic Matter constituent"),
600 arguments.at(
"Particle Size constituent"),
607 arguments.at(
"Organic Matter constituent"),
608 arguments.at(
"Particle Size constituent")
611 for (std::map<std::string, Elemental_Profile_Set>::iterator it =
Data()->begin();
617 it->second.SetRegressionModels(transformed_data[it->first].GetRegressionModels());
621 std::vector<ResultItem> regression_results = transformed_data.
GetMLRResults();
623 for (
size_t i = 0; i < regression_results.size(); i++)
633 results.
SetName(
"Covariance Matrix for " + arguments.at(
"Source/Target group"));
636 covariance_matrix_item.
SetName(
"Covariance Matrix for " + arguments.at(
"Source/Target group"));
642 Data()->at(arguments.at(
"Source/Target group")).CalculateCovarianceMatrix()
645 covariance_matrix_item.
SetResult(covariance_matrix);
654 results.
SetName(
"Correlation Matrix for " + arguments.at(
"Source/Target group"));
657 correlation_matrix_item.
SetName(
"Correlation Matrix");
659 correlation_matrix_item.
setTableTitle(
"Correlation Matrix for source group '" +
660 arguments.at(
"Source/Target group") +
"'");
664 double threshold = QString::fromStdString(arguments.at(
"Threshold")).toDouble();
665 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
666 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
674 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
676 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
678 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
682 arguments.at(
"OM and Size Correct based on target sample"),
684 Data()->GetElementInformation()
689 transformed_data.at(arguments.at(
"Source/Target group")).CalculateCorrelationMatrix()
695 correlation_matrix_item.
SetResult(correlation_matrix);
703 if (arguments.at(
"Source/Target group I") == arguments.at(
"Source/Target group II"))
705 QMessageBox::warning(
mainwindow,
"SedSAT3",
"The selected sources must be different", QMessageBox::Ok);
712 results.
SetName(
"DFA between " + arguments.at(
"Source/Target group I") +
713 "&" + arguments.at(
"Source/Target group II"));
715 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
716 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
720 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
722 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
724 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
728 arguments.at(
"OM and Size Correct based on target sample"),
730 Data()->GetElementInformation()
742 if (arguments.at(
"Box-cox transformation") ==
"true")
748 arguments.at(
"Source/Target group I"),
749 arguments.at(
"Source/Target group II")
754 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Singular matrix in within group scatter matrix!\n", QMessageBox::Ok);
761 dfa_p_value.
SetName(
"Chi-squared P-Value");
771 dfa_f_test_p_value.
SetName(
"F-test P-Value");
775 dfa_f_test_p_value.
SetResult(f_test_p_value);
780 dfa_projected.
SetName(
"Projected Elemental Profiles");
791 dfa_eigen_vector.
SetName(
"Eigen vector");
797 dfa_eigen_vector.
SetResult(eigen_vector);
810 results.
SetName(
"DFA between " + arguments.at(
"Source group") +
"& the rest");
812 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
813 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
817 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
819 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
821 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
825 arguments.at(
"OM and Size Correct based on target sample"),
827 Data()->GetElementInformation()
839 if (arguments.at(
"Box-cox transformation") ==
"true")
845 arguments.at(
"Source group")
850 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Singular matrix in within group scatter matrix!\n", QMessageBox::Ok);
857 dfa_p_value.
SetName(
"Chi-squared P-Value");
867 dfa_f_test_p_value.
SetName(
"F-test P-Value");
871 dfa_f_test_p_value.
SetResult(f_test_p_value);
876 dfa_projected.
SetName(
"Projected Elemental Profiles");
887 dfa_eigen_vector.
SetName(
"Eigen vector");
893 dfa_eigen_vector.
SetResult(eigen_vector);
908 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
909 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
913 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
915 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
917 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
921 arguments.at(
"OM and Size Correct based on target sample"),
923 Data()->GetElementInformation()
938 if (arguments.at(
"Box-cox transformation") ==
"true")
947 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Singular matrix in within group scatter matrix!\n", QMessageBox::Ok);
954 dfa_p_value.
SetName(
"Chi-squared P-Value");
964 dfa_f_test_p_value.
SetName(
"F-test P-Value");
968 dfa_f_test_p_value.
SetResult(f_test_p_value);
973 dfa_projected.
SetName(
"Multiway Projected Elemental Profiles");
984 dfa_eigen_vectors.
SetName(
"Eigen vector");
990 dfa_eigen_vectors.
SetResult(eigen_vectors);
1000 if (arguments.at(
"Source/Target group I") == arguments.at(
"Source/Target group II"))
1002 QMessageBox::warning(
mainwindow,
"SedSAT3",
"The selected sources must be different", QMessageBox::Ok);
1009 results.
SetName(
"Stepwise DFA between " + arguments.at(
"Source/Target group I") +
1010 "&" + arguments.at(
"Source/Target group II"));
1012 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1013 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1017 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1021 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
1025 arguments.at(
"OM and Size Correct based on target sample"),
1027 Data()->GetElementInformation()
1042 if (arguments.at(
"Box-cox transformation") ==
"true")
1050 arguments.at(
"Source/Target group I"),
1051 arguments.at(
"Source/Target group II")
1054 if (sdfa_results[0].size() == 0)
1056 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Singular matrix in within group scatter matrix!\n", QMessageBox::Ok);
1063 sdfa_p_values.
SetName(
"Chi-squared P-Values");
1075 sdfa_wilks_lambda.
SetName(
"Wilks' Lambda");
1081 sdfa_wilks_lambda.
SetResult(wilks_lambda_vector);
1087 sdfa_f_test_p_value.
SetName(
"F-test P-Value");
1093 sdfa_f_test_p_value.
SetResult(f_test_p_value);
1106 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1107 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1111 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1115 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
1119 arguments.at(
"OM and Size Correct based on target sample"),
1121 Data()->GetElementInformation()
1136 if (arguments.at(
"Box-cox transformation") ==
"true")
1145 if (sdfa_results[0].size() == 0)
1147 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Singular matrix in within group scatter matrix!\n", QMessageBox::Ok);
1154 sdfa_p_values.
SetName(
"Chi-squared P-Values");
1165 sdfa_selected.
SetName(
"Elements to be Selected");
1175 if (arguments.at(
"Modify the included elements based on the results") ==
"true")
1180 for (
size_t i = 0; i < selected.size(); i++)
1182 p_vector_selected->
append(selected[i], p_vector->
valueAt(i));
1185 sdfa_selected.
SetResult(p_vector_selected);
1191 sdfa_wilks_lambda.
SetName(
"Wilks' Lambda");
1197 sdfa_wilks_lambda.
SetResult(wilks_lambda_vector);
1203 sdfa_f_test_p_value.
SetName(
"F-test P-Value");
1209 sdfa_f_test_p_value.
SetResult(f_test_p_value);
1220 results.
SetName(
"Stepwise DFA between " + arguments.at(
"Source group") +
"& the rest");
1222 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1223 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1227 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1231 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
1235 arguments.at(
"OM and Size Correct based on target sample"),
1237 Data()->GetElementInformation()
1252 if (arguments.at(
"Box-cox transformation") ==
"true")
1260 arguments.at(
"Source group")
1263 if (sdfa_results[0].size() == 0)
1265 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Singular matrix in within group scatter matrix!\n", QMessageBox::Ok);
1272 sdfa_p_values.
SetName(
"Chi-squared P-Values");
1284 sdfa_wilks_lambda.
SetName(
"Wilks' Lambda");
1290 sdfa_wilks_lambda.
SetResult(wilks_lambda_vector);
1296 sdfa_f_test_p_value.
SetName(
"F-test P-Value");
1302 sdfa_f_test_p_value.
SetResult(f_test_p_value);
1310 results.
SetName(
"Kolmogorov–Smirnov statististics for " + arguments.at(
"Source/Target group"));
1313 ks_item.
SetName(
"Kolmogorov–Smirnov statististics for " + arguments.at(
"Source/Target group"));
1318 if (arguments.at(
"Distribution") ==
"Normal")
1322 else if (arguments.at(
"Distribution") ==
"Lognormal")
1328 Data()->at(arguments.at(
"Source/Target group")).CalculateKolmogorovSmirnovStatistics(dist)
1340 results.
SetName(
"Kolmogorov–Smirnov statististics for constituent " +
1341 arguments.at(
"Constituent") +
" in group " +
1342 arguments.at(
"Source/Target group"));
1345 ks_item.
SetName(
"Kolmogorov–Smirnov statististics for constituent " +
1346 arguments.at(
"Constituent") +
" in group " +
1347 arguments.at(
"Source/Target group"));
1351 if (arguments.at(
"Distribution") ==
"Normal")
1355 else if (arguments.at(
"Distribution") ==
"Lognormal")
1361 Data()->at(arguments.at(
"Source/Target group"))
1375 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
1377 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
1379 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
1385 MCMC = std::make_unique<CMCMC<SourceSinkData>>();
1389 rtw->SetTitle(
"Acceptance Rate", 0);
1390 rtw->SetTitle(
"Purturbation Factor", 1);
1391 rtw->SetTitle(
"Log posterior value", 2);
1392 rtw->SetYAxisTitle(
"Acceptance Rate", 0);
1393 rtw->SetYAxisTitle(
"Purturbation Factor", 1);
1394 rtw->SetYAxisTitle(
"Log posterior value", 2);
1411 contribution_matrix_item.
SetName(
"Contribution Range Matrix");
1414 contribution_matrix_item.
SetResult(contributions);
1418 rtw->SetProgress(1);
1431 mcmc_samples.SetName(
"MCMC samples for testing MCMC'");
1438 mcmc_for_testing->
Model = &testing_model;
1442 rtw->
SetTitle(
"Acceptance Rate", 0);
1443 rtw->
SetTitle(
"Purturbation Factor", 1);
1444 rtw->
SetTitle(
"Log posterior value", 2);
1451 std::vector<double> mins;
1452 std::vector<double> maxs;
1453 mins.push_back(0.1);
1455 maxs.push_back(1.0);
1461 mcmc_for_testing->
SetProperty(
"number_of_samples", arguments.at(
"Number of samples"));
1462 mcmc_for_testing->
SetProperty(
"number_of_chains", arguments.at(
"Number of chains"));
1463 mcmc_for_testing->
SetProperty(
"number_of_burnout_samples", arguments.at(
"Samples to be discarded (burnout)"));
1468 std::string folder_path;
1469 if (!QString::fromStdString(arguments.at(
"samples_file_name")).contains(
"/"))
1475 mcmc_for_testing->
step(
1476 QString::fromStdString(arguments.at(
"Number of chains")).toInt(),
1477 QString::fromStdString(arguments.at(
"Number of samples")).toInt(),
1478 folder_path + arguments.at(
"samples_file_name"),
1489 *dists =
samples->distribution(
1491 QString::fromStdString(arguments.at(
"Samples to be discarded (burnout)")).toInt()
1494 distribution_result_item.
SetName(
"Posterior Distributions");
1497 distribution_result_item.
SetResult(dists);
1501 delete mcmc_for_testing;
1508 results.
SetName(
"Distribution fitting results for '" + arguments.at(
"Constituent") +
1509 "' in '" + arguments.at(
"Source/Target group"));
1513 distribution_item.
SetName(
"Fitted PDF for '" + arguments.at(
"Constituent") +
1514 "' in '" + arguments.at(
"Source/Target group"));
1522 cumulative_distribution_item.
SetName(
"Fitted CDF for '" + arguments.at(
"Constituent") +
1523 "' in '" + arguments.at(
"Source/Target group"));
1530 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1534 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1538 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
1542 arguments.at(
"OM and Size Correct based on target sample"),
1544 Data()->GetElementInformation()
1555 if (arguments.at(
"Box-cox transformation") ==
"true")
1561 CMBTimeSeriesSet fitted_normal = transformed_data.at(arguments.at(
"Source/Target group"))
1567 if (arguments.at(
"Box-cox transformation") !=
"true")
1569 fitted_lognormal = transformed_data.at(arguments.at(
"Source/Target group"))
1575 CMBTimeSeriesSet observed_fitted_normal_cdf = transformed_data.at(arguments.at(
"Source/Target group"))
1581 if (arguments.at(
"Box-cox transformation") !=
"true")
1583 observed_fitted_lognormal_cdf = transformed_data.at(arguments.at(
"Source/Target group"))
1590 pdf->append(fitted_normal[
"Observed"]);
1591 pdf->append(fitted_normal[
"Fitted"]);
1592 if (arguments.at(
"Box-cox transformation") !=
"true")
1594 pdf->append(fitted_lognormal[
"Fitted"]);
1596 pdf->setname(0,
"Samples");
1597 pdf->setname(1,
"Normal");
1598 if (arguments.at(
"Box-cox transformation") !=
"true")
1600 pdf->setname(2,
"Log-normal");
1605 cdf->append(observed_fitted_normal_cdf[
"Observed"]);
1606 cdf->append(observed_fitted_normal_cdf[
"Fitted"]);
1607 if (arguments.at(
"Box-cox transformation") !=
"true")
1609 cdf->append(observed_fitted_lognormal_cdf[
"Fitted"]);
1611 cdf->setname(0,
"Observed");
1612 cdf->setname(1,
"Normal");
1613 if (arguments.at(
"Box-cox transformation") !=
"true")
1615 cdf->setname(2,
"Log-normal");
1619 cumulative_distribution_item.
SetResult(cdf);
1629 results.
SetName(
"Bracketing analysis for sample '" + arguments.at(
"Sample") +
"'");
1632 bracketing_result_item.
SetName(
"Bracketing results");
1637 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1638 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1639 bool correct_based_on_size_and_organic_matter = (arguments.at(
"Correct based on size and organic matter") ==
"true");
1644 correct_based_on_size_and_organic_matter,
1645 arguments.at(
"Sample")
1652 transformed_data.
BracketTest(arguments.at(
"Sample"),
false)
1656 bracketing_result_item.
SetResult(bracketing_result);
1667 bracketing_result_item.
SetName(
"Bracketing results");
1673 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1674 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1675 bool correct_based_on_size_and_organic_matter = (arguments.at(
"Correct based on size and organic matter") ==
"true");
1680 if (correct_based_on_size_and_organic_matter)
1684 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
1690 Data()->BracketTest(
1691 correct_based_on_size_and_organic_matter,
1698 bracketing_result_item.
SetResult(bracketing_result);
1706 results.
SetName(
"Box-Cox parameter for '" + arguments.at(
"Source/Target group") +
"'");
1709 boxcox_result_item.
SetName(
"Box-Cox parameters");
1716 Data()->at(arguments.at(
"Source/Target group")).CalculateBoxCoxParameters()
1719 boxcox_result_item.
SetResult(boxcox_params);
1727 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1728 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1739 results.
SetName(
"Outlier analysis for '" + arguments.at(
"Source/Target group") +
"'");
1742 outlier_result_item.
SetName(
"Outlier Analysis");
1748 double threshold = QString::fromStdString(arguments.at(
"Threshold")).toDouble();
1751 transformed_data.at(arguments.at(
"Source/Target group")).DetectOutliers(-threshold, threshold)
1757 outlier_result_item.
SetResult(outlier_matrix);
1766 arguments.at(
"Source/Target group I") +
"' and '" +
1767 arguments.at(
"Source/Target group II") +
"'");
1769 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1773 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1777 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
1781 arguments.at(
"OM and Size Correct based on target sample"),
1783 Data()->GetElementInformation()
1794 if (arguments.at(
"Box-cox transformation") ==
"true")
1801 edp_result_std.
SetName(
"Discreminant difference to standard deviation ratio");
1809 arguments.at(
"Source/Target group I"),
1810 arguments.at(
"Source/Target group II"),
1817 edp_result_std.
SetResult(edp_profile_set);
1819 edp_result_std.
setYAxisTitle(
"Standard deviation to mean ratio");
1824 edp_result_percent.
SetName(
"Discriminat fraction");
1827 edp_result_percent.
setYAxisTitle(
"Percentage discriminated");
1833 arguments.at(
"Source/Target group I"),
1834 arguments.at(
"Source/Target group II")
1840 edp_result_percent.
SetResult(edp_profile_set_percent);
1847 edp_result_p_value.
SetName(
"Discriminat p-value");
1856 arguments.at(
"Source/Target group I"),
1857 arguments.at(
"Source/Target group II"),
1864 edp_result_p_value.
SetResult(edp_profile_set_p_value);
1865 edp_profile_set_p_value->
SetLimit(
_range::high, aquiutils::atof(arguments.at(
"P-value threshold")));
1876 bool include_target = (arguments.at(
"Include target samples") ==
"true");
1877 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1881 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1885 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
1889 arguments.at(
"OM and Size Correct based on target sample"),
1891 Data()->GetElementInformation()
1902 if (arguments.at(
"Box-cox transformation") ==
"true")
1907 results.
SetName(
"Multi-way element discriminant power between '" +
1908 arguments.at(
"Source/Target group I") +
"' and '" +
1909 arguments.at(
"Source/Target group II") +
"'");
1913 edp_result_std.
SetName(
"Multi-way discreminant difference to standard deviation ratio");
1925 edp_result_std.
SetResult(edp_profile_set);
1930 edp_result_percent.
SetName(
"Multi-way discriminat fraction");
1933 edp_result_percent.
setYAxisTitle(
"Percentage discriminated");
1943 edp_result_percent.
SetResult(edp_profile_set_percent);
1948 edp_p_value.
SetName(
"Multi-way discriminat p-value");
1961 edp_p_value.
SetResult(edp_profile_set_p_value);
1962 edp_profile_set_p_value->
SetLimit(
_range::high, aquiutils::atof(arguments.at(
"P-value threshold")));
1971 bool log_transformation = (arguments.at(
"Log Transformation") ==
"true");
1972 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1973 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1977 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1981 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
1985 arguments.at(
"OM and Size Correct based on target sample"),
1987 Data()->GetElementInformation()
1998 if (arguments.at(
"Box-cox transformation") ==
"true")
2001 log_transformation =
false;
2007 anova_results.
SetName(
"ANOVA");
2023 if (arguments.at(
"Modify the included elements based on the results") ==
"true")
2027 aquiutils::atof(arguments.at(
"P-value threshold"))
2043 bool organic_size_correction;
2044 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
2046 organic_size_correction =
true;
2047 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
2049 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
2055 organic_size_correction =
false;
2061 arguments.at(
"Sample"),
2062 organic_size_correction,
2063 Data()->GetElementInformation()
2071 bool softmax = (arguments.at(
"Softmax transformation") ==
"true");
2075 bool outcome = corrected_data.
BootStrap(
2077 aquiutils::atof(arguments.at(
"Pecentage eliminated")),
2078 aquiutils::atoi(arguments.at(
"Number of realizations")),
2079 arguments.at(
"Sample"),
2092 bool organic_size_correction;
2093 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
2095 organic_size_correction =
true;
2096 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
2098 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
2104 organic_size_correction =
false;
2115 bool softmax = (arguments.at(
"Softmax transformation") ==
"true");
2119 arguments.at(
"Source Group"),
2121 organic_size_correction
2126 results.
SetName(
"Source verification for source'" + arguments.at(
"Source Group") +
"'");
2132 contributions_result_item.
SetName(
"Source Verification");
2133 contributions_result_item.
SetResult(contributions);
2157 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
2159 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
2161 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
2165 arguments.at(
"OM and Size Correct based on target sample"),
2167 Data()->GetElementInformation()
2178 bool isotopes = (arguments.at(
"Include Isotopes") ==
"true");
2184 edp_p_value.
SetName(
"Multi-way discriminat p-value");
2197 edp_p_value.
SetResult(edp_profile_set_p_value);
2203 aquiutils::atoi(arguments.at(
"Number of elements from each pair"))
2209 selected_elements.
SetName(
"Selected Elements");
2217 if (arguments.at(
"Modify the included elements based on the results") ==
"true")
2227 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
2229 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
2231 QMessageBox::warning(
mainwindow,
"SedSAT3",
"Perform Organic Matter and Size Correction first!\n", QMessageBox::Ok);
2237 MCMC = std::make_unique<CMCMC<SourceSinkData>>();
2241 rtw->SetTitle(
"Acceptance Rate", 0);
2242 rtw->SetTitle(
"Purturbation Factor", 1);
2243 rtw->SetTitle(
"Log posterior value", 2);
2244 rtw->SetYAxisTitle(
"Acceptance Rate", 0);
2245 rtw->SetYAxisTitle(
"Purturbation Factor", 1);
2246 rtw->SetYAxisTitle(
"Log posterior value", 2);
2251 arguments.at(
"Sample"),
2265 rtw->SetProgress(1);
Matrix class with labeled rows and columns for Chemical Mass Balance analysis.
void SetBooleanValue(bool val)
Sets boolean display mode for table widget.
Collection of time series with labels and observed values.
Collection of named CMBVectorSet objects for hierarchical data organization.
Collection of named CMBVector objects for multi-variable analysis.
Vector class with string labels for Chemical Mass Balance analysis.
CMBVector ExtractWithinRange(const double &lowval, const double &highval) const
Extracts elements with values within specified range.
void SetBooleanValue(bool val)
Sets boolean display mode for table widget.
CMBVector ExtractUpToMinimum() const
Extracts elements up to first minimum value.
void append(const string &label, const double &val)
Appends a labeled element to the vector.
double valueAt(int i) const
Gets value at specified index.
vector< string > Labels() const
Gets all element labels.
Markov Chain Monte Carlo sampler for Bayesian parameter estimation.
bool SetProperty(const string &varname, const string &value)
Set MCMC properties from string key-value pairs.
bool step(int k, int chain_counter)
Perform single MCMC step for one chain.
T * Model
Pointer to the model object being calibrated.
void initialize(CMBTimeSeriesSet *results, bool random=false)
Initialize MCMC chains with starting parameter values.
CMBTimeSeriesSet CreateCDFComparison(distribution_type dist_type) const
Create comparison of empirical vs fitted CDF.
CMBTimeSeriesSet CreateFittedDistribution(distribution_type dist_type) const
Create fitted distribution visualization.
bool ExecuteOutlierAnalysis(const std::map< std::string, std::string > &arguments)
Executes outlier detection analysis for a source/target group.
bool ExecuteTestCMBBayesian(const std::map< std::string, std::string > &arguments)
Executes MCMC test with a simple analytical model.
bool ExecuteCMBBayesian(const std::map< std::string, std::string > &arguments)
Executes Bayesian Chemical Mass Balance using MCMC sampling.
bool ExecuteDFAM(const std::map< std::string, std::string > &arguments)
Executes multi-way Discriminant Function Analysis across all groups.
bool ExecuteDFA(const std::map< std::string, std::string > &arguments)
Executes Discriminant Function Analysis between two groups.
bool ExecuteSDFAM(const std::map< std::string, std::string > &arguments)
Executes multi-way Stepwise Discriminant Function Analysis across all groups.
bool ExecuteBoxCox(const std::map< std::string, std::string > &arguments)
Calculates optimal Box-Cox transformation parameters.
bool ExecuteKolmogorovSmirnovIndividual(const std::map< std::string, std::string > &arguments)
Executes Kolmogorov-Smirnov test for a single constituent in a group.
bool CheckNegativeElements(SourceSinkData *data=nullptr)
Validates that all element concentrations are non-negative.
bool ExecuteCMBBayesianBatch(const std::map< std::string, std::string > &arguments)
Executes Bayesian Chemical Mass Balance across all target samples.
bool ExecuteAutoSelect(const std::map< std::string, std::string > &arguments)
Executes automatic element selection based on discriminant power.
bool ExecuteSDFA(const std::map< std::string, std::string > &arguments)
Executes Stepwise Discriminant Function Analysis between two groups.
bool ExecuteBracketingAnalysisBatch(const std::map< std::string, std::string > &arguments)
Executes bracketing analysis across all target samples.
bool ExecuteANOVA(const std::map< std::string, std::string > &arguments)
Executes Analysis of Variance (ANOVA) for element discrimination.
QString workingfolder
Output directory path.
std::unique_ptr< CGA< SourceSinkData > > GA
Genetic Algorithm optimizer (owned)
bool ExecuteGA_NoTargets(const std::map< std::string, std::string > &arguments)
Executes Genetic Algorithm disregarding target constraints.
bool ExecuteGA(const std::map< std::string, std::string > &arguments)
Executes Genetic Algorithm optimization.
bool ExecuteSourceVerify(const std::map< std::string, std::string > &arguments)
Executes source verification analysis.
bool ExecuteGA_FixedProfile(const std::map< std::string, std::string > &arguments)
Executes Genetic Algorithm with fixed elemental profiles.
bool ExecuteMLR(const std::map< std::string, std::string > &arguments)
Executes multiple linear regression versus organic matter and particle size.
MainWindow * mainwindow
Non-owning pointer to parent window.
bool ExecuteDistributionFitting(const std::map< std::string, std::string > &arguments)
Executes distribution fitting analysis for a constituent.
bool ExecuteLevenbergMarquardtBatch(const std::map< std::string, std::string > &arguments)
Executes Levenberg-Marquardt optimization across all target samples.
bool ExecuteKolmogorovSmirnov(const std::map< std::string, std::string > &arguments)
Executes Kolmogorov-Smirnov goodness-of-fit test for a source/target group.
bool ExecuteErrorAnalysis(const std::map< std::string, std::string > &arguments)
Executes bootstrap error analysis for uncertainty quantification.
SourceSinkData * Data()
Returns pointer to the current SourceSinkData.
SourceSinkData * data
Non-owning pointer to analysis data.
bool ExecuteSDFAOnevsRest(const std::map< std::string, std::string > &arguments)
Executes Stepwise Discriminant Function Analysis for one group versus all others.
bool Execute(const std::string &command, std::map< std::string, std::string > arguments)
Executes a specified analysis command with given parameters.
bool ExecuteBracketingAnalysis(const std::map< std::string, std::string > &arguments)
Executes bracketing analysis for a single target sample.
bool ExecuteDFAOnevsRest(const std::map< std::string, std::string > &arguments)
Executes Discriminant Function Analysis for one group versus all others.
bool ExecuteCovarianceMatrix(const std::map< std::string, std::string > &arguments)
Calculates covariance matrix for a source or target group.
Conductor(MainWindow *mainwindow)
Constructs a Conductor associated with a MainWindow.
Results results
Current analysis results (cleared each Execute)
bool ExecuteOMSizeCorrect(const std::map< std::string, std::string > &arguments)
Executes organic matter and particle size correction.
bool ExecuteLevenbergMarquardt(const std::map< std::string, std::string > &arguments)
Executes Levenberg-Marquardt nonlinear optimization.
bool ExecuteEDP(const std::map< std::string, std::string > &arguments)
Calculates two-way element discriminant power between two groups.
bool ExecuteEDPM(const std::map< std::string, std::string > &arguments)
Calculates multi-way element discriminant power across all groups.
bool ExecuteCorrelationMatrix(const std::map< std::string, std::string > &arguments)
Calculates correlation matrix for a source or target group.
std::unique_ptr< CMCMC< SourceSinkData > > MCMC
MCMC sampler (owned)
Manages a collection of elemental profiles (samples) for source fingerprinting analysis.
Elemental_Profile SelectTopElementsAggregate(int n) const
Select top N elements across all samples (aggregate minimum)
Container for elemental concentration data of a single sediment sample.
vector< string > GetElementNames() const
Get list of all element names.
options & GetOptions()
Get reference to the options structure.
void SetOption(options_key opt, bool val)
Set a configuration option.
void SetLimit(_range lowhigh, const double &value)
Set upper or lower limit for value highlighting.
Main application window for SedSAT3 source apportionment analysis.
void SetYAxisTitle(const QString &title, int chart=0)
void SetProgress(const double &prog)
void SetTitle(const QString &title, int chart=0)
void SetAbsoluteValue(bool val)
void SetShowGraph(bool state)
void setYAxisTitle(const string &title)
void SetXAxisMode(xaxis_mode mode)
void SetYLimit(_range highlow, const double &value)
void setTableTitle(const string &Title)
void SetName(const string &_name)
void SetResult(Interface *_result)
void SetShowTable(bool state)
void setXAxisTitle(const string &title)
void SetYAxisMode(yaxis_mode mode)
void SetShowAsString(bool value)
void SetType(const result_type &_type)
void Append(const ResultItem &)
void SetName(const string &_name)
bool InitializeParametersAndObservations(const string &targetsamplename, estimation_mode est_mode=estimation_mode::elemental_profile_and_contribution)
Initialize parameters and observations for MCMC optimization.
void SetProgressWindow(ProgressWindow *_rtw)
Sets the progress window for displaying optimization progress.
bool PerformRegressionVsOMAndSize(const string &om, const string &particle_size, regression_form form, const double &p_value_threshold=0.05)
Performs multiple linear regression of elements vs OM and particle size.
Elemental_Profile_Set DifferentiationPower_Percentage(bool include_target)
Computes rank-based differentiation percentage for all source pairs.
CMBTimeSeriesSet BootStrap(const double &percentage, unsigned int num_iterations, string target_sample, bool use_softmax)
Performs bootstrap uncertainty analysis on source contributions.
SourceSinkData ExtractChemicalElements(bool isotopes) const
Extract only chemical elements (and optionally isotopes)
CMBVector ANOVA(bool use_log)
Performs one-way ANOVA for all elements across source groups.
bool SolveLevenberg_Marquardt(transformation trans=transformation::linear)
Solves for optimal source contributions using the Levenberg-Marquardt algorithm.
vector< CMBVector > StepwiseDiscriminantFunctionAnalysis(const string &source1, const string &source2)
Performs stepwise discriminant analysis between two specific sources.
ConcentrationSet * GetElementDistribution(const string &element_name)
Retrieves pointer to element distribution at dataset level.
SourceSinkData BoxCoxTransformed(bool calculate_optimal_lambda=false)
Applies Box-Cox transformation to all source groups for normalization.
void SetParameterEstimationMode(estimation_mode est_mode)
Sets the estimation mode for parameter optimization.
Elemental_Profile t_TestPValue(const string &source1, const string &source2, bool use_log)
Computes t-test p-values for element-wise differences between two sources.
vector< ResultItem > GetMLRResults()
Retrieves multiple linear regression results for all sample groups.
CMBVector BracketTest(const string &target_sample, bool correct_based_on_om_n_size)
Performs bracket test to check if target concentrations fall within source ranges.
void IncludeExcludeElementsBasedOn(const vector< string > &elements)
Sets element inclusion based on a specified list.
ResultItem GetPredictedElementalProfile(parameter_mode param_mode=parameter_mode::based_on_fitted_distribution)
Generates predicted elemental concentrations for the target sample.
void SetOMandSizeConstituents(const string &_omconstituent, const string &_sizeconsituent)
Sets the names of OM and particle size constituents.
SourceSinkData CreateCorrectedAndFilteredDataset(bool exclude_samples, bool exclude_elements, bool omnsizecorrect, const string &target="") const
Create a corrected and filtered copy of the dataset.
vector< string > NegativeValueCheck()
Checks for zero or negative concentration values across all sources.
CMBTimeSeriesSet VerifySource(const string &source_group, bool use_softmax, bool apply_om_size_correction)
Performs leave-one-out validation on a source group.
bool SetSelectedTargetSample(const string &sample_name)
Sets the currently selected target sample for analysis.
void AddtoToolsUsed(const string &tool)
Adds a tool name to the list of tools used in analysis.
DFA_result DiscriminantFunctionAnalysis()
Performs discriminant function analysis for all source groups.
vector< ResultItem > GetSourceProfiles()
Retrieves elemental profiles for all source groups.
Results MCMC(const string &target_sample, map< string, string > arguments, CMCMC< SourceSinkData > *mcmc, ProgressWindow *progress_window, const string &working_folder)
Performs Markov Chain Monte Carlo analysis for Bayesian source apportionment.
Elemental_Profile_Set DifferentiationPower(bool use_log, bool include_target)
Computes differentiation power for all source pairs.
SourceSinkData CreateCorrectedDataset(const string &target, bool omnsizecorrect, map< string, element_information > *elementinfo)
Create a corrected copy of the dataset for a specific target sample.
ResultItem GetObservedvsModeledElementalProfile(parameter_mode param_mode=parameter_mode::based_on_fitted_distribution)
Creates a comparison of observed vs modeled elemental profiles.
string GetTargetGroup() const
Retrieves the name of the target group.
Elemental_Profile_Set DifferentiationPower_P_value(bool include_target)
Computes t-test p-values for all source pairs.
ResultItem GetContribution()
Packages source contributions into a ResultItem for output.
ResultItem GetObservedvsModeledElementalProfile_Isotope(parameter_mode param_mode=parameter_mode::based_on_fitted_distribution)
Creates a comparison of observed vs modeled isotope delta values.
vector< string > OMandSizeConstituents()
Retrieves the names of OM and particle size constituents.
void InitializeParametersObservations(const vector< double > &mins, const vector< double > &maxs)
@ direct
Use empirical statistics from data.
distribution_type
Enumeration of probability distribution types supported in SedSat3.
@ lognormal
Lognormal distribution: ln(x) ~ N(μ, σ²), for strictly positive variables.
@ normal
Normal (Gaussian) distribution: p(x) = N(μ, σ²)
@ single_column_x
Enable single-column mode for X-axis data representation.
@ low
Lower bound of the parameter range.
@ high
Upper bound of the parameter range.
@ predicted_concentration
@ timeseries_set_first_symbol
@ source_elemental_profiles_based_on_source_data
CMBVectorSet eigen_vectors
CMBVectorSetSet multi_projected
QString X_suffix
Suffix appended to X-axis field names in serialization.
QString Y_suffix
Suffix appended to Y-axis field names in serialization.