Skip to content

reading of PETSIRD list-mode function#1604

Open
KrisThielemans wants to merge 131 commits into
masterfrom
PETSIRD
Open

reading of PETSIRD list-mode function#1604
KrisThielemans wants to merge 131 commits into
masterfrom
PETSIRD

Conversation

@KrisThielemans
Copy link
Copy Markdown
Collaborator

WIP

@KrisThielemans KrisThielemans self-assigned this Jul 16, 2025
Copy link
Copy Markdown
Collaborator

@NikEfth NikEfth left a comment

Choose a reason for hiding this comment

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

[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.

Comment on lines +20 to +21
- Mat3: std::array<std::array<float,3>,3> for compact fixed-size storage.
- Vec3: std::array<float,3> for simple 3D vectors.
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.

OK. I started a bit of this. From the test_ . It won't be hard.

Comment thread src/include/stir/listmode/CListModeDataSAFIR.h
else
{
bin.timing_pos_num() = -timing_pos_num;
bin.timing_pos_num() = -timing_pos_num - (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.

I am sorry, I don't understand. We need to make adjustments for even and odd number of bins.

auto stir_scanner_sptr = petsird_info_sptr->get_scanner_sptr();

int tof_mash_factor = 1;
this->set_proj_data_info_sptr(std::const_pointer_cast<const ProjDataInfo>(
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.

experimenting.

Comment on lines +42 to +43
// for (int timing_pos_num = proj_data_info.get_min_tof_pos_num(); timing_pos_num <= proj_data_info.get_max_tof_pos_num();
// ++timing_pos_num)
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.

This is n't used atm.

@NikEfth NikEfth marked this pull request as ready for review March 20, 2026 13:04
Copy link
Copy Markdown
Collaborator Author

@KrisThielemans KrisThielemans left a comment

Choose a reason for hiding this comment

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

some other clean-up suggestions

Comment thread src/include/stir/ArrayFunction.inl Outdated
Comment on lines +363 to +369
find_unique_values(std::set<elemT>& values, const Array<num_dim, elemT>& input)
{
for (int i = input.get_min_index(); i <= input.get_max_index(); ++i)
{
find_unique_values(values, input[i]);
}
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This will fail, as input[i] is an num_dim-1 array. You probably wanted to iterate using begin_all(), but as it doesn't create trouble, it means this function isn't used, so you could cut it. If it is needed, the 1D and nD implementation could be the same.

Comment thread src/listmode_buildblock/CListModeDataBasedOnCoordinateMap.cxx Outdated
Comment thread src/listmode_buildblock/CListModeDataBasedOnCoordinateMap.cxx Outdated
Comment thread CMakeLists.txt Outdated
Comment thread CMakeLists.txt
Comment thread src/include/stir/listmode/CListModeDataSAFIR.h Outdated
Comment thread src/include/stir/listmode/CListModeDataBasedOnCoordinateMap.h Outdated
Copy link
Copy Markdown
Collaborator

@NikEfth NikEfth left a comment

Choose a reason for hiding this comment

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

all done

@NikEfth
Copy link
Copy Markdown
Collaborator

NikEfth commented Mar 20, 2026

Do you want the PETSIRDInfo_helpers with stir::Arrays?

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 22, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 219 complexity · 8 duplication

Metric Results
Complexity 219
Duplication 8

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.

@NikEfth
Copy link
Copy Markdown
Collaborator

NikEfth commented May 28, 2026

@casperdcl This is the PR


template <typename elemT>
inline void
find_unique_values(std::set<elemT>& values, const Array<1, elemT>& input)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

why not use use begin_all(), end_all(), then you need don' t need the template specialisation. In fact, I'm not sure if we then need the function at all as it's a 2 liner.

else
{
bin.timing_pos_num() = -timing_pos_num;
bin.timing_pos_num() = -timing_pos_num - (get_num_tof_poss() % 2 == 0);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this needs discussion and serious thought

Comment thread CMakeLists.txt
Comment on lines +299 to +302
string(REGEX MATCH "cxx_std_([0-9]+)" _petsird_std_match "${_petsird_features}")
if(CMAKE_MATCH_1)
UseCXX(${CMAKE_MATCH_1})
endif()
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

impressive enough, but should not be necessary AFAIK. If the target set C++ version, then it should automatically transcend. no?

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.

Yes, that is true.

Comment on lines +27 to +30
#include "stir/ProjData.h"
#include "stir/ProjDataInfo.h"
#include "stir/listmode/CListRecord.h"
#include "stir/IO/InputStreamWithRecords.h"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

all of these are unused in the .h, so should be removed. However, we do need DetectorCoordinateMap.h

If listmode reconstruction is done, the map is regenerated on-the-fly.

*/
class CListModeDataPETSIRD : public CListModeDataBasedOnCoordinateMap
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

whenever you're ready, move implementations to .cxx

Comment on lines +10 to +12
#include <iostream>
#include <fstream>
#include "stir/Succeeded.h"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

looks like we don't need any of this


SPDX-License-Identifier: Apache-2.0
See STIR/LICENSE.txt for detail
/*!
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

close comment first (compiler warning otherwise)

Comment on lines +18 to +31
#include "stir/DetectionPosition.h"
#include "stir/DetectionPositionPair.h"
#include "petsird/protocols.h"
#include "stir/Scanner.h"
#include "stir/DetectorCoordinateMap.h"
#include "stir/ProjDataInfo.h"
#include <set>
#include "stir/format.h"
#include "stir/info.h"
#include "stir/error.h"

#include "petsird_helpers.h"
#include "petsird_helpers/create.h" // for make_detection_bin
#include "petsird_helpers/geometry.h" // depending on where get_detection_efficiency lives
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

only include whatever is needed for the class definition and .inl (which should be as little as possible). Several reasons:

  • easier to understand
  • less auto-generated dependencies, so faster recompilation
  • no (less?) issues with compiling registries, like we currently have for the MacOS job
    in file included from /Users/runner/work/STIR/STIR/src/recon_buildblock/recon_buildblock_registries.cxx:87:
    In file included from /Users/runner/work/STIR/STIR/src/include/stir/recon_buildblock/BinNormalisationFromPETSIRD.h:27:
    In file included from /Users/runner/work/STIR/STIR/src/include/stir/PETSIRDInfo.h:25:
    /Users/runner/work/STIR/STIR/src/include/stir/format.h:40:12: fatal error: 'fmt/format.h' file not found
    40 | #  include "fmt/format.h"
    

Copy link
Copy Markdown
Collaborator Author

@KrisThielemans KrisThielemans left a comment

Choose a reason for hiding this comment

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

Looks like CI is working! Great. (The MacOS job fails because of too much stuff in .h/.inl, see previous review).

case ${{matrix.os}} in
(ubuntu* | macOS*)
sudo .github/workflows/GHA_increase_disk_space.sh
if [ "${ACT:-false}" = "true" ]; then
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

what is this? Is it https://github.com/nektos/act? Please add a comment line

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.

I forgot to remove it. I ran to problems executing the CI locally, as I don't have Github's infracture and this stops the execution of the GHA_increase_disk_space.
I run the CI like this:
act -W .github/workflows/build-test.yml -P ubuntu-24.04=ghcr.io/catthehacker/ubuntu:act-24.04 --env ACT=true

Copy link
Copy Markdown
Collaborator Author

@KrisThielemans KrisThielemans May 29, 2026

Choose a reason for hiding this comment

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

keep it in. Seems quite useful anyway. But document, and add 2 lines in the developers guide

cache-environment: true
cache-downloads: true

- name: Add STIR dependencies in PETSIRD environent
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
- name: Add STIR dependencies in PETSIRD environent
- name: Add STIR dependencies in PETSIRD environment

shell: bash -el {0}
run: |
set -ex
micromamba install -y -n yardl -c conda-forge boost-cpp swig matplotlib
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hopefully we don't need matplotlib. It's a large dependency...

Also, I'm doubtful of having boost-cpp and swig here, but also via APT/brew below. Do we really need this here?

mkdir -p build
cd build

cmake .. \
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
cmake .. \
cmake .. \
-G Ninja \

as we use that for STIR itself, it provides clearer messages, and means we don't need make

BUILD_TYPE: "Release"
parallelproj: "ON"
ROOT: "ON"
ROOT: "OFF"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

needed?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants