Skip to content

Commit b06adca

Browse files
committed
SPECTGPU:starting point; created SPECTGPU_projector folder and scheleton classe, atm a lot of copy from niftyGPU
1 parent 25b3656 commit b06adca

File tree

11 files changed

+1492
-0
lines changed

11 files changed

+1492
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//
2+
//
3+
/*!
4+
\file
5+
\ingroup projection
6+
\ingroup SPECTGPU
7+
8+
\brief Back projection class using SPECTGPU's GPU implementation.
9+
10+
\author Daniel Deidda
11+
12+
\todo SPECTGPU limitations -
13+
14+
\todo STIR wrapper limitations -
15+
*/
16+
/*
17+
Copyright (C) 2026, National Physical Laboratory
18+
This file is part of STIR.
19+
20+
SPDX-License-Identifier: Apache-2.0
21+
22+
See STIR/LICENSE.txt for details
23+
*/
24+
#ifndef __stir_gpu_BackProjectorByBinSPECTGPU_h__
25+
#define __stir_gpu_BackProjectorByBinSPECTGPU_h__
26+
27+
#include "stir/RegisteredParsingObject.h"
28+
#include "stir/recon_buildblock/BackProjectorByBin.h"
29+
#include "stir/recon_buildblock/SPECTGPU_projector/SPECTGPUHelper.h"
30+
31+
START_NAMESPACE_STIR
32+
33+
class DataSymmetriesForViewSegmentNumbers;
34+
35+
/*!
36+
\ingroup projection
37+
\brief Class for SPECTGPU's GPU back projector
38+
*/
39+
class BackProjectorByBinSPECTGPU : public RegisteredParsingObject<BackProjectorByBinSPECTGPU, BackProjectorByBin>
40+
{
41+
public:
42+
//! Name which will be used when parsing a BackProjectorByBin object
43+
static const char* const registered_name;
44+
45+
//! Default constructor calls reset_timers()
46+
BackProjectorByBinSPECTGPU();
47+
48+
virtual ~BackProjectorByBinSPECTGPU();
49+
50+
/// Keymap
51+
virtual void initialise_keymap();
52+
53+
//! Stores all necessary geometric info
54+
/*!
55+
If necessary, set_up() can be called more than once.
56+
*/
57+
virtual void set_up(const shared_ptr<const ProjDataInfo>& proj_data_info_ptr,
58+
const shared_ptr<const DiscretisedDensity<3, float>>& density_info_sptr // TODO should be Info only
59+
);
60+
61+
/// Back project
62+
void back_project(const ProjData&, int subset_num = 0, int num_subsets = 1);
63+
64+
/// Get output
65+
virtual void get_output(DiscretisedDensity<3, float>&) const;
66+
67+
/*! \brief tell the back projector to start accumulating into a new target.
68+
This function has to be called before any back-projection is initiated.*/
69+
virtual void start_accumulating_in_new_target();
70+
71+
/// Set verbosity
72+
void set_verbosity(const bool verbosity) { _cuda_verbosity = verbosity; }
73+
74+
/// Set use truncation - truncate before forward
75+
/// projection and after back projection
76+
void set_use_truncation(const bool use_truncation) { _use_truncation = use_truncation; }
77+
78+
protected:
79+
virtual void actual_back_project(const RelatedViewgrams<float>&,
80+
const int min_axial_pos_num,
81+
const int max_axial_pos_num,
82+
const int min_tangential_pos_num,
83+
const int max_tangential_pos_num);
84+
85+
private:
86+
shared_ptr<DataSymmetriesForViewSegmentNumbers> _symmetries_sptr;
87+
SPECTGPUHelper _helper;
88+
int _cuda_device;
89+
bool _cuda_verbosity;
90+
std::vector<float> _np_sino;
91+
bool _use_truncation;
92+
};
93+
94+
END_NAMESPACE_STIR
95+
96+
#endif // __stir_gpu_BackProjectorByBinSPECTGPU_h__
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
//
2+
//
3+
4+
#ifndef __stir_gpu_ForwardProjectorByBinSPECTGPU_h__
5+
#define __stir_gpu_ForwardProjectorByBinSPECTGPU_h__
6+
/*!
7+
\file
8+
\ingroup projection
9+
\ingroup SPECTGPU
10+
11+
\brief Forward projection class using SPECTGPU's GPU implementation.
12+
13+
\author Daniel Deidda
14+
15+
\todo SPECTGPU limitations -
16+
17+
\todo STIR wrapper limitations -
18+
19+
*/
20+
/*
21+
Copyright (C) 2026, National Physical Laboratory
22+
This file is part of STIR.
23+
24+
SPDX-License-Identifier: Apache-2.0
25+
26+
See STIR/LICENSE.txt for details
27+
*/
28+
29+
#include "stir/RegisteredParsingObject.h"
30+
#include "stir/recon_buildblock/ForwardProjectorByBin.h"
31+
#include "stir/recon_buildblock/SPECTGPU_projector/SPECTGPUHelper.h"
32+
33+
START_NAMESPACE_STIR
34+
35+
class ProjDataInMemory;
36+
class DataSymmetriesForViewSegmentNumbers;
37+
38+
/*!
39+
\ingroup projection
40+
\brief Class for SPECTGPU's GPU forward projector.
41+
*/
42+
class ForwardProjectorByBinSPECTGPU : public RegisteredParsingObject<ForwardProjectorByBinSPECTGPU, ForwardProjectorByBin>
43+
{
44+
public:
45+
//! Name which will be used when parsing a ForwardProjectorByBin object
46+
static const char* const registered_name;
47+
48+
//! Default constructor calls reset_timers()
49+
// inline
50+
ForwardProjectorByBinSPECTGPU();
51+
52+
/// Constructor
53+
virtual ~ForwardProjectorByBinSPECTGPU();
54+
55+
/// Keymap
56+
virtual void initialise_keymap();
57+
58+
//! Stores all necessary geometric info
59+
/*!
60+
If necessary, set_up() can be called more than once.
61+
62+
Derived classes can assume that forward_project() will be called
63+
with input corresponding to the arguments of the last call to set_up().
64+
65+
\warning there is currently no check on this.
66+
\warning Derived classes have to call set_up from the base class.
67+
*/
68+
virtual void set_up(const shared_ptr<const ProjDataInfo>& proj_data_info_ptr,
69+
const shared_ptr<const DiscretisedDensity<3, float>>& density_info_sptr // TODO should be Info only
70+
);
71+
72+
/// Set input
73+
virtual void set_input(const DiscretisedDensity<3, float>&);
74+
75+
/// Set verbosity
76+
void set_verbosity(const bool verbosity) { _cuda_verbosity = verbosity; }
77+
78+
/// Set use truncation - truncate before forward
79+
/// projection and after back projection
80+
void set_use_truncation(const bool use_truncation) { _use_truncation = use_truncation; }
81+
82+
protected:
83+
//! This virtual function has to be implemented by the derived class.
84+
virtual void actual_forward_project(RelatedViewgrams<float>&,
85+
const DiscretisedDensity<3, float>&,
86+
const int min_axial_pos_num,
87+
const int max_axial_pos_num,
88+
const int min_tangential_pos_num,
89+
const int max_tangential_pos_num);
90+
91+
virtual void actual_forward_project(RelatedViewgrams<float>& viewgrams,
92+
const int min_axial_pos_num,
93+
const int max_axial_pos_num,
94+
const int min_tangential_pos_num,
95+
const int max_tangential_pos_num);
96+
97+
private:
98+
shared_ptr<DataSymmetriesForViewSegmentNumbers> _symmetries_sptr;
99+
shared_ptr<ProjDataInMemory> _projected_data_sptr;
100+
SPECTGPUHelper _helper;
101+
int _cuda_device;
102+
bool _cuda_verbosity;
103+
bool _use_truncation;
104+
};
105+
106+
END_NAMESPACE_STIR
107+
108+
#endif // __stir_gpu_ForwardProjectorByBinSPECTGPU_h__
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
//
3+
/*
4+
Copyright (C) 2026, National Physical Laboratory
5+
This file is part of STIR.
6+
7+
SPDX-License-Identifier: Apache-2.0
8+
9+
See STIR/LICENSE.txt for details
10+
*/
11+
/*!
12+
\file
13+
\ingroup projection
14+
\ingroup SPECTGPU
15+
16+
\brief Declares class stir::ProjectorByBinPairUsingSPECTGPU
17+
18+
\author Daniel Deidda
19+
20+
*/
21+
#ifndef __stir_recon_buildblock_ProjectorByBinPairUsingSPECTGPU_h_
22+
#define __stir_recon_buildblock_ProjectorByBinPairUsingSPECTGPU_h_
23+
24+
#include "stir/RegisteredParsingObject.h"
25+
#include "stir/recon_buildblock/ProjectorByBinPair.h"
26+
27+
START_NAMESPACE_STIR
28+
29+
class Succeeded;
30+
/*!
31+
\ingroup projection
32+
\brief A projector pair based on SPECTGPU projectors
33+
*/
34+
class ProjectorByBinPairUsingSPECTGPU
35+
: public RegisteredParsingObject<ProjectorByBinPairUsingSPECTGPU, ProjectorByBinPair, ProjectorByBinPair>
36+
{
37+
private:
38+
typedef RegisteredParsingObject<ProjectorByBinPairUsingSPECTGPU, ProjectorByBinPair, ProjectorByBinPair> base_type;
39+
40+
public:
41+
//! Name which will be used when parsing a ProjectorByBinPair object
42+
static const char* const registered_name;
43+
44+
//! Default constructor
45+
ProjectorByBinPairUsingSPECTGPU();
46+
47+
/// Set verbosity
48+
void set_verbosity(const bool verbosity);
49+
50+
/// Set use truncation - truncate before forward
51+
/// projection and after back projection
52+
void set_use_truncation(const bool use_truncation);
53+
54+
private:
55+
void set_defaults();
56+
void initialise_keymap();
57+
bool post_processing();
58+
bool _verbosity;
59+
bool _use_truncation;
60+
};
61+
62+
END_NAMESPACE_STIR
63+
64+
#endif // __stir_recon_buildblock_ProjectorByBinPairUsingSPECTGPU_h_

0 commit comments

Comments
 (0)