reading of PETSIRD list-mode function#1604
Conversation
|
PETSIRD requires additional dependencies (yardl, pinned xtensor) that are not part of STIR’s standard CI environment. |
|
There is a problem with the TOF tests. Very likely, this happened because in this PR I allowed the use of an even number of TOF bins (because my PETSIRD files had an even number). I may have overlooked something regarding the odd number (default in the tests). |
There was a problem hiding this comment.
Pull request overview
This PR introduces initial support for reading PETSIRD (PET Standard for Image Reconstruction and Data) list-mode files into STIR. The work includes scanner geometry inference, coordinate mapping, and the necessary infrastructure to handle PETSIRD data formats (both HDF5 and binary).
- Adds PETSIRD submodule integration with CMake configuration
- Implements PETSIRD list-mode data reader with automatic scanner geometry detection
- Refactors SAFIR list-mode classes to share common base functionality
- Includes TOF handling improvements for even-numbered TOF bins
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| CMakeLists.txt | Adds PETSIRD as optional dependency with submodule management |
| src/buildblock/PETSIRDInfo.cxx | Core geometry inference logic for PETSIRD scanners |
| src/listmode_buildblock/CListModeDataPETSIRD.cxx | Main PETSIRD list-mode reader implementation |
| src/include/stir/listmode/CListModeDataBasedOnCoordinateMap.h | New base class for coordinate-mapped list-mode data |
| src/buildblock/ProjDataInfo.cxx | Refactored TOF mash factor logic with even bin support |
| src/include/stir/ProjDataInfoCylindricalNoArcCorr.inl | Fixed TOF bin mapping for even TOF bins |
| src/IO/PETSIRDCListmodeInputFileFormat.cxx | File format detection for PETSIRD files |
| .github/workflows/build-test.yml | CI updates to disable PETSIRD in existing tests |
Comments suppressed due to low confidence (4)
src/recon_buildblock/find_basic_vs_nums_in_subset.cxx:1
- The commented-out loop and loose braces suggest incomplete refactoring. Either remove the commented code or complete the intended changes to maintain code clarity.
src/recon_buildblock/find_basic_vs_nums_in_subset.cxx:1 - Debug print statements should be removed before merging. These commented-out std::cout calls are leftover debugging code that clutters the source.
src/include/stir/listmode/CListModeDataBasedOnCoordinateMap.h:1 - File header comment references wrong class. This header is for CListModeDataBasedOnCoordinateMap, not CListModeDataSAFIR.
/* CListModeDataSAFIR.h
CMakeLists.txt:1
- All optional dependencies have been changed from OFF to ON (disabled by default). This appears to be a temporary development change that should not be merged. These defaults would break existing functionality for other users.
# This file is part of STIR.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Introduce PETSIRDInfo as a dataset-level integration object for PETSIRD PETSIRDInfo encapsulates all PETSIRD-specific static information needed
PETSIRDInfo is immutable after construction and shared via The PETSIRD listmode implementation was updated accordingly:
These changes preserve STIR’s separation of concerns, avoid PETSIRD |
KrisThielemans
left a comment
There was a problem hiding this comment.
This is mostly clean. thanks! A lot of my comments are housekeeping, but there are some important ones. Major thing is to keep this PR separate from other things (I won't accept this PR with them...), for example:
- there are some changes here for
set_proj_data_infowhich probably came from another PR. Maybe they'll disappear when you merge master here - there are changes here to cope with even number of TOF bins. They might be good, but it doesn't have anything to do with PETSIRD.
- there's some changes in
find_basic_vs_nums...which don't belong here - I see no reason to make
InputFormat::can_readnon-const. If this is really required for PETSIRD, please explain. We should then work around it.
I guess the BinNormalisation isn't finished yet. I would suggest we currently call error and do it in a separate PR.
|
You van have mutable members
Kris
________________________________
From: Nikos Efthimiou ***@***.***>
Sent: Wednesday, March 4, 2026 10:02:46 AM
To: UCL/STIR ***@***.***>
Cc: Kris Thielemans ***@***.***>; Author ***@***.***>
Subject: Re: [UCL/STIR] reading of PETSIRD list-mode function (PR #1604)
⚠ Caution: External sender
@NikEfth commented on this pull request.
________________________________
In src/include/stir/IO/InputFileFormat.h<#1604 (comment)>:
@@ -46,7 +46,7 @@ class InputFileFormat
{
return this->actual_can_read(signature, input);
}
- virtual bool can_read(const FileSignature& signature, const std::string& filename) const
+ virtual bool can_read(const FileSignature& signature, const std::string& filename)
This was necessary to support both the HDF5 and binary versions of PETSIRD. I could not think another way arround it.
—
Reply to this email directly, view it on GitHub<#1604 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABQRIHMFCYAB5WGTRVX5QVT4O75MNAVCNFSM6AAAAACBU47CHKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTQOBYGM4DKOJQHE>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
NikEfth
left a comment
There was a problem hiding this comment.
[x] there are some changes here for set_proj_data_info which probably came from another PR. Maybe they'll disappear when you merge master here
- Merged with master is fine now.
[ x] there are changes here to cope with even number of TOF bins. They might be good, but it doesn't have anything to do with PETSIRD.
- I know. But I had to make them as the data shared by people in the hackathon had even number of bins. If you you want to compare with that we need these changes here. I can document more.
[x] there's some changes in find_basic_vs_nums... which don't belong here
- Yes that code doesn't do anything atm.
[x] I see no reason to make InputFormat::can_read non-const. If this is really required for PETSIRD, please explain. We should then work around it.
- Done
[x] I guess the BinNormalisation isn't finished yet. I would suggest we currently call error and do it in a separate PR.
- No it is finished. Unless you have comments.
| - Mat3: std::array<std::array<float,3>,3> for compact fixed-size storage. | ||
| - Vec3: std::array<float,3> for simple 3D vectors. |
There was a problem hiding this comment.
OK. I started a bit of this. From the test_ . It won't be hard.
KrisThielemans
left a comment
There was a problem hiding this comment.
some other clean-up suggestions
|
Do you want the |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| BestPractice | 1 minor |
🟢 Metrics 225 complexity · 8 duplication
Metric Results Complexity 225 Duplication 8
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.
|
@casperdcl This is the PR |
KrisThielemans
left a comment
There was a problem hiding this comment.
Looks like CI is working! Great. (The MacOS job fails because of too much stuff in .h/.inl, see previous review).
|
Hi, I wanted to replace the |
|
I tried the interactive rebase, but it introduces a lot of old code and mege conflicts |
|
please don't push that! |
|
which one? The interactive rebase? Sure :) any other advice? |
|
The trick would be to interactive rebase on the commit that we branched off from (not on master). |
|
I want to flag for you that the macOS builds here are (since 15 May) consuming the free Actions budget we have available in the UCL organisation, because even though this is a public repo the use of larger runners is always charged for. The budget for June has now been used up. Could you look into doing fewer Mac builds or reducing the build time? |
It appears this was a false alarm: despite GitHub's web UI reporting this repository as the biggest consumer of our actions budget, actually the runners used are free and don't count towards the limit. It was actually a couple of other private repositories that don't even make the top 10 overall users that were consuming the limited budget! But you have to look at the raw data rather than any of the dashboards to be able to tell that... |
|
Thanks @jonc125! In any case, there's a good message here that we should be careful in pushing to Github. Small commits use computing resources that should be used elsewhere. |
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| BestPractice | 1 minor |
🟢 Metrics 232 complexity · 8 duplication
Metric Results Complexity 232 Duplication 8
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.
|
@KrisThielemans I don't think I can clean up the history more. At |
mainly a copy at this stage
| if (num_tof_bins % 2 == 0) | ||
| error("ProjDataInfo: Number of TOF bins should be an odd number. Abort."); | ||
| const int num_mashed_bins = max_timing_poss / tof_mash_factor; | ||
| num_tof_bins = num_mashed_bins; |
There was a problem hiding this comment.
did you fix this?
| BinNormalisationFromPETSIRD::read_norm_data(const string& filename) | ||
| { | ||
| petsird::Header header; | ||
| petsird_data_sptr.reset(new petsird::binary::PETSIRDReader(filename)); |
There was a problem hiding this comment.
I guess cope with HDF5
Using PETSIRD 0.9.1
|
Looks like we're green, and only 2 comments left! However, i haven't actually run this. It'd be great to add a test like
However, this is probably non-trivial due to the possibility of different coordinates/order. @NikEfth what do you think? |
|
well, at least I hope it's green now... |

Adding support for PETSIRD.
Warning: this changes SAFIR reading (although we think it should be safe), as we lifted a lot of its code to a new class
CListModeDataBasedOnCoordinateMapTo be able to test with existing PETSIRD files, @NikEfth also added support for even number of TOF bins. So...
Fixes #1333