Skip to content

Commit

Permalink
Added exporting ROI's in export image as csv
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Jul 15, 2024
1 parent a1c8b00 commit bd6104c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mvc/ExportMapsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void ExportMapsDialog::createLayout()
_export_png = new QCheckBox("Save PNG");
_export_png->setChecked(true);

_export_ascii = new QCheckBox("Save ASCII");
_export_ascii = new QCheckBox("Save CSV");
_export_ascii->setChecked(false);

_export_all = new QCheckBox("Exports all elements: Unchecked exports only elements in view");
Expand Down
54 changes: 51 additions & 3 deletions src/mvc/MapsElementsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2184,8 +2184,8 @@ void MapsElementsWidget::on_export_images()
}
if (_export_maps_dialog->get_save_ascii())
{
ascii_dir.mkdir("ASCII");
ascii_dir.cd("ASCII");
ascii_dir.mkdir("CSV");
ascii_dir.cd("CSV");

std::vector<std::string> normalizers = { STR_DS_IC , STR_US_IC, STR_SR_CURRENT, "Counts" };

Expand Down Expand Up @@ -2318,11 +2318,59 @@ void MapsElementsWidget::on_export_images()
}
out_stream << "\n";
}

out_stream << "\n";
// check if there are any ROI's and export them
const std::unordered_map<std::string, Map_ROI> rois = _model->get_map_rois();
for (auto itr_roi : rois)
{
out_stream << "ROI: "<<itr_roi.first<<"\n";
for (auto& p_itr : itr_roi.second.pixel_list)
{
int yidx = p_itr.second;
int xidx = p_itr.first;
out_stream << yidx << " , " << xidx << " , " << y_axis.at(yidx) << " , " << x_axis.at(xidx) << " , ";

for (auto& e_itr : element_counts)
{
float calib_val = 1.0;
double val = 1.0;
float e_val = (e_itr.second)(yidx, xidx);
if (a_itr == STR_FIT_ROI || n_itr == "Counts")
{
val = e_val;
}
else
{
if (calib_curve != nullptr && normalizer != nullptr)
{
if (calib_curve->calib_curve.count(e_itr.first) > 0)
{
calib_val = static_cast<float>(calib_curve->calib_curve.at(e_itr.first));
float n_val = (*normalizer)(yidx, xidx);
val = e_val / n_val / calib_val;
}
else
{
val = e_val;
}
}
else
{
val = e_val;
}
}
out_stream << val << " , ";
}
out_stream << "\n";
}
out_stream << "\n";
}
out_stream.close();
}
else
{
logE << "Could not save PNG for " << save_file_name << "\n";
logE << "Could not save file for " << save_file_name << "\n";
}

ascii_dir.cdUp();
Expand Down

0 comments on commit bd6104c

Please sign in to comment.