Skip to content

Commit

Permalink
Merge pull request #1124 from KrisThielemans/betterSPECTMessage
Browse files Browse the repository at this point in the history
Better SPECT message if attenuation doesn't match
  • Loading branch information
KrisThielemans authored Jan 8, 2023
2 parents 2ff4a2a + 62290dd commit c226f7b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions documentation/release_5.1.htm
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ <h3>Changed functionality</h3>
<li>(private) bitfields <code>random</code> or <code>isRandom</code> have been renamed to <code>delayed</code>
to avoid confusion. Affected listmode file formats are SAFIR, ECAT962 and ECAT966.
</li>
<li><code>DiscretisedDensityDensity::has_same_characteristics</code> now adds actual origins and grid spacing to the explanation if they are different.
</li>
<li><code>ProjMatrixByBinSPECTUB</code> prints an explanation when the attenuation image has different characteristics.
</li>
</ul>

<h3>Build system and dependencies</h3>
Expand Down
12 changes: 10 additions & 2 deletions src/include/stir/DiscretisedDensity.inl
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ actual_has_same_characteristics(DiscretisedDensity<num_dimensions, elemT> const&
}

if (norm(other.get_origin() - this->get_origin()) > 1.E-2)
{
explanation = "Not the same origin.";
{
char tmp[2000];
snprintf(tmp, 2000, "Not the same origin: (%g,%g,%g) and (%g,%g,%g)",
other.get_origin()[1],
other.get_origin()[2],
other.get_origin()[3],
this->get_origin()[1],
this->get_origin()[2],
this->get_origin()[3]);
explanation = tmp;
return false;
}
if (other.get_index_range() != this->get_index_range())
Expand Down
3 changes: 2 additions & 1 deletion src/include/stir/DiscretisedDensityOnCartesianGrid.inl
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ actual_has_same_characteristics(DiscretisedDensity<num_dimensions, elemT> const&
if (norm(other.get_grid_spacing() - this->get_grid_spacing()) > 1.E-4F*norm(this->get_grid_spacing()))
{
char tmp[2000];
sprintf(tmp, "Not the same grid spacing: (%g,%g,%g) and (%g,%g,%g)",
snprintf(tmp, 2000, "Not the same grid spacing: (%g,%g,%g) and (%g,%g,%g)",
other.get_grid_spacing()[1],
num_dimensions>1?other.get_grid_spacing()[2]:0.,
num_dimensions>2?other.get_grid_spacing()[3]:0.,
this->get_grid_spacing()[1],
num_dimensions>1?this->get_grid_spacing()[2]:0.,
num_dimensions>2?this->get_grid_spacing()[3]:0.);
explanation = tmp;
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/recon_buildblock/ProjMatrixByBinPinholeSPECTUB.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,9 @@ set_up(
if ( wmh.do_att ){
if (is_null_ptr(attenuation_image_sptr))
error("Attenuation image not set.");

if (!density_info_ptr->has_same_characteristics(*attenuation_image_sptr))
error("Currently the attenuation map and emission image must have the same dimension, orientation, and voxel size.");
std::string explanation;
if (!density_info_ptr->has_same_characteristics(*attenuation_image_sptr, explanation))
error("Currently the attenuation map and emission image must have the same dimension, orientation, and voxel size:\n" + explanation);

if ( ( attmap = new (nothrow) float [ wmh.vol.Nvox ] ) == nullptr )
error("Error allocating space to store values for attenuation map.");
Expand Down
5 changes: 3 additions & 2 deletions src/recon_buildblock/ProjMatrixByBinSPECTUB.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,9 @@ set_up(
if ( wmh.do_att || wmh.do_msk_att ){
if (is_null_ptr(attenuation_image_sptr))
error("Attenation image not set");
if (!density_info_ptr->has_same_characteristics(*attenuation_image_sptr))
error("Currently the attenuation map and emission image must have the same dimension, orientation and voxel size");
std::string explanation;
if (!density_info_ptr->has_same_characteristics(*attenuation_image_sptr, explanation))
error("Currently the attenuation map and emission image must have the same dimension, orientation and voxel size:\n" + explanation);

attmap = new float [ vol.Nvox ];
std::copy(attenuation_image_sptr->begin_all(), attenuation_image_sptr->end_all(),attmap);
Expand Down

0 comments on commit c226f7b

Please sign in to comment.