Thanks to visit codestin.com
Credit goes to github.com

Skip to content

* Fixed mashing for even number of TOF bins. - #1755

Open
NikEfth wants to merge 1 commit into
masterfrom
fix_tof_mashing
Open

* Fixed mashing for even number of TOF bins.#1755
NikEfth wants to merge 1 commit into
masterfrom
fix_tof_mashing

Conversation

@NikEfth

@NikEfth NikEfth commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Changes in this pull request

This PR fixes #1751. With even number of TOF abs, naive inversion does not work. If even we need to subtract 1.
Now, both -1 and 0 become a mashed TOF bin 0 but they have inverted detectors.

Testing performed

New tests introduced to explicitly check the transformation with even and odd TOF bins, with and without mashing.

Related issues

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have added docstrings/doxygen in line with the guidance in the developer guide
  • I have implemented unit tests that cover any new or modified functionality (if applicable)
  • The code builds and runs on my machine
  • [] documentation/release_XXX.md has been updated with any functionality change (if applicable)

Contribution Notes

Please tick the following:

  • The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in STIR (the Work) under the terms and conditions of the Apache-2.0 License.
  • I (or my institution) have signed the STIR Contribution License Agreement (not required for small changes).

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 6 duplication

Metric Results
Complexity 0
Duplication 6

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.


dp.timing_pos() = std::abs(bin.timing_pos_num()) * this->get_tof_mash_factor();
dp.timing_pos()
= (bin.timing_pos_num() >= 0 ? bin.timing_pos_num() : -bin.timing_pos_num() - (this->get_num_tof_poss() % 2 == 0))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure a bool converts to 1?
probably clearer/safer would be

(this->get_num_tof_poss() % 2 == 0 ? 1 : 0)

Or cryptic

(1 - (this->get_num_tof_poss() % 2))

@KrisThielemans KrisThielemans left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this correct?

You put in changes for even number tof bins, but the number of timing_pos could also be even. Do we cope with this? Same convention?

We want the dp.timing_pos correspond to the centre of the (mashed) TOF bin.

Examples that seem to give undesirable results

  • num_tof_bins is even
bin.timing_pos_num centred_range for bin centred_range for dp.timing_pos actual (asymmetric) range
0 0.5 0.5 * mash 0.5 * mash - 0.5

dp.timing_pos wouldn't be integer if mash is even

  • num_tof_bins is odd, but mash is even
bin.timing_pos_num centred_range for bin centred_range for dp.timing_pos actual (asymmetric) range
0 0 0 -0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

potential problems with even TOF bins and TOF mashing

3 participants