Skip to content

Commit e30cf18

Browse files
allow using full FOV for Parallelproj projector
introduce restrict_to_cylindrical_FOV variable/keyword (defaulting to true), identical to what is used in the ray-tracing matrix This variable is a rename of the _use_truncation variable (which was essentially disabled), but now made to work.
1 parent 0307f8d commit e30cf18

6 files changed

+89
-20
lines changed

src/include/stir/recon_buildblock/Parallelproj_projector/BackProjectorByBinParallelproj.h

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class BackProjectorByBinParallelproj :
8585
void set_num_gpu_chunks(int num_gpu_chunks) {_num_gpu_chunks = num_gpu_chunks; }
8686
int get_num_gpu_chunks() { return _num_gpu_chunks; }
8787

88+
bool get_restrict_to_cylindrical_FOV() const;
89+
void set_restrict_to_cylindrical_FOV(bool val);
90+
8891
protected:
8992

9093
virtual void actual_back_project(const RelatedViewgrams<float>&,
@@ -100,6 +103,7 @@ class BackProjectorByBinParallelproj :
100103
void set_helper(shared_ptr<detail::ParallelprojHelper>);
101104
bool _cuda_verbosity;
102105
int _num_gpu_chunks;
106+
bool _restrict_to_cylindrical_FOV;
103107
};
104108

105109
END_NAMESPACE_STIR

src/include/stir/recon_buildblock/Parallelproj_projector/ForwardProjectorByBinParallelproj.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ virtual void set_up(
8080
/// Set verbosity
8181
void set_verbosity(const bool verbosity) { _cuda_verbosity = verbosity; }
8282

83-
/// Set use truncation - truncate before forward
84-
/// projection and after back projection
85-
void set_use_truncation(const bool use_truncation) { _use_truncation = use_truncation; }
86-
8783
// set/get number of gpu chunks to use
8884
void set_num_gpu_chunks(int num_gpu_chunks) {_num_gpu_chunks = num_gpu_chunks; }
8985
int get_num_gpu_chunks() { return _num_gpu_chunks; }
9086

87+
bool get_restrict_to_cylindrical_FOV() const;
88+
void set_restrict_to_cylindrical_FOV(bool val);
89+
9190
protected:
9291

9392
virtual void actual_forward_project(RelatedViewgrams<float>& viewgrams,
@@ -102,7 +101,7 @@ virtual void set_up(
102101
friend class ProjectorByBinPairUsingParallelproj;
103102
void set_helper(shared_ptr<detail::ParallelprojHelper>);
104103
bool _cuda_verbosity;
105-
bool _use_truncation;
104+
bool _restrict_to_cylindrical_FOV;
106105
int _num_gpu_chunks;
107106
};
108107

src/include/stir/recon_buildblock/Parallelproj_projector/ProjectorByBinPairUsingParallelproj.h

+5
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,18 @@ class ProjectorByBinPairUsingParallelproj :
5757
/// Set verbosity
5858
void set_verbosity(const bool verbosity);
5959

60+
bool get_restrict_to_cylindrical_FOV() const;
61+
void set_restrict_to_cylindrical_FOV(bool val);
62+
6063
private:
6164
shared_ptr<detail::ParallelprojHelper> _helper;
6265

6366
void set_defaults() override;
6467
void initialise_keymap() override;
6568
bool post_processing() override;
6669
bool _verbosity;
70+
bool _restrict_to_cylindrical_FOV;
71+
bool _already_set_up;
6772
};
6873

6974
END_NAMESPACE_STIR

src/recon_buildblock/Parallelproj_projector/BackProjectorByBinParallelproj.cxx

+20-4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ initialise_keymap()
6767
parser.add_start_key("Back Projector Using Parallelproj Parameters");
6868
parser.add_stop_key("End Back Projector Using Parallelproj Parameters");
6969
parser.add_key("verbosity", &_cuda_verbosity);
70+
parser.add_key("restrict to cylindrical FOV", &_restrict_to_cylindrical_FOV);
7071
parser.add_key("num_gpu_chunks", &_num_gpu_chunks);
7172
}
7273

@@ -76,8 +77,22 @@ set_defaults()
7677
{
7778
_cuda_verbosity = true;
7879
_num_gpu_chunks = 1;
80+
_restrict_to_cylindrical_FOV = true;
7981
}
8082

83+
bool
84+
BackProjectorByBinParallelproj::
85+
get_restrict_to_cylindrical_FOV() const
86+
{
87+
return this->_restrict_to_cylindrical_FOV;
88+
}
89+
90+
void
91+
BackProjectorByBinParallelproj::
92+
set_restrict_to_cylindrical_FOV(bool val)
93+
{
94+
this->_restrict_to_cylindrical_FOV = val;
95+
}
8196

8297
void
8398
BackProjectorByBinParallelproj::set_helper(shared_ptr<detail::ParallelprojHelper> helper)
@@ -91,6 +106,10 @@ BackProjectorByBinParallelproj::
91106
set_up(const shared_ptr<const ProjDataInfo>& proj_data_info_sptr,
92107
const shared_ptr<const DiscretisedDensity<3,float> >& density_info_sptr)
93108
{
109+
#ifdef STIR_TOF
110+
if (proj_data_info_sptr->get_num_tof_poss() > 1)
111+
error("STIR-ParallelProj interface does not support TOF data yet. Sorry!");
112+
#endif
94113
BackProjectorByBin::set_up(proj_data_info_sptr,density_info_sptr);
95114
check(*proj_data_info_sptr, *_density_sptr);
96115
_symmetries_sptr.reset(new TrivialDataSymmetriesForBins(proj_data_info_sptr));
@@ -201,10 +220,7 @@ get_output(DiscretisedDensity<3,float> &density) const
201220
// --------------------------------------------------------------- //
202221
std::copy(image_vec.begin(), image_vec.end(), density.begin_all());
203222

204-
// After the back projection, we enforce a truncation outside of the FOV.
205-
// This is because the parallelproj projector seems to have some trouble at the edges and this
206-
// could cause some voxel values to spiral out of control.
207-
//if (_use_truncation)
223+
if (this->_restrict_to_cylindrical_FOV)
208224
{
209225
const float radius = p.get_proj_data_info_sptr()->get_scanner_sptr()->get_inner_ring_radius();
210226
const float image_radius = _helper->voxsize[2]*_helper->imgdim[2]/2;

src/recon_buildblock/Parallelproj_projector/ForwardProjectorByBinParallelproj.cxx

+22-6
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ForwardProjectorByBinParallelproj::registered_name =
4242
"Parallelproj";
4343

4444
ForwardProjectorByBinParallelproj::ForwardProjectorByBinParallelproj() :
45-
_cuda_verbosity(true), _use_truncation(true), _num_gpu_chunks(1)
45+
_cuda_verbosity(true), _restrict_to_cylindrical_FOV(true), _num_gpu_chunks(1)
4646
{
4747
this->_already_set_up = false;
4848
this->_do_not_setup_helper = false;
@@ -59,6 +59,7 @@ initialise_keymap()
5959
parser.add_start_key("Forward Projector Using Parallelproj Parameters");
6060
parser.add_stop_key("End Forward Projector Using Parallelproj Parameters");
6161
parser.add_key("verbosity", &_cuda_verbosity);
62+
parser.add_key("restrict to cylindrical FOV", &_restrict_to_cylindrical_FOV);
6263
parser.add_key("num_gpu_chunks", &_num_gpu_chunks);
6364
}
6465

@@ -67,10 +68,24 @@ ForwardProjectorByBinParallelproj::
6768
set_defaults()
6869
{
6970
_cuda_verbosity = true;
70-
_use_truncation = true;
71+
_restrict_to_cylindrical_FOV = true;
7172
_num_gpu_chunks = 1;
7273
}
7374

75+
bool
76+
ForwardProjectorByBinParallelproj::
77+
get_restrict_to_cylindrical_FOV() const
78+
{
79+
return this->_restrict_to_cylindrical_FOV;
80+
}
81+
82+
void
83+
ForwardProjectorByBinParallelproj::
84+
set_restrict_to_cylindrical_FOV(bool val)
85+
{
86+
this->_restrict_to_cylindrical_FOV = val;
87+
}
88+
7489

7590
void
7691
ForwardProjectorByBinParallelproj::set_helper(shared_ptr<detail::ParallelprojHelper> helper)
@@ -84,6 +99,10 @@ ForwardProjectorByBinParallelproj::
8499
set_up(const shared_ptr<const ProjDataInfo>& proj_data_info_sptr,
85100
const shared_ptr<const DiscretisedDensity<3,float> >& density_info_sptr)
86101
{
102+
#ifdef STIR_TOF
103+
if (proj_data_info_sptr->get_num_tof_poss() > 1)
104+
error("STIR-ParallelProj interface does not support TOF data yet. Sorry!");
105+
#endif
87106
ForwardProjectorByBin::set_up(proj_data_info_sptr,density_info_sptr);
88107
check(*proj_data_info_sptr, *_density_sptr);
89108
_symmetries_sptr.reset(new TrivialDataSymmetriesForBins(proj_data_info_sptr));
@@ -135,10 +154,7 @@ set_input(const DiscretisedDensity<3,float> & density)
135154
{
136155
ForwardProjectorByBin::set_input(density);
137156

138-
// Before forward projection, we enforce a truncation outside of the FOV.
139-
// This is because the parallelproj projector seems to have some trouble at the edges and this
140-
// could cause some voxel values to spiral out of control.
141-
//if (_use_truncation)
157+
if (this->_restrict_to_cylindrical_FOV)
142158
{
143159
const float radius = this->_proj_data_info_sptr->get_scanner_sptr()->get_inner_ring_radius();
144160
const float image_radius = _helper->voxsize[2]*_helper->imgdim[2]/2;

src/recon_buildblock/Parallelproj_projector/ProjectorByBinPairUsingParallelproj.cxx

+34-5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ProjectorByBinPairUsingParallelproj::initialise_keymap()
3939
parser.add_start_key("Projector Pair Using Parallelproj Parameters");
4040
parser.add_stop_key("End Projector Pair Using Parallelproj Parameters");
4141
parser.add_key("verbosity",&_verbosity);
42+
parser.add_key("restrict to cylindrical FOV", &_restrict_to_cylindrical_FOV);
4243
}
4344

4445

@@ -47,6 +48,8 @@ ProjectorByBinPairUsingParallelproj::set_defaults()
4748
{
4849
base_type::set_defaults();
4950
this->set_verbosity(true);
51+
this->set_restrict_to_cylindrical_FOV(true);
52+
this->_already_set_up = false;
5053
}
5154

5255
bool
@@ -67,22 +70,48 @@ ProjectorByBinPairUsingParallelproj()
6770
set_defaults();
6871
}
6972

73+
bool
74+
ProjectorByBinPairUsingParallelproj::
75+
get_restrict_to_cylindrical_FOV() const
76+
{
77+
return this->_restrict_to_cylindrical_FOV;
78+
}
79+
80+
void
81+
ProjectorByBinPairUsingParallelproj::
82+
set_restrict_to_cylindrical_FOV(bool val)
83+
{
84+
this->_already_set_up = this->_already_set_up && (this->_restrict_to_cylindrical_FOV == val);
85+
this->_restrict_to_cylindrical_FOV = val;
86+
}
87+
7088
Succeeded
7189
ProjectorByBinPairUsingParallelproj::
7290
set_up(const shared_ptr<const ProjDataInfo>& proj_data_info_sptr,
7391
const shared_ptr<const DiscretisedDensity<3,float> >& image_info_sptr)
7492
{
75-
_helper = std::make_shared<detail::ParallelprojHelper>(*proj_data_info_sptr, *image_info_sptr);
76-
dynamic_pointer_cast<ForwardProjectorByBinParallelproj>(this->forward_projector_sptr)
77-
->set_helper(_helper);
78-
dynamic_pointer_cast<BackProjectorByBinParallelproj>(this->back_projector_sptr)
79-
->set_helper(_helper);
93+
auto fwd_prj_downcast_sptr =
94+
dynamic_pointer_cast<ForwardProjectorByBinParallelproj>(this->forward_projector_sptr);
95+
if (!fwd_prj_downcast_sptr)
96+
error("internal error: forward projector should be ParallelProj");
97+
98+
auto bck_prj_downcast_sptr =
99+
dynamic_pointer_cast<BackProjectorByBinParallelproj>(this->back_projector_sptr);
100+
if (!bck_prj_downcast_sptr)
101+
error("internal error: back projector should be ParallelProj");
102+
103+
bck_prj_downcast_sptr->set_restrict_to_cylindrical_FOV(this->_restrict_to_cylindrical_FOV);
104+
fwd_prj_downcast_sptr->set_restrict_to_cylindrical_FOV(this->_restrict_to_cylindrical_FOV);
105+
this->_helper = std::make_shared<detail::ParallelprojHelper>(*proj_data_info_sptr, *image_info_sptr);
106+
fwd_prj_downcast_sptr->set_helper(this->_helper);
107+
bck_prj_downcast_sptr->set_helper(this->_helper);
80108

81109
// the forward_projector->set_up etc will be called in the base class
82110

83111
if (base_type::set_up(proj_data_info_sptr, image_info_sptr) != Succeeded::yes)
84112
return Succeeded::no;
85113

114+
this->_already_set_up = true;
86115
return Succeeded::yes;
87116
}
88117

0 commit comments

Comments
 (0)