Closed KrisThielemans closed 1 year ago
so it seem wmh needs to be intialised, I will have a look
I think this is relevant to this issue. Let me know if it needs its own:
I'm having issues with improperly initialised values when setting up the projector after setting a resolution model
acq_model_matrix = ProjMatrixByBinSPECTUB()
acq_model_matrix.set_resolution_model(0.93, 0.03, False)
projector = ProjectorByBinPairUsingProjMatrixByBin(acq_model_matrix)
projector.set_up(templ_sino.get_proj_data_info(), target) # error occurs here
Failing scripts for sirf and stir are available at https://github.com/samdporter/SPECTissues, along with valgrind outputs.
This error does not occur if no resolution model is set.
Relevant (I think) part of the valgrind output
==1156376== Conditional jump or move depends on uninitialised value(s)
==1156376== at 0x64C3CB2: SPECTUB::max_psf_szb(SPECTUB::angle_type*, SPECTUB::wmh_type&) (SPECTUB_Tools.cxx:788)
==1156376== by 0x64C099F: stir::ProjMatrixByBinSPECTUB::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjMatrixByBinSPECTUB.cxx:583)
==1156376== by 0x64DA33E: stir::ForwardProjectorByBinUsingProjMatrixByBin::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ForwardProjectorByBinUsingProjMatrixByBin.cxx:100)
==1156376== by 0x64DDD07: stir::ProjectorByBinPair::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjectorByBinPair.cxx:47)
==1156376== by 0x64DE10C: stir::ProjectorByBinPairUsingProjMatrixByBin::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjectorByBinPairUsingProjMatrixByBin.cxx:88)
==1156376== by 0x6242DA7: _wrap_ProjectorByBinPairUsingProjMatrixByBin_set_up (stirPYTHON_wrap.cxx:128250)
==1156376== by 0x24C9DF: ??? (in /usr/bin/python3.10)
==1156376== by 0x250F51: _PyEval_EvalFrameDefault (in /usr/bin/python3.10)
==1156376== by 0x341E55: ??? (in /usr/bin/python3.10)
==1156376== by 0x341CF5: PyEval_EvalCode (in /usr/bin/python3.10)
==1156376== by 0x36C7D7: ??? (in /usr/bin/python3.10)
==1156376== by 0x3660BA: ??? (in /usr/bin/python3.10)
==1156376==
==1156376== Conditional jump or move depends on uninitialised value(s)
==1156376== at 0x64C3713: SPECTUB::calc_sigma_h(SPECTUB::voxel_type, SPECTUB::collim_type) (SPECTUB_Tools.cxx:815)
==1156376== by 0x64C3D47: SPECTUB::max_psf_szb(SPECTUB::angle_type*, SPECTUB::wmh_type&) (SPECTUB_Tools.cxx:794)
==1156376== by 0x64C099F: stir::ProjMatrixByBinSPECTUB::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjMatrixByBinSPECTUB.cxx:583)
==1156376== by 0x64DA33E: stir::ForwardProjectorByBinUsingProjMatrixByBin::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ForwardProjectorByBinUsingProjMatrixByBin.cxx:100)
==1156376== by 0x64DDD07: stir::ProjectorByBinPair::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjectorByBinPair.cxx:47)
==1156376== by 0x64DE10C: stir::ProjectorByBinPairUsingProjMatrixByBin::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjectorByBinPairUsingProjMatrixByBin.cxx:88)
==1156376== by 0x6242DA7: _wrap_ProjectorByBinPairUsingProjMatrixByBin_set_up (stirPYTHON_wrap.cxx:128250)
==1156376== by 0x24C9DF: ??? (in /usr/bin/python3.10)
==1156376== by 0x250F51: _PyEval_EvalFrameDefault (in /usr/bin/python3.10)
==1156376== by 0x341E55: ??? (in /usr/bin/python3.10)
==1156376== by 0x341CF5: PyEval_EvalCode (in /usr/bin/python3.10)
==1156376== by 0x36C7D7: ??? (in /usr/bin/python3.10)
==1156376==
==1156376== Conditional jump or move depends on uninitialised value(s)
==1156376== at 0x64C6B81: SPECTUB::voxel_projection(SPECTUB::voxel_type*, float*, float, SPECTUB::wmh_type&) (SPECTUB_Weight3d.cxx:534)
==1156376== by 0x64C7AEE: SPECTUB::wm_size_estimation(int, SPECTUB::angle_type const*, SPECTUB::voxel_type, SPECTUB::bin_type, SPECTUB::volume_type const&, SPECTUB::proj_type const&, bool const*, bool const*, int, SPECTUB::discrf_type const*, int*, SPECTUB::wmh_type&, float const*) (SPECTUB_Weight3d.cxx:385)
==1156376== by 0x64C0DD9: stir::ProjMatrixByBinSPECTUB::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjMatrixByBinSPECTUB.cxx:650)
==1156376== by 0x64DA33E: stir::ForwardProjectorByBinUsingProjMatrixByBin::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ForwardProjectorByBinUsingProjMatrixByBin.cxx:100)
==1156376== by 0x64DDD07: stir::ProjectorByBinPair::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjectorByBinPair.cxx:47)
==1156376== by 0x64DE10C: stir::ProjectorByBinPairUsingProjMatrixByBin::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjectorByBinPairUsingProjMatrixByBin.cxx:88)
==1156376== by 0x6242DA7: _wrap_ProjectorByBinPairUsingProjMatrixByBin_set_up (stirPYTHON_wrap.cxx:128250)
==1156376== by 0x24C9DF: ??? (in /usr/bin/python3.10)
==1156376== by 0x250F51: _PyEval_EvalFrameDefault (in /usr/bin/python3.10)
==1156376== by 0x341E55: ??? (in /usr/bin/python3.10)
==1156376== by 0x341CF5: PyEval_EvalCode (in /usr/bin/python3.10)
==1156376== by 0x36C7D7: ??? (in /usr/bin/python3.10)
==1156376==
==1156376== Conditional jump or move depends on uninitialised value(s)
==1156376== at 0x64C3713: SPECTUB::calc_sigma_h(SPECTUB::voxel_type, SPECTUB::collim_type) (SPECTUB_Tools.cxx:815)
==1156376== by 0x64C72FD: SPECTUB::fill_psf_2d(SPECTUB::psf2da_type*, SPECTUB::psf1d_type*, SPECTUB::voxel_type const&, SPECTUB::discrf_type const*, float, SPECTUB::wmh_type&) (SPECTUB_Weight3d.cxx:599)
==1156376== by 0x64C7C7B: SPECTUB::wm_size_estimation(int, SPECTUB::angle_type const*, SPECTUB::voxel_type, SPECTUB::bin_type, SPECTUB::volume_type const&, SPECTUB::proj_type const&, bool const*, bool const*, int, SPECTUB::discrf_type const*, int*, SPECTUB::wmh_type&, float const*) (SPECTUB_Weight3d.cxx:402)
==1156376== by 0x64C0DD9: stir::ProjMatrixByBinSPECTUB::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjMatrixByBinSPECTUB.cxx:650)
==1156376== by 0x64DA33E: stir::ForwardProjectorByBinUsingProjMatrixByBin::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ForwardProjectorByBinUsingProjMatrixByBin.cxx:100)
==1156376== by 0x64DDD07: stir::ProjectorByBinPair::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjectorByBinPair.cxx:47)
==1156376== by 0x64DE10C: stir::ProjectorByBinPairUsingProjMatrixByBin::set_up(std::shared_ptr<stir::ProjDataInfo const> const&, std::shared_ptr<stir::DiscretisedDensity<3, float> const> const&) (ProjectorByBinPairUsingProjMatrixByBin.cxx:88)
==1156376== by 0x6242DA7: _wrap_ProjectorByBinPairUsingProjMatrixByBin_set_up (stirPYTHON_wrap.cxx:128250)
==1156376== by 0x24C9DF: ??? (in /usr/bin/python3.10)
==1156376== by 0x250F51: _PyEval_EvalFrameDefault (in /usr/bin/python3.10)
==1156376== by 0x341E55: ??? (in /usr/bin/python3.10)
==1156376== by 0x341CF5: PyEval_EvalCode (in /usr/bin/python3.10)
One of the possible reasons could be here:
in each condition for mask type the relative do_msk is set to true but the others should also be set to false. @KrisThielemans @samdporter do you agree? I suspect more similar stuff is below
in each condition for mask type the relative do_msk is set to true but the others should also be set to false.
looks like it. do_mask_att
isn't always set for instance.
A few others
wmh.att_fn
is never set. It should be set from this->attenuation_map
.set_attenuation_image_sptr(const shared_ptr<const DiscretisedDensity<3,float> > value)
should set this->attenuation_map
to "". There could be other set
functions where the relevant variable isn't initialised.wmh.COL.do_fb
is only initialised in an else
statement, which causes @samdporter problem. Looks like the collimator parameters need to be always set, even if do_psf
(which makes sense of course), so most of the lines in that else
statement need to be moved before the if(do_psf)
.I think some of these don't matter too much, as in many places the logic will generally not use the variables that aren't set. (For instance, some of the valgridn
messages occur only in the printing of information). But there have to be a few that do matter, so we'll have to work by elimination. Luckily valgrind
will tell us as we shouldn't have any uninitalized
warnings.
It's a bit weird that we get this now, but possible when wmh
was a global variable, the compiler initialised it somehow anyway (I'd need to brush up on my C++...).
wmh.COL.do_fb
is only initialised in anelse
statement, which causes @samdporter problem. Looks like the collimator parameters need to be always set, even ifdo_psf
(which makes sense of course), so most of the lines in thatelse
statement need to be moved before theif(do_psf)
.
I guess we don't need this if statement then we can just print "No correction for PSF. Parallel geometry" if (!wmh.do_psf)
also COL.num seem to be always zero when I debug but it's not intialised
similar to att_fn:
these are also not initalised though my debugger shows them as ""
@varzakis got some problems running the simplest forward projection of SPECT images with SIRF (python kernel crash). Skipping SIRF, we got an occasional crash with STIR directly. Trying to diagnose this by running the following
gives a lot of output on uninitialised values. Relevant lines seem to be https://github.com/UCL/STIR/blob/6124652f44b2599e6d5262640800495534cee60e/src/recon_buildblock/ProjMatrixByBinSPECTUB.cxx#L480 https://github.com/UCL/STIR/blob/6124652f44b2599e6d5262640800495534cee60e/src/recon_buildblock/ProjMatrixByBinSPECTUB.cxx#L556 https://github.com/UCL/STIR/blob/6124652f44b2599e6d5262640800495534cee60e/src/recon_buildblock/ProjMatrixByBinSPECTUB.cxx#L568 https://github.com/UCL/STIR/blob/6124652f44b2599e6d5262640800495534cee60e/src/recon_buildblock/ProjMatrixByBinSPECTUB.cxx#L585 https://github.com/UCL/STIR/blob/6124652f44b2599e6d5262640800495534cee60e/src/recon_buildblock/ProjMatrixByBinSPECTUB.cxx#L652
full output: