Skip to content

Commit 75a9342

Browse files
Merge pull request #1316 from KrisThielemans/DetectionPositionFixes
DetectionPosition fixes
2 parents 21eb434 + 1d26b90 commit 75a9342

File tree

5 files changed

+47
-16
lines changed

5 files changed

+47
-16
lines changed

documentation/release_6.0.htm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ <h4>Python (and MATLAB)</h4>
118118
derived classes.
119119
</li>
120120
</ul>
121+
</li>
122+
<li>
123+
add <code>DetectionPositionPair.__repr__</code> for printing and
124+
change order of text in <code>DetectionPosition.__repr__</code> to
125+
fit with constructor to avoid confusion.<br>
126+
<a href="https://github.com/UCL/STIR/pull/1316">PR #1316</a>
127+
</li>
121128
</ul>
122129

123130

src/include/stir/stream.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Copyright (C) 2000 PARAPET partners
1515
Copyright (C) 2000-2009 Hammersmith Imanet Ltd
1616
Copyright (C) 2013 Kris Thielemans
17-
Copyright (C) 2023 University College London
17+
Copyright (C) 2023, 2024 University College London
1818
1919
This file is part of STIR.
2020
@@ -29,6 +29,7 @@
2929
#include "stir/BasicCoordinate.h"
3030
#include "stir/Bin.h"
3131
#include "stir/DetectionPosition.h"
32+
#include "stir/DetectionPositionPair.h"
3233
#include <iostream>
3334
#include <vector>
3435

@@ -86,6 +87,7 @@ operator<<(std::ostream& str, const std::vector<elemT>& v);
8687

8788
/*!
8889
\brief Outputs a Bin to a stream.
90+
\ingroup projdata
8991
9092
Output is of the form
9193
\verbatim
@@ -103,17 +105,34 @@ inline std::ostream& operator<<(std::ostream& out, const Bin& bin)
103105

104106
/*!
105107
\brief Outputs a DetectionPosition to a stream.
108+
\ingroup projdata
106109
107110
Output is of the form
108111
\verbatim
109-
[radial=.., axial=..., tangential=...]
112+
[tangential=..., axial=..., radial=...]
110113
\endverbatim
111114
*/
112115
template <class T>
113116
inline std::ostream& operator<<(std::ostream& out, const DetectionPosition<T>& det_pos)
114117
{
115-
return out << "[radial=" << det_pos.radial_coord() << ", axial=" << det_pos.axial_coord()
116-
<< ", tangential=" << det_pos.tangential_coord() << "]";
118+
return out << "[tangential=" << det_pos.tangential_coord() << ", axial=" << det_pos.axial_coord()
119+
<< ", radial=" << det_pos.radial_coord() << "]";
120+
}
121+
122+
/*!
123+
\brief Outputs a DetectionPosition to a stream.
124+
\ingroup projdata
125+
126+
Output is of the form
127+
\verbatim
128+
[pos1=..., pos2=..., timing_pos=...]
129+
\endverbatim
130+
*/
131+
template <class T>
132+
inline std::ostream& operator<<(std::ostream& out, const DetectionPositionPair<T>& det_pos)
133+
{
134+
return out << "[pos1=" << det_pos.pos1() << ", pos2=" << det_pos.pos2()
135+
<< ", timing_pos=" << det_pos.timing_pos() << "]";
117136
}
118137

119138
/*!

src/recon_buildblock/BinNormalisationFromECAT8.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,8 @@ get_uncalibrated_bin_efficiency(const Bin& bin) const {
570570
uncompressed_bin, detection_position_pair);
571571

572572

573-
const DetectionPosition<>& pos1 = detection_position_pair.pos1();
574-
const DetectionPosition<>& pos2 = detection_position_pair.pos2();
573+
//const DetectionPosition<>& pos1 = detection_position_pair.pos1();
574+
//const DetectionPosition<>& pos2 = detection_position_pair.pos2();
575575
float lor_efficiency= 0.;
576576

577577
/*

src/swig/stir_projdata.i

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,18 @@
4141
%attributeref(stir::DetectionPosition<unsigned int>, unsigned int, axial_coord);
4242
%attributeref(stir::DetectionPosition<unsigned int>, unsigned int, radial_coord);
4343
%include "stir/DetectionPosition.h"
44-
#ifdef STIR_TOF
4544
ADD_REPR(stir::DetectionPosition, %arg(*$self))
46-
#endif
4745
%template(DetectionPosition) stir::DetectionPosition<unsigned int>;
4846

47+
%attributeref(stir::DetectionPositionPair<unsigned int>, int, timing_pos);
4948
%attributeref(stir::DetectionPositionPair<unsigned int>, stir::DetectionPosition<unsigned int>, pos1);
5049
%attributeref(stir::DetectionPositionPair<unsigned int>, stir::DetectionPosition<unsigned int>, pos2);
5150
%include "stir/DetectionPositionPair.h"
52-
#ifdef STIR_TOF
53-
//ADD_REPR(stir::DetectionPositionPair, %arg(*$self))
54-
#endif
51+
ADD_REPR(stir::DetectionPositionPair, %arg(*$self))
5552
%template(DetectionPositionPair) stir::DetectionPositionPair<unsigned int>;
5653

5754
%attributeref(stir::SegmentIndices, int, segment_num);
58-
#ifdef STIR_TOF
5955
%attributeref(stir::SegmentIndices, int, timing_pos_num);
60-
#endif
6156
%attributeref(stir::ViewgramIndices, int, view_num);
6257
%attributeref(stir::SinogramIndices, int, axial_pos_num);
6358
%attributeref(stir::Bin, int, axial_pos_num);
@@ -69,9 +64,8 @@ ADD_REPR(stir::DetectionPosition, %arg(*$self))
6964
%include "stir/ViewgramIndices.h"
7065
%include "stir/SinogramIndices.h"
7166
%include "stir/Bin.h"
72-
#ifdef STIR_TOF
7367
ADD_REPR(stir::Bin, %arg(*$self))
74-
#endif
68+
7569

7670
%newobject stir::Scanner::get_scanner_from_name;
7771
%include "stir/Scanner.h"

src/swig/test/python/test_buildblock.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,18 @@ def test_zoom_image():
185185
assert abs(zoomed_image[ind]-1)<.001
186186
zoomed_image=zoom_image(image, zoom, offset, offset, new_size, ZoomOptions(ZoomOptions.preserve_projections))
187187
assert abs(zoomed_image[ind]-1./(zoom))<.001
188-
188+
189+
def test_DetectionPositionPair():
190+
d1=DetectionPosition(1,2,0)
191+
d2=DetectionPosition(4,5,6)
192+
dp=DetectionPositionPair(d1,d2,3)
193+
assert d1==dp.pos1
194+
assert d2==dp.pos2
195+
assert dp.timing_pos == 3
196+
dp.pos1.tangential_coord = 7
197+
assert dp.pos1.tangential_coord == 7
198+
assert d1.tangential_coord == 1
199+
189200
def test_Scanner():
190201
scanner=Scanner.get_scanner_from_name("ECAT 962")
191202
assert scanner.get_num_rings()==32

0 commit comments

Comments
 (0)