Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b1a701e
Create CListModeDataBasedOnCoordinateMap from SAFIR
NikEfth Jul 14, 2025
12985cc
creating template classes for PETSIRD [WIP]
Jul 15, 2025
ff1038e
initial attempt for CListModeDataPETSIRD [WIP]
NikEfth Jul 16, 2025
b80d022
reading PETSIRD header [WIP]
danieldeidda Jul 16, 2025
4ce4ff2
Updates on the PETSIRD interface and CMake [WIP]
NikEfth Jul 16, 2025
f5b56f2
PETSIRD: extracting position of each detector [WIP]
danieldeidda Jul 17, 2025
211cc15
PETSIRD: orientations etc [WIP]
NikEfth Jul 17, 2025
030ffd5
PETSIRD: fixes for detector map [WIP]
danieldeidda Aug 12, 2025
e8fd6d4
PETSIRD: first working version
NikEfth Jun 26, 2026
6437d97
PETSIRD: safe checking on type of scanner geometry
KrisThielemans Jun 27, 2026
76b751c
* Documented that CListRecordPETSIRD has both detector position and t…
NikEfth Jul 2, 2026
1e2088e
add test on tof_mashing factor
KrisThielemans Jul 5, 2026
e742484
PETSIRD: hdf5 input files for norm
KrisThielemans Jul 5, 2026
8a04aa4
[GHA] simplification
KrisThielemans Jul 5, 2026
f3fcca6
Merge remote-tracking branch 'origin/master' into PETSIRD
KrisThielemans Jul 5, 2026
dec6303
[GHA] further simplification
KrisThielemans Jul 6, 2026
6209572
use build_environment.yml and use on GHA
KrisThielemans Jul 8, 2026
a64da93
[GHA] change job to force action to run
KrisThielemans Jul 9, 2026
c453883
[GHA] fix
KrisThielemans Jul 9, 2026
64e90c0
[GHA] add just
KrisThielemans Jul 9, 2026
b78e20f
add date to build_environment
KrisThielemans Jul 9, 2026
c3b8cdf
use mamba
KrisThielemans Jul 9, 2026
74e1f42
use micromamba
KrisThielemans Jul 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
230 changes: 178 additions & 52 deletions .github/workflows/build-test.yml

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ option(STIR_ENABLE_EXPERIMENTAL "disable use of STIR experimental code" OFF) # d
option(DISABLE_NiftyPET_PROJECTOR "disable use of NiftyPET projector" OFF)
option(DISABLE_Parallelproj_PROJECTOR "disable use of Parallelproj projector" OFF)
OPTION(DOWNLOAD_ZENODO_TEST_DATA "download zenodo data for tests" OFF)
option(DISABLE_PETSIRD "disable use of PETSIRD filetypes" OFF)
option(DISABLE_UPENN "disable use of UPENN filetypes" OFF)

find_package(Git QUIET)
Expand Down Expand Up @@ -278,6 +279,41 @@ else()
message(STATUS "Parallelproj projector support disabled or not available.")
endif()

if(NOT DISABLE_PETSIRD)
find_package(PETSIRD CONFIG)

if(PETSIRD_FOUND)
message(STATUS "PETSIRD support enabled (found PETSIRD).")
set(HAVE_PETSIRD ON)

# Inspect PETSIRD transitive dependencies
if(TARGET PETSIRD::petsird)
get_target_property(_petsird_libs PETSIRD::petsird INTERFACE_LINK_LIBRARIES)
Comment thread
KrisThielemans marked this conversation as resolved.

get_target_property(_petsird_features PETSIRD::petsird INTERFACE_COMPILE_FEATURES)
get_target_property(_petsird_libs PETSIRD::petsird INTERFACE_LINK_LIBRARIES)
message(STATUS "PETSIRD::petsird dependencies: ${_petsird_libs}")
message(STATUS "PETSIRD::petsird compile features: ${_petsird_features}")

# I have to give credit to AI for the following line.
# Probably this will not be needed, but I will keep it here for future reference.
# string(REGEX MATCH "cxx_std_([0-9]+)" _petsird_std_match "${_petsird_features}")
# if(CMAKE_MATCH_1)
# UseCXX(${CMAKE_MATCH_1})
# endif()

else()
message(FATAL_ERROR "PETSIRD::petsird target not found after find_package(PETSIRD)")
endif()

else()
message(STATUS "PETSIRD not found: PETSIRD support will be disabled.")
set(HAVE_PETSIRD OFF)
endif()
else()
set(HAVE_PETSIRD OFF)
endif()

#### enable support for ctest
ENABLE_TESTING()

Expand Down
4 changes: 3 additions & 1 deletion documentation/devel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ Please check files here for information/code practices for developers.
- Do read our [contribution guidelines](../../CONTRIBUTING.md)
- Set your editor settings appropriately: [instructions](editor-settings.md)
- Install git hooks for serious development: [instructions](git-hooks.md)
- Read the documentation, including the STIR developers guide
- Read the documentation, including the STIR developers guide

- To run the CI workflow locally with `act`: [instructions](local-CI.md)
37 changes: 37 additions & 0 deletions documentation/devel/local-CI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Running the GitHub Actions workflow locally with `act`

The GitHub Actions CI workflow can be tested locally using [`act`](https://github.com/nektos/act).
This is useful for debugging workflow changes before pushing to GitHub.

## Prerequisities

Install `act` and make sure Docker or Podman is available and running.

On Linux, the workflow can be run with an Ubuntu 24.04
container image compatible with GitHub Actions:

```bash
act -W .github/workflows/build-test.yml \
-P ubuntu-24.04=ghcr.io/catthehacker/ubuntu:act-24.04 \
--env ACT=true
```

* The ```-W``` option selects the workflow file to run
* The ```-P``` option maps the GitHub Actions
runner label ```ubuntu-24.04``` to a local container image.
The image in the command above is suggested online.
* The `--env ACT=true` option sets an environment variable
used by the workflow to detect that it is running under `act`.
Some GitHub steps are skipped.

## NOTES

* It is highly recommended to run only one job at the time.
STIR has an array of different OSes and options.
Don't try to spin them up all together in your local workstation.
* Runnning the workflow locally with ```act``` is not always identical to GitHub.
* If Docker runs out of disk space, remove old images and containers before running

```bash
docker system prune
```
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright 2025, 2026, University Medical Center Groningen
# Copyright 2011-01-01 - 2011-06-30 Hammersmith Imanet Ltd
# Copyright 2011-07-01 - 2012 Kris Thielemans
# Copyright 2016 ETH Zurich
Expand Down Expand Up @@ -278,6 +279,10 @@ else()
target_link_libraries(stir_registries PUBLIC CUDA::cudart)
endif()

if (HAVE_PETSIRD)
target_link_libraries(stir_registries PUBLIC PETSIRD::petsird)
endif()

# go and look for CMakeLists.txt files in all those directories
foreach(STIR_DIR ${STIR_DIRS} ${STIR_TEST_DIRS})
ADD_SUBDIRECTORY(${STIR_DIR})
Expand Down
10 changes: 10 additions & 0 deletions src/IO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ if (HAVE_HDF5)
)
endif()

if (HAVE_PETSIRD)
list(APPEND ${dir_LIB_SOURCES}
PETSIRDCListmodeInputFileFormat.cxx
)
endif()

endif() # MINI_STIR

target_sources(${STIR_BUILDBLOCK_LIB} PRIVATE ${${dir_LIB_SOURCES}})
Expand Down Expand Up @@ -137,3 +143,7 @@ if (HAVE_JSON)
get_target_property(TMP nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${TARGET} PRIVATE "${TMP}")
endif()

if(HAVE_PETSIRD)
target_link_libraries(${TARGET} PUBLIC PETSIRD::petsird)
endif()
9 changes: 9 additions & 0 deletions src/IO/IO_registries.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Copyright 2025, 2026, University Medical Center Groningen
Copyright (C) 2002-2011, Hammersmith Imanet Ltd
Copyright (C) 2012, Kris Thielemans
Copyright (C) 2013, Institute for Bioengineering of Catalonia
Expand Down Expand Up @@ -66,6 +67,10 @@
# include "stir/IO/InputStreamFromROOTFileForECATPET.h"
# endif

# ifdef HAVE_PETSIRD
# include "stir/IO/PETSIRDCListmodeInputFileFormat.h"
# endif

# ifdef HAVE_UPENN
# include "stir/IO/PENNListmodeInputFileFormat.h"
# include "stir/IO/InputStreamWithRecordsFromUPENNbin.h"
Expand Down Expand Up @@ -156,5 +161,9 @@ static InputStreamWithRecordsFromUPENNtxt::RegisterIt dummy686062;
// static RegisterInputFileFormat<PENNImageInputFileFormat> idummy1(2);
# endif

# ifdef HAVE_PETSIRD
static RegisterInputFileFormat<PETSIRDCListmodeInputFileFormat> LMdummyPETSIRD(10);
# endif

#endif // MINI_STIR
END_NAMESPACE_STIR
86 changes: 86 additions & 0 deletions src/IO/PETSIRDCListmodeInputFileFormat.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* PETSIRDCListmodeInputFileFormat.h
Comment thread
KrisThielemans marked this conversation as resolved.

Class defining input file format for coincidence listmode data for PETSIRD.

Copyright 2025, 2026, University Medical Center Groningen
Copyright 2025 National Physical Laboratory

SPDX-License-Identifier: Apache-2.0
See STIR/LICENSE.txt for details
*/
#include "stir/IO/PETSIRDCListmodeInputFileFormat.h"
#include "petsird/binary/protocols.h"
#include "petsird/hdf5/protocols.h"
#include "stir/error.h"
#include "stir/format.h"
#include <array>
// #include "../../PETSIRD/cpp/generated/types.h"
// #include "../../PETSIRD/cpp/helpers/include/petsird_helpers.h"

START_NAMESPACE_STIR

/*!

\file
\ingroup listmode
\brief Implementation of class stir::PETSIRDCListmodeInputFileFormat

\author Nikos Efthimiou
\author Daniel Deidda

*/

bool
PETSIRDCListmodeInputFileFormat::can_read(const FileSignature& signature, const std::string& filename) const
{

std::array<char, 4> hdf5_signature = { 'H', 'D', 'F', '5' };
Comment thread
KrisThielemans marked this conversation as resolved.
std::array<char, 4> binary_signature = { 'y', 'a', 'r', 'd' };

std::ifstream file(filename, std::ios::binary);
if (!file.is_open())
{
error(format("Cannot open file: {}", filename));
return false;
}
std::array<char, 4> signature_{};
auto it = std::istreambuf_iterator<char>(file);
auto end = std::istreambuf_iterator<char>();

for (size_t i = 0; i < signature_.size() && it != end; ++i, ++it)
{
signature_[i] = *it;
}

if (!file)
error("Stream error while reading file signature");

if (signature_ == hdf5_signature)
{
use_hdf5 = true;
return use_hdf5;
}

if (signature_ == binary_signature)
{
use_hdf5 = false;
return true;
}

// petsird::hdf5::PETSIRDReader* petsird_reader = new petsird::hdf5::PETSIRDReader(filename);

// if (is_null_ptr(petsird_reader))
// {

// petsird::binary::PETSIRDReader* petsird_reader = new petsird::binary::PETSIRDReader(filename);
// if (is_null_ptr(petsird_reader))
// {
// return false;
// }
// return true;
// }

return false;
}

END_NAMESPACE_STIR
11 changes: 10 additions & 1 deletion src/buildblock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ if (NOT MINI_STIR)
list(APPEND ${dir_LIB_SOURCES}
ProjDataGEHDF5.cxx
)
endif()
endif()
if (HAVE_PETSIRD)
list(APPEND ${dir_LIB_SOURCES}
PETSIRDInfo.cxx
)
endif()

endif() # MINI_STIR

Expand Down Expand Up @@ -154,3 +159,7 @@ endif()
if (STIR_OPENMP)
target_link_libraries(${TARGET} PUBLIC ${OpenMP_EXE_LINKER_FLAGS})
endif()

if(HAVE_PETSIRD)
target_link_libraries(${TARGET} PUBLIC PETSIRD::petsird)
endif()
Loading
Loading