Skip to content

Commit a170529

Browse files
Merge pull request #1331 from KrisThielemans/RFSfixes
randoms from singles fixes, and related changes to coincidence width (moved method to Scanner)
2 parents e8f2dd8 + 2c776e3 commit a170529

18 files changed

+244
-126
lines changed

documentation/release_6.0.htm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,23 @@ <h4>Non-TOF related</h4>
292292
</li>
293293
</ul>
294294

295+
<h3>Changed functionality</h3>
296+
297+
<h4>TOF related</h4>
298+
<ul>
299+
<li>
300+
<code>ProjDataInfoCylindricalNoArcCorr::get_all_det_pos_pairs_for_bin</code> is in most places intended to return
301+
the physical locations. However, a `DetectionPositionPair` also contains (unmashed) TOF bin information.
302+
This will be further complicated once energy windows are supported. The
303+
method therefore has an extra boolean argument <code>ignore_non_spatial_dimensions</code>, which defaults to
304+
<code>true</code>.
305+
</li>
306+
<li>
307+
<code>multiply_crystal_factors</code> is essentially a non-TOF calculation. When given TOF projection data,
308+
it will "spread" the non-TOF result equally over all TOF bins. This is also appropriate for
309+
<code>randoms_from_singles</code>.
310+
</li>
311+
</ul>
295312

296313
</body>
297314

src/buildblock/ProjDataInfo.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "stir/IndexRange2D.h"
4242
#include "stir/IndexRange3D.h"
4343
#include "stir/Bin.h"
44+
#include "stir/TOF_conversions.h"
4445
// include for ask and ask_num
4546
#include "stir/utilities.h"
4647
#include "stir/warning.h"

src/buildblock/ProjDataInfoCylindricalNoArcCorr.cxx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -336,31 +336,42 @@ initialise_det1det2_to_uncompressed_view_tangpos() const
336336

337337
unsigned int
338338
ProjDataInfoCylindricalNoArcCorr::
339-
get_num_det_pos_pairs_for_bin(const Bin& bin) const
339+
get_num_det_pos_pairs_for_bin(const Bin& bin, bool ignore_non_spatial_dimensions) const
340340
{
341341
return
342342
get_num_ring_pairs_for_segment_axial_pos_num(bin.segment_num(),
343343
bin.axial_pos_num())*
344344
get_view_mashing_factor()*
345-
std::max(1,get_tof_mash_factor());
345+
(ignore_non_spatial_dimensions ? 1 : std::max(1,get_tof_mash_factor()));
346346
}
347347

348348
void
349349
ProjDataInfoCylindricalNoArcCorr::
350350
get_all_det_pos_pairs_for_bin(vector<DetectionPositionPair<> >& dps,
351-
const Bin& bin) const
351+
const Bin& bin,
352+
bool ignore_non_spatial_dimensions) const
352353
{
353354
this->initialise_uncompressed_view_tangpos_to_det1det2_if_not_done_yet();
354355

355-
dps.resize(get_num_det_pos_pairs_for_bin(bin));
356+
dps.resize(get_num_det_pos_pairs_for_bin(bin, ignore_non_spatial_dimensions));
356357

357358
const ProjDataInfoCylindrical::RingNumPairs& ring_pairs =
358359
get_all_ring_pairs_for_segment_axial_pos_num(bin.segment_num(),
359360
bin.axial_pos_num());
360361
// not sure how to handle mashing with non-zero view offset...
361362
assert(get_min_view_num()==0);
362-
// not sure how to handle even tof mashing
363-
assert(!is_tof_data() || (get_tof_mash_factor() % 2 == 1));
363+
364+
int min_timing_pos_num = 0;
365+
int max_timing_pos_num = 0;
366+
if (!ignore_non_spatial_dimensions)
367+
{
368+
// not sure how to handle even tof mashing
369+
assert(!is_tof_data() || (get_tof_mash_factor() % 2 == 1)); // TODOTOF
370+
// we will need to add all (unmashed) timing_pos for the current bin
371+
min_timing_pos_num = bin.timing_pos_num()*get_tof_mash_factor() - (get_tof_mash_factor() / 2);
372+
max_timing_pos_num = bin.timing_pos_num()*get_tof_mash_factor() + (get_tof_mash_factor() / 2);
373+
}
374+
364375
unsigned int current_dp_num=0;
365376
for (int uncompressed_view_num=bin.view_num()*get_view_mashing_factor();
366377
uncompressed_view_num<(bin.view_num()+1)*get_view_mashing_factor();
@@ -370,34 +381,23 @@ get_all_det_pos_pairs_for_bin(vector<DetectionPositionPair<> >& dps,
370381
uncompressed_view_tangpos_to_det1det2[uncompressed_view_num][bin.tangential_pos_num()].det1_num;
371382
const int det2_num =
372383
uncompressed_view_tangpos_to_det1det2[uncompressed_view_num][bin.tangential_pos_num()].det2_num;
373-
for (ProjDataInfoCylindrical::RingNumPairs::const_iterator rings_iter = ring_pairs.begin();
374-
rings_iter != ring_pairs.end();
375-
++rings_iter)
384+
for (auto rings_iter = ring_pairs.begin(); rings_iter != ring_pairs.end(); ++rings_iter)
376385
{
377-
for (int uncompressed_timing_pos_num = bin.timing_pos_num()*get_tof_mash_factor() - (get_tof_mash_factor() / 2);
378-
uncompressed_timing_pos_num <= bin.timing_pos_num()*get_tof_mash_factor() + (get_tof_mash_factor() / 2);
386+
for (int uncompressed_timing_pos_num = min_timing_pos_num;
387+
uncompressed_timing_pos_num <= max_timing_pos_num;
379388
++uncompressed_timing_pos_num)
380389
{
381-
assert(current_dp_num < get_num_det_pos_pairs_for_bin(bin));
390+
assert(current_dp_num < get_num_det_pos_pairs_for_bin(bin, ignore_non_spatial_dimensions));
382391
dps[current_dp_num].pos1().tangential_coord() = det1_num;
383392
dps[current_dp_num].pos1().axial_coord() = rings_iter->first;
384393
dps[current_dp_num].pos2().tangential_coord() = det2_num;
385394
dps[current_dp_num].pos2().axial_coord() = rings_iter->second;
386-
// need to keep dp.timing_pos positive
387-
if (uncompressed_timing_pos_num > 0)
388-
{
389-
dps[current_dp_num].timing_pos() = static_cast<unsigned>(uncompressed_timing_pos_num);
390-
}
391-
else
392-
{
393-
std::swap(dps[current_dp_num].pos1(), dps[current_dp_num].pos2());
394-
dps[current_dp_num].timing_pos() = static_cast<unsigned>(-uncompressed_timing_pos_num);
395-
}
395+
dps[current_dp_num].timing_pos() = uncompressed_timing_pos_num;
396396
++current_dp_num;
397397
}
398398
}
399399
}
400-
assert(current_dp_num == get_num_det_pos_pairs_for_bin(bin));
400+
assert(current_dp_num == get_num_det_pos_pairs_for_bin(bin, ignore_non_spatial_dimensions));
401401
}
402402

403403
Succeeded

0 commit comments

Comments
 (0)