From a7466cef2a1c2b1b47f186c922d10c1c06a866c2 Mon Sep 17 00:00:00 2001 From: Nikos Efthimiou Date: Wed, 26 Aug 2026 11:20:53 +0200 Subject: [PATCH 1/7] fixed all warnings --- src/buildblock/ArcCorrection.cxx | 6 ++-- src/buildblock/RadionuclideDB.cxx | 10 +++---- src/buildblock/recon_array_functions.cxx | 2 +- src/display/screen.c | 10 ++++--- ...ataSymmetriesForBins_PET_CartesianGrid.cxx | 30 +++++++++++++------ .../sample_scatter_points.cxx | 2 +- src/test/numerics/test_Fourier.cxx | 2 +- src/test/test_proj_data_info_subsets_pet.cxx | 4 ++- src/test/test_stir_math.cxx | 8 ++--- 9 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/buildblock/ArcCorrection.cxx b/src/buildblock/ArcCorrection.cxx index fa84ca2866..6c14420880 100644 --- a/src/buildblock/ArcCorrection.cxx +++ b/src/buildblock/ArcCorrection.cxx @@ -71,8 +71,10 @@ ArcCorrection::set_up(const shared_ptr& noarc_corr_proj_data if (dynamic_cast(noarc_corr_proj_data_info_sptr.get()) != 0) warning("ArcCorrection called with arc-corrected proj_data_info"); else - warning("ArcCorrection called with proj_data_info of the wrong type:\n\t%s", - typeid(*noarc_corr_proj_data_info_sptr).name()); + { + const auto& noarc_corr_proj_data_info = *noarc_corr_proj_data_info_sptr; + warning("ArcCorrection called with proj_data_info of the wrong type:\n\t%s", typeid(noarc_corr_proj_data_info).name()); + } return Succeeded::no; } diff --git a/src/buildblock/RadionuclideDB.cxx b/src/buildblock/RadionuclideDB.cxx index cefe666d44..04d7a14661 100644 --- a/src/buildblock/RadionuclideDB.cxx +++ b/src/buildblock/RadionuclideDB.cxx @@ -109,11 +109,12 @@ RadionuclideDB::get_radionuclide_from_json(ImagingModality rmodality, const std: std::string name = rname; +#ifdef nlohmann_json_FOUND + float keV; float h_life; float branching_ratio; -#ifdef nlohmann_json_FOUND info("RadionuclideDB: finding record radionuclide: " + rname + " in file " + this->database_filename, 3); // convert modality string @@ -137,9 +138,8 @@ RadionuclideDB::get_radionuclide_from_json(ImagingModality rmodality, const std: auto rnuclide_entry = all_nuclides.end(); try { - rnuclide_entry = std::find_if(all_nuclides.begin(), all_nuclides.end(), [&rname](const nlohmann::json::reference& entry) { - return entry.at("name") == rname; - }); + rnuclide_entry = std::find_if( + all_nuclides.begin(), all_nuclides.end(), [&rname](const nlohmann::json& entry) { return entry.at("name") == rname; }); } catch (...) { @@ -167,7 +167,7 @@ RadionuclideDB::get_radionuclide_from_json(ImagingModality rmodality, const std: auto decay_entry = decays.end(); try { - decay_entry = std::find_if(decays.begin(), decays.end(), [&modality_string](const nlohmann::json::reference& entry) { + decay_entry = std::find_if(decays.begin(), decays.end(), [&modality_string](const nlohmann::json& entry) { return entry.at("modality") == modality_string; }); } diff --git a/src/buildblock/recon_array_functions.cxx b/src/buildblock/recon_array_functions.cxx index 290fdb8bba..f1dc8a774e 100644 --- a/src/buildblock/recon_array_functions.cxx +++ b/src/buildblock/recon_array_functions.cxx @@ -407,7 +407,7 @@ truncate_end_planes(DiscretisedDensity<3, float>& input_image, int input_num_pla // TODO this function does not make a lot of sense in general # ifndef NDEBUG // this will throw an exception when the cast is invalid - dynamic_cast&>(input_image); + assert((dynamic_cast*>(&input_image) != nullptr)); # endif const int zs = input_image.get_min_index(); diff --git a/src/display/screen.c b/src/display/screen.c index 509becc533..c7cea6117b 100644 --- a/src/display/screen.c +++ b/src/display/screen.c @@ -447,7 +447,8 @@ SCX_WRITE(int* Xpos_x, int* Xpos_y, char* text) } } -void SCX_STOP(stop) int stop; +void +SCX_STOP(int stop) { XEvent report; @@ -525,8 +526,8 @@ SCX_Y_MAX() # undef SCX_hintY /* KT 28/11/2002 heavily modified to account for TrueColor */ -void SCX_PutImg(image, x_begin, y_begin, lengthX, lengthY) image_t* image; -int x_begin, y_begin, lengthX, lengthY; +void +SCX_PutImg(image_t* image, int x_begin, int y_begin, int lengthX, int lengthY) { XImage* myimage; unsigned char* local_image; @@ -687,7 +688,8 @@ SCX_SAVE_TO_FILE(int x_begin, int y_begin, int width, int height, FILE* outfile) /* change November 1997: added this function (was SCX_SCALE before) */ /* 30/01/98 put high intensities on top of scale 25/11/2002 try this again*/ -void SC_SCALE(pos_x, pos_y, size_x, size_y) int pos_x, pos_y, size_x, size_y; +void +SC_SCALE(int pos_x, int pos_y, int size_x, int size_y) { unsigned char par; float pos_inc; diff --git a/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx b/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx index 82391fef93..7ccd1ba303 100644 --- a/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx +++ b/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx @@ -260,9 +260,12 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid // will for now just switch view syms off if (is_null_ptr( dynamic_cast(subset_proj_data_info_ptr->get_original_proj_data_info_sptr().get()))) - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of original (non-subset) ProjDataInfo: %s\n" - "(can only handle projection data corresponding to a cylinder)\n", - typeid(*subset_proj_data_info_ptr->get_original_proj_data_info_sptr()).name()); + { + const auto& original_proj_data_info = *subset_proj_data_info_ptr->get_original_proj_data_info_sptr(); + error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of original (non-subset) ProjDataInfo: %s\n" + "(can only handle projection data corresponding to a cylinder)\n", + typeid(original_proj_data_info).name()); + } if (do_symmetry_90degrees_min_phi || do_symmetry_180degrees_min_phi) { @@ -287,8 +290,11 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid = dynamic_cast*>(image_info_ptr.get()); if (is_null_ptr(cartesian_grid_info_ptr)) - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", - typeid(*image_info_ptr).name()); + { + const auto& image_info = *image_info_ptr; + error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", + typeid(image_info_ptr).name()); + } // WARNING get_grid_spacing()[1] == z const float z_origin_in_planes = image_info_ptr->get_origin().z() / cartesian_grid_info_ptr->get_grid_spacing()[1]; @@ -391,8 +397,11 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid = dynamic_cast*>(image_info_ptr.get()); if (cartesian_grid_info_ptr == NULL) - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", - typeid(*image_info_ptr).name()); + { + const auto& image_info = *image_info_ptr; + error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", + typeid(image_info).name()); + } // WARNING get_grid_spacing()[1] == z // note: origin by default is (0,0,0) @@ -435,8 +444,11 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid = dynamic_cast*>(image_info_ptr.get()); if (cartesian_grid_info_ptr == NULL) - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", - typeid(*image_info_ptr).name()); + { + const auto& image_info = *image_info_ptr; + error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", + typeid(image_info).name()); + } // WARNING get_grid_spacing()[1] == z const float z_origin_in_planes = image_info_ptr->get_origin().z() / cartesian_grid_info_ptr->get_grid_spacing()[1]; diff --git a/src/scatter_buildblock/sample_scatter_points.cxx b/src/scatter_buildblock/sample_scatter_points.cxx index 78628947f6..903ea9f09c 100644 --- a/src/scatter_buildblock/sample_scatter_points.cxx +++ b/src/scatter_buildblock/sample_scatter_points.cxx @@ -31,7 +31,7 @@ static inline float random_point(const float low, const float high) { /* returns a pseudo random number which holds in the bounds low and high */ - const float result = (rand() * (high - low)) / RAND_MAX + low; + const float result = static_cast((static_cast(rand()) * (high - low)) / RAND_MAX + low); assert(low <= result); assert(high >= result); return result; diff --git a/src/test/numerics/test_Fourier.cxx b/src/test/numerics/test_Fourier.cxx index 513d090112..3020e0ab7c 100644 --- a/src/test/numerics/test_Fourier.cxx +++ b/src/test/numerics/test_Fourier.cxx @@ -51,7 +51,7 @@ typedef VectorWithOffset ArrayC2; inline float rand1() { - return 2 * (rand() - RAND_MAX / 2.F) / RAND_MAX; + return static_cast(2.0 * (static_cast(rand()) - RAND_MAX / 2.0) / RAND_MAX); } /*! diff --git a/src/test/test_proj_data_info_subsets_pet.cxx b/src/test/test_proj_data_info_subsets_pet.cxx index a05f3d1fb1..ade5f3b7b7 100644 --- a/src/test/test_proj_data_info_subsets_pet.cxx +++ b/src/test/test_proj_data_info_subsets_pet.cxx @@ -359,7 +359,9 @@ TestProjDataInfoSubsets::test_split(const ProjData& proj_data) cerr << "\t\tchecking Full subset should >= original ProjDataInfo" << endl; if (!(*full_pdi_sptr >= *proj_data.get_proj_data_info_sptr())) { - cerr << typeid(*full_pdi_sptr).name() << " " << typeid(*sub_a_pdi_sptr).name() << endl; + const auto& full_pdi = *full_pdi_sptr; + const auto& sub_a_pdi = *sub_a_pdi_sptr; + cerr << typeid(full_pdi).name() << " " << typeid(sub_a_pdi).name() << endl; cerr << "Failed: Expected full == original" << endl; everything_ok = false; } diff --git a/src/test/test_stir_math.cxx b/src/test/test_stir_math.cxx index 890febc321..49c012b656 100644 --- a/src/test/test_stir_math.cxx +++ b/src/test/test_stir_math.cxx @@ -134,8 +134,8 @@ stir_mathTests::run_tests() } // add with power etc // range for rand() is 0 to RAND_MAX - const float min_threshold = RAND_MAX / 5.F; - const float max_threshold = RAND_MAX / 2.F; + const float min_threshold = static_cast(RAND_MAX) / 5.F; + const float max_threshold = static_cast(RAND_MAX) / 2.F; { char cmd_args[1000]; snprintf(cmd_args, @@ -265,8 +265,8 @@ stir_mathTests::run_tests() } // add with power etc // range for rand() is 0 to RAND_MAX - const float min_threshold = RAND_MAX / 5.F; - const float max_threshold = RAND_MAX / 2.F; + const float min_threshold = static_cast(RAND_MAX) / 5.F; + const float max_threshold = static_cast(RAND_MAX) / 2.F; { char cmd_args[1000]; snprintf(cmd_args, From 32230e543ef5d092dc29dc80b83d8ba6bbdf6d9a Mon Sep 17 00:00:00 2001 From: Nikos Efthimiou Date: Wed, 26 Aug 2026 12:39:09 +0200 Subject: [PATCH 2/7] bug fix --- .../DataSymmetriesForBins_PET_CartesianGrid.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx b/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx index 7ccd1ba303..c7049420ff 100644 --- a/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx +++ b/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx @@ -293,7 +293,7 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid { const auto& image_info = *image_info_ptr; error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", - typeid(image_info_ptr).name()); + typeid(image_info).name()); } // WARNING get_grid_spacing()[1] == z From 4c2093b56ea49b1dbca592644b85ccaa6f328fed Mon Sep 17 00:00:00 2001 From: Nikos Efthimiou Date: Wed, 26 Aug 2026 12:56:57 +0200 Subject: [PATCH 3/7] One more typeid warning --- src/test/test_proj_data_info_subsets_spect.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/test_proj_data_info_subsets_spect.cxx b/src/test/test_proj_data_info_subsets_spect.cxx index 39985cb4e0..07655ebc5c 100644 --- a/src/test/test_proj_data_info_subsets_spect.cxx +++ b/src/test/test_proj_data_info_subsets_spect.cxx @@ -327,7 +327,9 @@ TestProjDataInfoSubsetsSPECTUB::test_split(const ProjData& proj_data) cerr << "\t\tchecking Full subset should >= original ProjDataInfo" << endl; if (!(*full_pdi_sptr >= *proj_data.get_proj_data_info_sptr())) { - cerr << typeid(*full_pdi_sptr).name() << " " << typeid(*sub_a_pdi_sptr).name() << endl; + const auto& full_pdi = *full_pdi_sptr; + const auto& sub_a_pdi = *sub_a_pdi_sptr; + cerr << typeid(full_pdi).name() << " " << typeid(sub_a_pdi).name() << endl; cerr << "Failed: Expected full == original" << endl; everything_ok = false; } From 846baa081fa239f98654193e5738fb53fb55d077 Mon Sep 17 00:00:00 2001 From: Nikos Efthimiou Date: Wed, 26 Aug 2026 13:53:41 +0200 Subject: [PATCH 4/7] * Fixed a few initialization warnings * Potential bug, in PETSIRD if x and y axis are the same size then z won't be checked. --- src/include/stir/detail/PETSIRDInfo_helpers.h | 7 +------ .../DataSymmetriesForBins_PET_CartesianGrid.inl | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/include/stir/detail/PETSIRDInfo_helpers.h b/src/include/stir/detail/PETSIRDInfo_helpers.h index d325cf075f..b0377fefbc 100644 --- a/src/include/stir/detail/PETSIRDInfo_helpers.h +++ b/src/include/stir/detail/PETSIRDInfo_helpers.h @@ -154,19 +154,14 @@ const std::set& get_largest_vector(const std::set& x, const std::set& y, const std::set& z) { const std::set* largest = &x; - int axis = 0; if (y.size() > largest->size()) { largest = &y; - axis = 1; } - else if (z.size() > largest->size()) + if (z.size() > largest->size()) { largest = &z; - axis = 2; } - - // stir::info(fmt::format("I believe the axial direction is the {}.", axis)); return *largest; } diff --git a/src/include/stir/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.inl b/src/include/stir/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.inl index 67e3c0c4a4..a418100310 100644 --- a/src/include/stir/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.inl +++ b/src/include/stir/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.inl @@ -556,7 +556,7 @@ DataSymmetriesForBins_PET_CartesianGrid::find_basic_bin( } } - int segment_num_temp, axial_pos_num_temp; + int segment_num_temp = 0, axial_pos_num_temp = 0; proj_data_info_blk_ptr->get_segment_axial_pos_num_for_ring_pair(segment_num_temp, axial_pos_num_temp, ring1, ring2); // to check @@ -637,7 +637,7 @@ DataSymmetriesForBins_PET_CartesianGrid::find_basic_bin( } } - int segment_num_temp, axial_pos_num_temp; + int segment_num_temp = 0, axial_pos_num_temp = 0; proj_data_info_gen_ptr->get_segment_axial_pos_num_for_ring_pair(segment_num_temp, axial_pos_num_temp, ring1, ring2); if (segment_num_temp != segment_num) From 889bdcc0d6433b3ddb0e79ec960c15a90ae680ad Mon Sep 17 00:00:00 2001 From: Nikos Efthimiou Date: Mon, 31 Aug 2026 14:10:07 +0200 Subject: [PATCH 5/7] fix hidden base function --- .../recon_buildblock/BackProjectorByBinUsingProjMatrixByBin.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/include/stir/recon_buildblock/BackProjectorByBinUsingProjMatrixByBin.h b/src/include/stir/recon_buildblock/BackProjectorByBinUsingProjMatrixByBin.h index 976147f4fa..11790dc0ad 100644 --- a/src/include/stir/recon_buildblock/BackProjectorByBinUsingProjMatrixByBin.h +++ b/src/include/stir/recon_buildblock/BackProjectorByBinUsingProjMatrixByBin.h @@ -74,6 +74,8 @@ class BackProjectorByBinUsingProjMatrixByBin BackProjectorByBinUsingProjMatrixByBin* clone() const override; protected: + // un-hide remaining base overload(s) + using BackProjectorByBin::actual_back_project; shared_ptr proj_matrix_ptr; // currently not exposed, but leaving this ine for the future From fb297246867e361f33c878c853962ec8c6c67eab Mon Sep 17 00:00:00 2001 From: Nikos Efthimiou Date: Mon, 7 Sep 2026 10:53:51 +0200 Subject: [PATCH 6/7] Use of format with typeid --- src/buildblock/ArcCorrection.cxx | 3 +- ...ataSymmetriesForBins_PET_CartesianGrid.cxx | 59 ++++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/buildblock/ArcCorrection.cxx b/src/buildblock/ArcCorrection.cxx index 6c14420880..75a03c1951 100644 --- a/src/buildblock/ArcCorrection.cxx +++ b/src/buildblock/ArcCorrection.cxx @@ -31,6 +31,7 @@ #include "stir/numerics/overlap_interpolate.h" #include #include "stir/warning.h" +#include "stir/format.h" START_NAMESPACE_STIR ArcCorrection::ArcCorrection() @@ -73,7 +74,7 @@ ArcCorrection::set_up(const shared_ptr& noarc_corr_proj_data else { const auto& noarc_corr_proj_data_info = *noarc_corr_proj_data_info_sptr; - warning("ArcCorrection called with proj_data_info of the wrong type:\n\t%s", typeid(noarc_corr_proj_data_info).name()); + warning(format("ArcCorrection called with proj_data_info of the wrong type: {}", typeid(noarc_corr_proj_data_info).name())); } return Succeeded::no; } diff --git a/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx b/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx index c7049420ff..acf8cf0c97 100644 --- a/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx +++ b/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx @@ -37,6 +37,7 @@ #include "stir/ProjDataInfoGeneric.h" #include "stir/warning.h" #include "stir/error.h" +#include "stir/format.h" using std::min; using std::max; @@ -262,9 +263,9 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid dynamic_cast(subset_proj_data_info_ptr->get_original_proj_data_info_sptr().get()))) { const auto& original_proj_data_info = *subset_proj_data_info_ptr->get_original_proj_data_info_sptr(); - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of original (non-subset) ProjDataInfo: %s\n" + error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of original (non-subset) ProjDataInfo: {}\n" "(can only handle projection data corresponding to a cylinder)\n", - typeid(original_proj_data_info).name()); + typeid(original_proj_data_info).name())); } if (do_symmetry_90degrees_min_phi || do_symmetry_180degrees_min_phi) @@ -282,9 +283,9 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid if (proj_data_info_ptr->get_scanner_ptr()->get_scanner_geometry() == "Cylindrical") { if (dynamic_cast(pdi_cyl_ptr) == NULL) - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: %s\n" + error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: {}\n" "(can only handle projection data corresponding to a cylinder)\n", - typeid(*pdi_cyl_ptr).name()); + typeid(*pdi_cyl_ptr).name())); const DiscretisedDensityOnCartesianGrid<3, float>* cartesian_grid_info_ptr = dynamic_cast*>(image_info_ptr.get()); @@ -292,19 +293,19 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid if (is_null_ptr(cartesian_grid_info_ptr)) { const auto& image_info = *image_info_ptr; - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", - typeid(image_info).name()); + error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: {}\n", + typeid(image_info).name())); } // WARNING get_grid_spacing()[1] == z const float z_origin_in_planes = image_info_ptr->get_origin().z() / cartesian_grid_info_ptr->get_grid_spacing()[1]; // z_origin_in_planes should be an integer if (fabs(round(z_origin_in_planes) - z_origin_in_planes) > 1.E-3F) - error("DataSymmetriesForBins_PET_CartesianGrid: the shift in the " - "z-direction of the origin (which is %g) should be a multiple of the plane " - "separation (%g)\n", + error(format("DataSymmetriesForBins_PET_CartesianGrid: the shift in the " + "z-direction of the origin (which is {}) should be a multiple of the plane " + "separation ({})\n", image_info_ptr->get_origin().z(), - cartesian_grid_info_ptr->get_grid_spacing()[1]); + cartesian_grid_info_ptr->get_grid_spacing()[1])); // check if unequal voxel size in x,y, if so, use less symmetry if (fabs(cartesian_grid_info_ptr->get_grid_spacing()[2] - cartesian_grid_info_ptr->get_grid_spacing()[3]) > 2.E-3F) @@ -329,10 +330,10 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid if (fabs(proj_data_info_ptr->get_tantheta(Bin(segment_num, 0, 0, 0)) + proj_data_info_ptr->get_tantheta(Bin(-segment_num, 0, 0, 0))) > 1.E-4F) - error("DataSymmetriesForBins_PET_CartesianGrid can only handle projection data " + error(format("DataSymmetriesForBins_PET_CartesianGrid can only handle projection data " "with negative segment numbers corresponding to -theta of the positive segments. " - "This is not true for segment pair %d.\n", - segment_num); + "This is not true for segment pair {}.\n", + segment_num)); // feable check on s-symmetry if (fabs(proj_data_info_ptr->get_s(Bin(0, 0, 0, 1)) + proj_data_info_ptr->get_s(Bin(0, 0, 0, -1))) > 1.E-4F) @@ -389,9 +390,9 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid if (proj_data_info_ptr->get_scanner_ptr()->get_scanner_geometry() == "BlocksOnCylindrical") { if (dynamic_cast(pdi_cyl_ptr) == NULL) - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: %s\n" + error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: {}\n" "(can only handle projection data corresponding to blocks on a cylinder)\n", - typeid(*pdi_cyl_ptr).name()); + typeid(*pdi_cyl_ptr).name())); const DiscretisedDensityOnCartesianGrid<3, float>* cartesian_grid_info_ptr = dynamic_cast*>(image_info_ptr.get()); @@ -399,8 +400,8 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid if (cartesian_grid_info_ptr == NULL) { const auto& image_info = *image_info_ptr; - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", - typeid(image_info).name()); + error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: {}\n", + typeid(image_info).name())); } // WARNING get_grid_spacing()[1] == z @@ -408,11 +409,11 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid const float z_origin_in_planes = image_info_ptr->get_origin().z() / cartesian_grid_info_ptr->get_grid_spacing()[1]; // z_origin_in_planes should be an integer if (fabs(round(z_origin_in_planes) - z_origin_in_planes) > 1.E-3F) - error("DataSymmetriesForBins_PET_CartesianGrid: the shift in the " - "z-direction of the origin (which is %g) should be a multiple of the plane " - "separation (%g)\n", + error(format("DataSymmetriesForBins_PET_CartesianGrid: the shift in the " + "z-direction of the origin (which is {}) should be a multiple of the plane " + "separation ({})\n", image_info_ptr->get_origin().z(), - cartesian_grid_info_ptr->get_grid_spacing()[1]); + cartesian_grid_info_ptr->get_grid_spacing()[1])); if (this->do_symmetry_90degrees_min_phi || this->do_symmetry_180degrees_min_phi || this->do_symmetry_swap_segment || this->do_symmetry_swap_s) @@ -436,9 +437,9 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid if (proj_data_info_ptr->get_scanner_ptr()->get_scanner_geometry() == "Generic") { if (dynamic_cast(pdi_cyl_ptr) == NULL) - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: %s\n" + error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: {}\n" "(can only handle projection data corresponding to a generig geometry)\n", - typeid(*pdi_cyl_ptr).name()); + typeid(*pdi_cyl_ptr).name())); const DiscretisedDensityOnCartesianGrid<3, float>* cartesian_grid_info_ptr = dynamic_cast*>(image_info_ptr.get()); @@ -446,19 +447,19 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid if (cartesian_grid_info_ptr == NULL) { const auto& image_info = *image_info_ptr; - error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: %s\n", - typeid(image_info).name()); + error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: {}\n", + typeid(image_info).name())); } // WARNING get_grid_spacing()[1] == z const float z_origin_in_planes = image_info_ptr->get_origin().z() / cartesian_grid_info_ptr->get_grid_spacing()[1]; // z_origin_in_planes should be an integer if (fabs(round(z_origin_in_planes) - z_origin_in_planes) > 1.E-3F) - error("DataSymmetriesForBins_PET_CartesianGrid: the shift in the " - "z-direction of the origin (which is %g) should be a multiple of the plane " - "separation (%g)\n", + error(format("DataSymmetriesForBins_PET_CartesianGrid: the shift in the " + "z-direction of the origin (which is {}) should be a multiple of the plane " + "separation ({})\n", image_info_ptr->get_origin().z(), - cartesian_grid_info_ptr->get_grid_spacing()[1]); + cartesian_grid_info_ptr->get_grid_spacing()[1])); if (this->do_symmetry_90degrees_min_phi || this->do_symmetry_180degrees_min_phi || this->do_symmetry_swap_segment || this->do_symmetry_swap_s || this->do_symmetry_shift_z) From 8cbf844d6d37c9f0ba4f73637049b6c6e48978c8 Mon Sep 17 00:00:00 2001 From: Nikos Efthimiou Date: Mon, 7 Sep 2026 10:57:27 +0200 Subject: [PATCH 7/7] pre-commit --- src/buildblock/ArcCorrection.cxx | 3 +- ...ataSymmetriesForBins_PET_CartesianGrid.cxx | 55 ++++++++++--------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/buildblock/ArcCorrection.cxx b/src/buildblock/ArcCorrection.cxx index 75a03c1951..bd10d91eab 100644 --- a/src/buildblock/ArcCorrection.cxx +++ b/src/buildblock/ArcCorrection.cxx @@ -74,7 +74,8 @@ ArcCorrection::set_up(const shared_ptr& noarc_corr_proj_data else { const auto& noarc_corr_proj_data_info = *noarc_corr_proj_data_info_sptr; - warning(format("ArcCorrection called with proj_data_info of the wrong type: {}", typeid(noarc_corr_proj_data_info).name())); + warning( + format("ArcCorrection called with proj_data_info of the wrong type: {}", typeid(noarc_corr_proj_data_info).name())); } return Succeeded::no; } diff --git a/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx b/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx index acf8cf0c97..a0f6fb6119 100644 --- a/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx +++ b/src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx @@ -263,9 +263,10 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid dynamic_cast(subset_proj_data_info_ptr->get_original_proj_data_info_sptr().get()))) { const auto& original_proj_data_info = *subset_proj_data_info_ptr->get_original_proj_data_info_sptr(); - error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of original (non-subset) ProjDataInfo: {}\n" - "(can only handle projection data corresponding to a cylinder)\n", - typeid(original_proj_data_info).name())); + error(format( + "DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of original (non-subset) ProjDataInfo: {}\n" + "(can only handle projection data corresponding to a cylinder)\n", + typeid(original_proj_data_info).name())); } if (do_symmetry_90degrees_min_phi || do_symmetry_180degrees_min_phi) @@ -284,8 +285,8 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid { if (dynamic_cast(pdi_cyl_ptr) == NULL) error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: {}\n" - "(can only handle projection data corresponding to a cylinder)\n", - typeid(*pdi_cyl_ptr).name())); + "(can only handle projection data corresponding to a cylinder)\n", + typeid(*pdi_cyl_ptr).name())); const DiscretisedDensityOnCartesianGrid<3, float>* cartesian_grid_info_ptr = dynamic_cast*>(image_info_ptr.get()); @@ -294,7 +295,7 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid { const auto& image_info = *image_info_ptr; error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: {}\n", - typeid(image_info).name())); + typeid(image_info).name())); } // WARNING get_grid_spacing()[1] == z @@ -302,10 +303,10 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid // z_origin_in_planes should be an integer if (fabs(round(z_origin_in_planes) - z_origin_in_planes) > 1.E-3F) error(format("DataSymmetriesForBins_PET_CartesianGrid: the shift in the " - "z-direction of the origin (which is {}) should be a multiple of the plane " - "separation ({})\n", - image_info_ptr->get_origin().z(), - cartesian_grid_info_ptr->get_grid_spacing()[1])); + "z-direction of the origin (which is {}) should be a multiple of the plane " + "separation ({})\n", + image_info_ptr->get_origin().z(), + cartesian_grid_info_ptr->get_grid_spacing()[1])); // check if unequal voxel size in x,y, if so, use less symmetry if (fabs(cartesian_grid_info_ptr->get_grid_spacing()[2] - cartesian_grid_info_ptr->get_grid_spacing()[3]) > 2.E-3F) @@ -331,9 +332,9 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid + proj_data_info_ptr->get_tantheta(Bin(-segment_num, 0, 0, 0))) > 1.E-4F) error(format("DataSymmetriesForBins_PET_CartesianGrid can only handle projection data " - "with negative segment numbers corresponding to -theta of the positive segments. " - "This is not true for segment pair {}.\n", - segment_num)); + "with negative segment numbers corresponding to -theta of the positive segments. " + "This is not true for segment pair {}.\n", + segment_num)); // feable check on s-symmetry if (fabs(proj_data_info_ptr->get_s(Bin(0, 0, 0, 1)) + proj_data_info_ptr->get_s(Bin(0, 0, 0, -1))) > 1.E-4F) @@ -391,8 +392,8 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid { if (dynamic_cast(pdi_cyl_ptr) == NULL) error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: {}\n" - "(can only handle projection data corresponding to blocks on a cylinder)\n", - typeid(*pdi_cyl_ptr).name())); + "(can only handle projection data corresponding to blocks on a cylinder)\n", + typeid(*pdi_cyl_ptr).name())); const DiscretisedDensityOnCartesianGrid<3, float>* cartesian_grid_info_ptr = dynamic_cast*>(image_info_ptr.get()); @@ -401,7 +402,7 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid { const auto& image_info = *image_info_ptr; error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: {}\n", - typeid(image_info).name())); + typeid(image_info).name())); } // WARNING get_grid_spacing()[1] == z @@ -410,10 +411,10 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid // z_origin_in_planes should be an integer if (fabs(round(z_origin_in_planes) - z_origin_in_planes) > 1.E-3F) error(format("DataSymmetriesForBins_PET_CartesianGrid: the shift in the " - "z-direction of the origin (which is {}) should be a multiple of the plane " - "separation ({})\n", - image_info_ptr->get_origin().z(), - cartesian_grid_info_ptr->get_grid_spacing()[1])); + "z-direction of the origin (which is {}) should be a multiple of the plane " + "separation ({})\n", + image_info_ptr->get_origin().z(), + cartesian_grid_info_ptr->get_grid_spacing()[1])); if (this->do_symmetry_90degrees_min_phi || this->do_symmetry_180degrees_min_phi || this->do_symmetry_swap_segment || this->do_symmetry_swap_s) @@ -438,8 +439,8 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid { if (dynamic_cast(pdi_cyl_ptr) == NULL) error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: {}\n" - "(can only handle projection data corresponding to a generig geometry)\n", - typeid(*pdi_cyl_ptr).name())); + "(can only handle projection data corresponding to a generig geometry)\n", + typeid(*pdi_cyl_ptr).name())); const DiscretisedDensityOnCartesianGrid<3, float>* cartesian_grid_info_ptr = dynamic_cast*>(image_info_ptr.get()); @@ -448,7 +449,7 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid { const auto& image_info = *image_info_ptr; error(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: {}\n", - typeid(image_info).name())); + typeid(image_info).name())); } // WARNING get_grid_spacing()[1] == z @@ -456,10 +457,10 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid // z_origin_in_planes should be an integer if (fabs(round(z_origin_in_planes) - z_origin_in_planes) > 1.E-3F) error(format("DataSymmetriesForBins_PET_CartesianGrid: the shift in the " - "z-direction of the origin (which is {}) should be a multiple of the plane " - "separation ({})\n", - image_info_ptr->get_origin().z(), - cartesian_grid_info_ptr->get_grid_spacing()[1])); + "z-direction of the origin (which is {}) should be a multiple of the plane " + "separation ({})\n", + image_info_ptr->get_origin().z(), + cartesian_grid_info_ptr->get_grid_spacing()[1])); if (this->do_symmetry_90degrees_min_phi || this->do_symmetry_180degrees_min_phi || this->do_symmetry_swap_segment || this->do_symmetry_swap_s || this->do_symmetry_shift_z)