Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master at v5.2.0 to TOF #52

Merged

Conversation

KrisThielemans
Copy link
Collaborator

@KrisThielemans KrisThielemans commented Nov 7, 2023

This merge uses SegmentIndices, ViewgramIndices, SinogramIndices (as in v5.2.0), but adding timing_pos_num to SegmentIndices. Functionality should be identical to previous status..

Note that DataSymmetries* have not been rewritten yet and still ignore timing_pos_num in ViewSegmentNumbers (as it wasn't in there).

Fixed a number of small problems along the way, including the fact that ProjMatrixByBin::set_up() didn't initialise the internal member image_info_sptr while the TOF calculation used it. (ProjMatrixByBinUsingRayTracing::set_up did the initialisation, but that meant that other classes derived from ProjMatrixByBin were not TOF-ready).

Edit before merge: This PR fixed a few other things and had to work around some problems, see comments (and commit messages) below. It also sets the version to 6.0.0.

KrisThielemans and others added 30 commits July 13, 2020 15:52
…d ring2;

save axial effects to file;
added interfileRawDataHeaderSiemens;
initialise view and tang_pos to 0 in construct_sino_lookup_table().
- created new class InterfileNormHeaderSiemens where all the parsing is
done (moving some bits from BinNormalisationFromECAT8, but adding much
more)
- add more consistency checks after parsing (still not enough)
- fix problem that we always assumed span=11 in the norm header
as we now parse it
- fix creating of internal proj_data_info which assumed
max_ring_difference=num_rings-1 as we now parse it
we were using the wrong variable in a loop in construct_sino_lookup_table.
Also use number of non-tof sinograms.
unclear use of member variable and argument, probably was a bug
that the argument was ignored.
Siemens data is often acquired with max_ring_difference < num_rings-1, and the
axial_effects stored are therefore limited. We now extrapolate them to just use 1.
variable was not initialised before

also do an explicit run-time error check and clean-up some
white-space
added write_components_to_file keyword (only setable via parsing)
by default set to false.
We found that we need to divide as opposed to multiply with the axial effect factors
There was a duplicate line in the other order. Removed now
before we were using a single axial effect factor. Now, we
will use all of them appropriate for a particular span.
Results are the same for span=11.

Also
- removed the unused "span" member variable
- write warning about larger max ring diffs in set_up() to avoid
local static variable
- throw as opposed to return Succeeded::no, improving user experience in Python
- more informative messages if anything is wrong
this enables more concise code (avoiding the need for comparing with Succeeded::yes
which is especially verbose in Python).
Also make Bin.time_frame_num a variable in Python like other members
@danieldeidda
Copy link

@danieldeidda I seem to have no difference in the comparison of forward projection, but do have the same differences in the sensitivity image.

remind me: are you comparing your pr result with the UCL branch?

@KrisThielemans
Copy link
Collaborator Author

with NikEfth/tof_sino_UCL, yes

@KrisThielemans
Copy link
Collaborator Author

In fact, I see a difference in the non-TOF sensitivity as well, where tof_sino_UCL produces zero-end planes (which seems wrong), while this PR doesn't. Which might say that this PR introduces a terrible bug, but solves another one... Not sure yet!

@KrisThielemans
Copy link
Collaborator Author

non-TOF sensitivity on this PR is the same as on master as far as I can see. tof_sino_UCL seems to ignore the zero end plane in segment 0:=0 option used in this test. (run_tests.sh uses span=1 data and sets zero end planes of segment 0:= 1, so it works on the tof_sino_UCL branch).

All this doesn't explain why the sensitivity of the TOF recon is wrong of course (which is by the way a non-TOF calculation)

@KrisThielemans
Copy link
Collaborator Author

The problem disappears when using TOF for the sensitivity calculation (use time-of-flight sensitivities := 1). When this setting is 0 (the default), the TOF backprojector is used anyway, and backprojects only TOF bin 0.

@KrisThielemans
Copy link
Collaborator Author

The problem is (amazingly) in ProjDataInfo::operator== (actually *::blindly_equals), which doesn't check tof_mash_factor. It therefore claims that the TOF and nonTOF proj_data_info are equal, causing ProjMatrixByBin::set_up() for the nonTOF calculation to skip the set_up, and therefore doing TOF calculations anyway.

set_up() checks if norm_proj_data_info >= emission_proj_data_info but
needs to handle non-TOF norm data and TOF emssion data.

Previously this worked as ProjDataInfo::blindly_equal ignored TOF_mashing,
but that is no longer the case, so we need to handle this here.
Tell use they can set STIR_CONFIG_DIR env variable
make sure that currect normalisation::set_up is used for either
sensitivity, log-likelihood or Hessian calculations

Still need to do listmode

Partially fixes NikEfth#56
@KrisThielemans
Copy link
Collaborator Author

351c29d fixed the sensitivity problem #56, although only for ProjData. Code still needs to be ported to listmode (which currently needs duplication sadly).

New error is in run_root_GATE.sh where we get

Number of prompts stored in this time period: 134580
True events in ROOT file : 134582

This is likely a long-standing problem on tof_sino_UCL though. I had it on my laptop but thought it was my (old) ROOT version. It turns out that run_root_GATE.sh isn't run on tof_sino_UCL GHA though, so we never checked. It's only because we merge a correction from master to the GHA workflow that we now see the problem here. (Note that the test does work on master).

- the script itself was a bit garbled
- it failed because the num_tangential_poss in the .hroot was too small compared to the data,
such that counts didn't match
- the hroot and template.hs were inconsistent (max num non-arccorrected)

I've also made the template TOF.
…n tang_poss

Also small clean-up by re-using constructor (C++11 feature)
insert break such that the script doesn't continue with tests that will fail
had to fix some files accordingly
- updated README (was still referring to test_root_view_offset)
- needed a small Python fix. Also changed label strategy to be clearer.
-
@KrisThielemans KrisThielemans force-pushed the merge_master_at_v5.2.0_to_TOF branch from 4b362c3 to 3846284 Compare December 29, 2023 08:27
@KrisThielemans KrisThielemans force-pushed the merge_master_at_v5.2.0_to_TOF branch from d193c6a to 01075f6 Compare December 30, 2023 16:22
@KrisThielemans
Copy link
Collaborator Author

KrisThielemans commented Dec 31, 2023

After merging tof_sino_UCL, to pick up the fixes on energy resolution info in ROOT to avoid seg-faults and "compressed" listmode data (#55), run_root_GATE.sh again fails for all events with

Running lm_to_projdata for all events
Number of prompts stored in this time period: 134820
Reading values directly from ROOT file
All events in ROOT file : 135062
Mismatched number of events!

Reason for this is that the test_PET_GATE.root file contains some weird events with too large time difference, but how this is handled is a bit complicated. (see also #58)

After the previous merge, the "internal" ProjDataInfo for CListModeDataROOT is "uncompressed" (before the merge, it had TOF mashing 82, as per the root_header.hroot file). The "out-of-range" events are currently assigned min_tof_pos_num, which is now -205 and has time-range -2055 - -2045 ps. LmToProjData tries to put this into the "TOF mashed" proj-data using CListEventScannerWithDiscreteDetectors::get_bin, which calls ProjDataInfo::get_bin_for_det_pos_pair which assigns this a "mashed TOF" timing_pos_num -3 (by dividing by 82). This is out-of-range, and hence the events don't get stored.

On the other hand, if the TOF mashing factor is set to 1 in both the .hroot and template, then the events do get stored (at the "first" TOF bin), and the test succeeds.

@KrisThielemans
Copy link
Collaborator Author

Fixing #58 is out-of-scope for this PR. Instead, I will modify the template and .hroot to use TOF mashing factor 1, but with 82 times wider TOF bins (which is equivalent to what was used before). With that, the test succeeds.

Motivation is twofold:
- it doesn't make a lot of sense to have TOF mashing keyword in a ROOT file
- run_root_GATE.sh failed due to events that have very large time diff in the test ROOT file.
( see NikEfth#52 (comment) for details)
@KrisThielemans
Copy link
Collaborator Author

I am postponing the sensitivity sync to listmode for later...

@KrisThielemans KrisThielemans merged commit 12e0fff into NikEfth:tof_sino_UCL Dec 31, 2023
5 checks passed
@KrisThielemans KrisThielemans deleted the merge_master_at_v5.2.0_to_TOF branch December 31, 2023 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants