Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/buildblock/ArcCorrection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "stir/numerics/overlap_interpolate.h"
#include <typeinfo>
#include "stir/warning.h"
#include "stir/format.h"

START_NAMESPACE_STIR
ArcCorrection::ArcCorrection()
Expand Down Expand Up @@ -71,8 +72,11 @@ ArcCorrection::set_up(const shared_ptr<const ProjDataInfo>& noarc_corr_proj_data
if (dynamic_cast<ProjDataInfoCylindricalArcCorr const*>(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(
format("ArcCorrection called with proj_data_info of the wrong type: {}", typeid(noarc_corr_proj_data_info).name()));
}
return Succeeded::no;
}

Expand Down
10 changes: 5 additions & 5 deletions src/buildblock/RadionuclideDB.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (...)
{
Expand Down Expand Up @@ -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;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/buildblock/recon_array_functions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DiscretisedDensityOnCartesianGrid<3, float>&>(input_image);
assert((dynamic_cast<DiscretisedDensityOnCartesianGrid<3, float>*>(&input_image) != nullptr));
# endif

const int zs = input_image.get_min_index();
Expand Down
10 changes: 6 additions & 4 deletions src/display/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 1 addition & 6 deletions src/include/stir/detail/PETSIRDInfo_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,14 @@ const std::set<float>&
get_largest_vector(const std::set<float>& x, const std::set<float>& y, const std::set<float>& z)
{
const std::set<float>* 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class BackProjectorByBinUsingProjMatrixByBin
BackProjectorByBinUsingProjMatrixByBin* clone() const override;

protected:
// un-hide remaining base overload(s)
using BackProjectorByBin::actual_back_project;
shared_ptr<ProjMatrixByBin> proj_matrix_ptr;

// currently not exposed, but leaving this ine for the future
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
86 changes: 50 additions & 36 deletions src/recon_buildblock/DataSymmetriesForBins_PET_CartesianGrid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -260,9 +261,13 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid
// will for now just switch view syms off
if (is_null_ptr(
dynamic_cast<const ProjDataInfoCylindrical*>(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"
{
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(*subset_proj_data_info_ptr->get_original_proj_data_info_sptr()).name());
typeid(original_proj_data_info).name()));
}

if (do_symmetry_90degrees_min_phi || do_symmetry_180degrees_min_phi)
{
Expand All @@ -279,26 +284,29 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid
if (proj_data_info_ptr->get_scanner_ptr()->get_scanner_geometry() == "Cylindrical")
{
if (dynamic_cast<const ProjDataInfoCylindrical*>(pdi_cyl_ptr) == NULL)
error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: %s\n"
"(can only handle projection data corresponding to a cylinder)\n",
typeid(*pdi_cyl_ptr).name());
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()));

const DiscretisedDensityOnCartesianGrid<3, float>* cartesian_grid_info_ptr
= dynamic_cast<const DiscretisedDensityOnCartesianGrid<3, float>*>(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(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",
image_info_ptr->get_origin().z(),
cartesian_grid_info_ptr->get_grid_spacing()[1]);
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]));

// 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)
Expand All @@ -323,10 +331,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 "
"with negative segment numbers corresponding to -theta of the positive segments. "
"This is not true for segment pair %d.\n",
segment_num);
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));

// 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)
Expand Down Expand Up @@ -383,27 +391,30 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid
if (proj_data_info_ptr->get_scanner_ptr()->get_scanner_geometry() == "BlocksOnCylindrical")
{
if (dynamic_cast<const ProjDataInfoBlocksOnCylindrical*>(pdi_cyl_ptr) == NULL)
error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: %s\n"
"(can only handle projection data corresponding to blocks on a cylinder)\n",
typeid(*pdi_cyl_ptr).name());
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()));

const DiscretisedDensityOnCartesianGrid<3, float>* cartesian_grid_info_ptr
= dynamic_cast<const DiscretisedDensityOnCartesianGrid<3, float>*>(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(format("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of image info: {}\n",
typeid(image_info).name()));
}

// WARNING get_grid_spacing()[1] == z
// note: origin by default is (0,0,0)
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",
image_info_ptr->get_origin().z(),
cartesian_grid_info_ptr->get_grid_spacing()[1]);
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]));

if (this->do_symmetry_90degrees_min_phi || this->do_symmetry_180degrees_min_phi || this->do_symmetry_swap_segment
|| this->do_symmetry_swap_s)
Expand All @@ -427,26 +438,29 @@ DataSymmetriesForBins_PET_CartesianGrid::DataSymmetriesForBins_PET_CartesianGrid
if (proj_data_info_ptr->get_scanner_ptr()->get_scanner_geometry() == "Generic")
{
if (dynamic_cast<const ProjDataInfoGeneric*>(pdi_cyl_ptr) == NULL)
error("DataSymmetriesForBins_PET_CartesianGrid constructed with wrong type of ProjDataInfo: %s\n"
"(can only handle projection data corresponding to a generig geometry)\n",
typeid(*pdi_cyl_ptr).name());
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()));

const DiscretisedDensityOnCartesianGrid<3, float>* cartesian_grid_info_ptr
= dynamic_cast<const DiscretisedDensityOnCartesianGrid<3, float>*>(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(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",
image_info_ptr->get_origin().z(),
cartesian_grid_info_ptr->get_grid_spacing()[1]);
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]));

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)
Expand Down
2 changes: 1 addition & 1 deletion src/scatter_buildblock/sample_scatter_points.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>((static_cast<double>(rand()) * (high - low)) / RAND_MAX + low);
assert(low <= result);
assert(high >= result);
return result;
Expand Down
2 changes: 1 addition & 1 deletion src/test/numerics/test_Fourier.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef VectorWithOffset<ArrayC1> ArrayC2;
inline float
rand1()
{
return 2 * (rand() - RAND_MAX / 2.F) / RAND_MAX;
return static_cast<float>(2.0 * (static_cast<double>(rand()) - RAND_MAX / 2.0) / RAND_MAX);
}

/*!
Expand Down
4 changes: 3 additions & 1 deletion src/test/test_proj_data_info_subsets_pet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/test_proj_data_info_subsets_spect.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/test_stir_math.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(RAND_MAX) / 5.F;
const float max_threshold = static_cast<float>(RAND_MAX) / 2.F;
{
char cmd_args[1000];
snprintf(cmd_args,
Expand Down Expand Up @@ -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<float>(RAND_MAX) / 5.F;
const float max_threshold = static_cast<float>(RAND_MAX) / 2.F;
{
char cmd_args[1000];
snprintf(cmd_args,
Expand Down
Loading