Skip to content

Commit 688187c

Browse files
authored
Merge branch 'master' into reinvert_SPECT_axis
2 parents a79b9fa + 4e9666a commit 688187c

25 files changed

+1150
-250
lines changed

.appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ test_script:
6868
- cd ..\src
6969
- "set PYTHONPATH=C:\\projects\\stir\\install\\python"
7070
- python -m pytest .
71+
- echo "Running Python examples"
72+
- cd ..\examples\python
73+
- rem Disabled as fails, probably because of plotting
74+
- rem python recon_demo_gradient.py
7175
- conda deactivate
7276

7377
on_finish:

.github/workflows/build-test.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,30 @@ jobs:
111111
compiler: gcc
112112
# compiler_version: 11
113113
cuda_version: "0"
114+
# openmp=OFF as ON needs special stuff for Apple gcc which KT doesn't feel like getting into...
114115
BUILD_FLAGS: "-DSTIR_OPENMP=OFF"
115116
parallelproj: "OFF"
116117
BUILD_TYPE: "Debug"
117118
ROOT: "OFF"
118119
ITK: "OFF"
119120
- os: macOS-latest
120121
compiler: clang
121-
compiler_version: 16
122+
compiler_version: 18
122123
cuda_version: "0"
123124
BUILD_FLAGS: "-DSTIR_OPENMP=OFF"
124125
parallelproj: "OFF"
125126
BUILD_TYPE: "Release"
126127
ROOT: "OFF"
127128
ITK: "OFF"
129+
- os: macOS-latest
130+
compiler: clang
131+
compiler_version: 21
132+
cuda_version: "0"
133+
BUILD_FLAGS: "-DSTIR_OPENMP=ON"
134+
parallelproj: "OFF"
135+
BUILD_TYPE: "Release"
136+
ROOT: "OFF"
137+
ITK: "OFF"
128138

129139
# let's run all of them, as opposed to aborting when one fails
130140
fail-fast: false
@@ -191,7 +201,8 @@ jobs:
191201
HOMEBREW_PREFIX=/usr/local
192202
fi
193203
LLVMDIR=$HOMEBREW_PREFIX/opt/llvm@${{ matrix.compiler_version }}
194-
LDFLAGS="-L${LLVMDIR}/lib/c++ -Wl,-rpath,${LLVMDIR}/lib/c++"
204+
# https://github.com/llvm/llvm-project/issues/94292#issuecomment-2149335628 says to remove this flag
205+
# LDFLAGS="-L${LLVMDIR}/lib/c++ -Wl,-rpath,${LLVMDIR}/lib/c++"
195206
export SDKROOT=$(xcrun --show-sdk-path)
196207
echo SDKROOT="$SDKROOT"
197208
# make available to jobs below
@@ -230,7 +241,7 @@ jobs:
230241
sudo apt install $CXX
231242
fi
232243
# other dependencies
233-
sudo apt install libboost-dev libhdf5-serial-dev swig python3-dev nlohmann-json3-dev
244+
sudo apt install libboost-dev libhdf5-serial-dev swig python3-dev nlohmann-json3-dev ninja-build
234245
if test "${{matrix.ITK}}XX" == "ONXX"; then
235246
sudo apt install libinsighttoolkit5-dev
236247
fi
@@ -239,7 +250,16 @@ jobs:
239250
PYTHON_EXECUTABLE=$(which python3)
240251
;;
241252
(macOS*)
242-
brew install boost swig python nlohmann-json
253+
if ! command -v ninja > /dev/null; then
254+
brew install ninja
255+
fi
256+
if ! command -v python3 > /dev/null; then
257+
brew install python
258+
fi
259+
if ! command -v swig > /dev/null; then
260+
brew install swig
261+
fi
262+
brew install boost nlohmann-json
243263
PYTHON_EXECUTABLE=$(which python3)
244264
;;
245265
(windows*)
@@ -350,7 +370,7 @@ jobs:
350370
echo "cmake flags $BUILD_FLAGS $EXTRA_BUILD_FLAGS"
351371
mkdir build
352372
cd build
353-
cmake -S .. ${BUILD_FLAGS} ${EXTRA_BUILD_FLAGS}
373+
cmake -G Ninja -S .. ${BUILD_FLAGS} ${EXTRA_BUILD_FLAGS}
354374
# report disk space
355375
case ${{matrix.os}} in
356376
(ubuntu* | macOS*)
@@ -375,7 +395,7 @@ jobs:
375395
run: |
376396
cd ${GITHUB_WORKSPACE}/build;
377397
source ${GITHUB_WORKSPACE}/my-env/bin/activate
378-
cmake --build . -j 2 --config ${BUILD_TYPE}} --target install
398+
cmake --build . --config ${BUILD_TYPE}} --target install
379399
380400
- name: ctest
381401
shell: bash
@@ -519,5 +539,7 @@ jobs:
519539
;;
520540
(*)
521541
python -m pytest .
542+
cd ../examples/python
543+
python recon_demo_gradient.py
522544
;;
523545
esac

documentation/release_6.3.htm

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ <h2> Summary for end users (also to be read by developers)</h2>
1919

2020

2121
<h3>New functionality</h3>
22+
<h4>General</h4>
2223
<ul>
2324
<li>
2425
The analytic Spline Reconstruction Technique (SRT) algorithm has been added in 2 different versions: for PET
@@ -51,9 +52,6 @@ <h3>New functionality</h3>
5152
However, projection data is currently still always returned as non-TOF (but list-mode data is read as TOF).<br>
5253
<a href=https://github.com/UCL/STIR/pull/1503>PR #1503</a>
5354
</li>
54-
<li>
55-
<tt>stir_timings</tt> has now an extra option to parse a par-file for a projector-pair.
56-
</li>
5755
<li>
5856
Added the ability to set a forward projector for mask projection in the <code>ScatterEstimation</code> class.<br>
5957
<a href=https://github.com/UCL/STIR/pull/1530>PR #1530</a>
@@ -64,18 +62,42 @@ <h3>New functionality</h3>
6462
<a href=https://github.com/UCL/STIR/pull/1519>PR #1519</a>
6563
</li>
6664
<li>
67-
<code>LmToProjData</code>/<tt>lm_to_projdata</tt> now no longer requires a template projection data. If none is
65+
<code>LmToProjData</code> class/<tt>lm_to_projdata</tt> utility now no longer requires a template projection data. If none is
6866
specified, it will use the proj_data_info from the input list-mode.<br>
6967
<b>Warning</b> for some scanners with TOF capabilities, this will result in very large projection data (possibly
7068
larger than the default from the vendor).<br>
7169
<a href=https://github.com/UCL/STIR/pull/1315>PR #1315</a>
7270
</li>
71+
</ul>
72+
<h4>Python</h4>
73+
<ul>
74+
<li>
75+
"Container" classes such as <code>FloatVoxelsOnCartesianGrid</code>, <code>ProjDataInMemory</code>
76+
and array-classes now have numerical operations properly defined, for instance
77+
<code>a = b + c</code> and <code>a -= 3</code>. Note that <code>a = 1 + b</code> is not
78+
yet available.<br>
79+
<a href=https://github.com/UCL/STIR/pull/1630>PR #1630</a>
80+
</li>
81+
<li>
82+
The above "container" classes now have an extra member `as_array()` which returns a numpy <code>ndarray</code>. This
83+
is equivalent to `stirextra.to_numpy()` which will become deprecated later. In addition, the
84+
<code>fill()</code> method now directly accepts an <code>ndarray</code>, avoiding the need to go via an iterator.
85+
These additions also make it easier to prt SIRF python code to STIR.<br>
86+
<a href=https://github.com/UCL/STIR/pull/1632>PR #1632</a>
87+
</li>
7388
<li>
74-
Added a Python script to convert e7tools generated Siemens Biograph Vision 600 sinograms to STIR compatible format.
89+
Added a Python script to convert e7tools generated Siemens Biograph Vision 600 sinograms to STIR compatible format.<br>
7590
<a href=https://github.com/UCL/STIR/pull/1593>PR #1593</a>
7691
</li>
7792
</ul>
7893

94+
<h4>Utilities</h4>
95+
<ul>
96+
<li>
97+
<tt>stir_timings</tt> has now an extra option to parse a par-file for a projector-pair.
98+
</li>
99+
</ul>
100+
79101
<h3>Changed functionality</h3>
80102
<ul>
81103
<li>
@@ -87,6 +109,14 @@ <h3>Changed functionality</h3>
87109
<li>
88110
Default ECAT scanner configurations updated to use a negative intrinsic tilt.
89111
</li>
112+
<li>
113+
When computing the sensitivity images in <code>PoissonLogLikelihoodWithLinearModelForMeanAndProjData</code>,
114+
we now avoid creating an extra <code>ProjDataInMemory</code> in most cases (there are still some corner
115+
cases for TOF data when using non-TOF projector for the sensitivity, but then the memory overhead is small).
116+
This enables LAFOV PET reconstructions with the "ray tracing" matrix (we use less memory, and we avoid running into a current
117+
<code>ProjDataInMemory</code> <a href=https://github.com/UCL/STIR/issues/1505> limitation on the number of bins</a>).<br>
118+
<a href=https://github.com/UCL/STIR/pull/1617>PR #1716</a>
119+
</li>
90120
<li>
91121
Boost format was replaced by `std::format` for formatting strings. If C++20 or newer is
92122
not yet used, a work-around is in place by using the [{fmt} library](https://github.com/fmtlib/fmt/)
@@ -154,6 +184,12 @@ <h3>New functionality</h3>
154184

155185
<h3>Changed functionality</h3>
156186
<ul>
187+
<li>
188+
In C++, "Container" classes such as <code>VoxelsOnCartesianGrid</code>, <code>ProjDataInMemory</code>
189+
and array-classes now have numerical operations that return objects of the correct type.
190+
(Previously, it was a base-class such as <code>NumericVectorWithOffset<Array<2, float>, float></code>).<br>
191+
<a href=https://github.com/UCL/STIR/pull/1630>PR #1630</a>
192+
</li>
157193
<li>
158194
Made 2 (deprecated) members of <code>ProjDataInfoBlocksOnCylindricalNoArcCorr</code> <code>private</code>
159195
and do some clean-up of which files to include.
@@ -181,12 +217,12 @@ <h3>Changed functionality</h3>
181217

182218
<h3>Bug fixes</h3>
183219
<ul>
184-
<li>Fixed minor incompatibility with gcc-14 and clang-18 buy adding an extra include file<br>
220+
<li>Fixed minor incompatibility with gcc-14 and clang-18 by adding an extra include file.<br>
185221
<a href=https://github.com/UCL/STIR/pull/1552>PR #1552</a>
186222
</li>
187223
</ul>
188224

189-
<h3>Deprecations</h3>
225+
<h3>New deprecations</h3>
190226
<ul>
191227
<li>
192228
<code>truncate_end_planes</code> will be removed in v7.0
@@ -197,7 +233,13 @@ <h3>Other code changes</h3>
197233

198234

199235
<h3>Test changes</h3>
200-
236+
<h4>Python tests</h4>
237+
<ul>
238+
<li>
239+
Tests for numerical operations for the "container" classes were added in the same PR as the code.<br>
240+
<a href=https://github.com/UCL/STIR/pull/1630>PR #1630</a>
241+
</li>
242+
</ul>
201243

202244
<h4>C++ tests</h4>
203245

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
# %%
22
import stir
33
import stirextra
4-
import matplotlib.pyplot as pylab
4+
import matplotlib.pyplot as plt
55
import os
66

77
# go to directory with input files
88
os.chdir('../recon_demo')
9-
10-
# define a function due to current limitation on Swig. " multiply_images(a,b)"
11-
def multiply_images(a, b):
12-
a.xapyb(a,b,a.get_empty_copy(),a)
13-
return a
14-
15-
169
# %%
1710
# initialise reconstruction object
1811
# we will do this here via a .par file
@@ -22,7 +15,7 @@ def multiply_images(a, b):
2215
num_subiterations = 4
2316
# set filenames to save subset sensitivities (for illustration purposes)
2417
poissonobj = recon.get_objective_function()
25-
poissonobj.set_subsensitivity_filenames('sens_subset%d.hv')
18+
poissonobj.set_subsensitivity_filenames('sens_subset{}.hv')
2619
poissonobj.set_recompute_sensitivity(True)
2720

2821

@@ -40,10 +33,6 @@ def multiply_images(a, b):
4033
s = recon.set_up(target)
4134

4235
# %%
43-
44-
# compute gradient of objective function
45-
# put some data in the image
46-
target.fill(1);
4736
# create a copy to store the gradient
4837
gradient=target.get_empty_copy();
4938
# compute gradient
@@ -52,22 +41,24 @@ def multiply_images(a, b):
5241

5342
# extract to python for plotting
5443
npimage = stirextra.to_numpy(gradient)
55-
pylab.plot(npimage[10, 30, :])
56-
pylab.show()
44+
plt.plot(npimage[10, 30, :])
45+
plt.show()
5746

5847
# this is useful to find the EM update (i.e. multiply with image)
5948
poissonobj.compute_sub_gradient_without_penalty_plus_sensitivity(gradient,target,subset_num)
6049
# extract to python for plotting
6150
npimage = stirextra.to_numpy(gradient)
62-
pylab.plot(npimage[10, 30, :])
63-
pylab.show()
6451

65-
# The followin is just the first iteration you need to create a for loop to run all the iterations and subsets
66-
EMupdate = multiply_images(target,gradient)
52+
plt.plot(npimage[10, 30, :])
53+
plt.show()
54+
55+
# The followin is just the first iteration you need to create a for
56+
# loop to run all the iterations and subsets
57+
EMupdate = target*gradient
6758
# extract to python for plotting
6859
npimage = stirextra.to_numpy(EMupdate)
69-
pylab.plot(npimage[10, 30, :])
70-
pylab.show()
60+
plt.plot(npimage[10, 30, :])
61+
plt.show()
7162

7263

7364

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ if(STIR_OPENMP)
137137
find_package(OpenMP REQUIRED)
138138
add_definitions(${OpenMP_CXX_FLAGS})
139139

140-
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
140+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT APPLE)
141141
# work around https://gitlab.kitware.com/cmake/cmake/-/issues/26037
142142
set (OpenMP_EXE_LINKER_FLAGS OpenMP::OpenMP_CXX -latomic)
143143
message(STATUS "OpenMP Linker flags for Clang: ${OpenMP_EXE_LINKER_FLAGS}")

src/buildblock/WienerArrayFilter2D.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
See STIR/LICENSE.txt for details
2020
*/
2121
#include "stir/WienerArrayFilter2D.h"
22-
22+
#include <vector>
2323
#include <algorithm>
2424

2525
using std::nth_element;

0 commit comments

Comments
 (0)