Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove presmoothingforward & postsmoothingback projectors #607

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

#include "stir/recon_buildblock/ProjectorByBinPairUsingSeparateProjectors.h"
#include "stir_experimental/motion/Transform3DObjectImageProcessor.h"
#include "stir/recon_buildblock/PresmoothingForwardProjectorByBin.h"
#include "stir/recon_buildblock/PostsmoothingBackProjectorByBin.h"

#include "stir/DiscretisedDensity.h"
// for set_projectors_and_symmetries
Expand Down Expand Up @@ -414,12 +412,9 @@ set_up_before_sensitivity(shared_ptr<TargetT > const& target_sptr)
warning("transformation type has to be Transform3DObjectImageProcessor");
return Succeeded::no;
}
shared_ptr<ForwardProjectorByBin> forward_projector_sptr_this_gate
(
new PresmoothingForwardProjectorByBin(this->projector_pair_ptr->
get_forward_projector_sptr(),
this->_forward_transformations[gate_num])
);
shared_ptr<ForwardProjectorByBin> forward_projector_sptr_this_gate =
this->projector_pair_ptr->get_forward_projector_sptr()->create_shared_clone();
forward_projector_sptr_this_gate->set_pre_data_processor(this->_forward_transformations[gate_num]);

shared_ptr<DataProcessor<TargetT> > transpose_transformer_sptr
(
Expand All @@ -431,11 +426,11 @@ set_up_before_sensitivity(shared_ptr<TargetT > const& target_sptr)
dynamic_cast<Transform3DObjectImageProcessor<float> &>(*transpose_transformer_sptr);
transpose_transformer.
set_do_transpose(!forward_transformer_ptr->get_do_transpose());
shared_ptr<BackProjectorByBin> back_projector_sptr_this_gate
(new PostsmoothingBackProjectorByBin(this->projector_pair_ptr->
get_back_projector_sptr(),
transpose_transformer_sptr)
);

shared_ptr<BackProjectorByBin> back_projector_sptr_this_gate =
this->projector_pair_ptr->get_back_projector_sptr()->create_shared_clone();
back_projector_sptr_this_gate->set_post_data_processor(transpose_transformer_sptr);

projector_pair_sptr_this_gate.
reset(new ProjectorByBinPairUsingSeparateProjectors
(forward_projector_sptr_this_gate,
Expand Down
12 changes: 12 additions & 0 deletions src/include/stir/recon_buildblock/BackProjectorByBin.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class BackProjectorByBin :
//! Default constructor calls reset_timers()
BackProjectorByBin();

/// Copy constructor
BackProjectorByBin(const BackProjectorByBin& to_copy);

virtual ~BackProjectorByBin();

//! Stores all necessary geometric info
Expand Down Expand Up @@ -144,8 +147,17 @@ void back_project(const RelatedViewgrams<float>&,
/// Set data processor to use after back projection
void set_post_data_processor(shared_ptr<DataProcessor<DiscretisedDensity<3,float> > > post_data_processor_sptr);

/// Create shared clone
std::unique_ptr<BackProjectorByBin> create_shared_clone() const
{
return std::unique_ptr<BackProjectorByBin>(this->create_shared_clone_impl());
}

protected:

/// Helper method for create_shared_clone. Don't use.
virtual BackProjectorByBin* create_shared_clone_impl() const = 0;

/*! \brief This actually does the back projection.
There are two versions of this code to enable backwards compatibility.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ class BackProjectorByBinUsingInterpolation :
*/
void use_piecewise_linear_interpolation(const bool use_piecewise_linear_interpolation);

/// Create shared clone
std::unique_ptr<BackProjectorByBinUsingInterpolation> create_shared_clone() const
{
return std::unique_ptr<BackProjectorByBinUsingInterpolation>(this->create_shared_clone_impl());
}

protected:

/// Helper method for create_shared_clone. Don't use.
virtual BackProjectorByBinUsingInterpolation* create_shared_clone_impl() const
{
error("To do");
return new BackProjectorByBinUsingInterpolation;
}

private:

// KT 20/06/2001 changed type to enable use of more methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class BackProjectorByBinUsingProjMatrixByBin:
BackProjectorByBinUsingProjMatrixByBin (
const shared_ptr<ProjMatrixByBin>& proj_matrix_ptr);

/// Copy constructor. Shallow copy of proj matrix
BackProjectorByBinUsingProjMatrixByBin(const BackProjectorByBinUsingProjMatrixByBin& to_copy)
: RegisteredParsingObject<BackProjectorByBinUsingProjMatrixByBin, BackProjectorByBin>(to_copy),
proj_matrix_ptr(to_copy.proj_matrix_ptr) { }

//! Stores all necessary geometric info
/*! Note that the density_info_ptr is not stored in this object. It's only used to get some info on sizes etc.
*/
Expand All @@ -87,9 +92,20 @@ class BackProjectorByBinUsingProjMatrixByBin:
shared_ptr<ProjMatrixByBin> &
get_proj_matrix_sptr(){ return proj_matrix_ptr ;}

/// Create shared clone. Warning, only shallow copy of ProjMatrixByBin.
std::unique_ptr<BackProjectorByBinUsingProjMatrixByBin> create_shared_clone() const
{
return std::unique_ptr<BackProjectorByBinUsingProjMatrixByBin>(this->create_shared_clone_impl());
}

protected:

/// Helper method for create_shared_clone. Don't use.
virtual BackProjectorByBinUsingProjMatrixByBin* create_shared_clone_impl() const
{
return new BackProjectorByBinUsingProjMatrixByBin(*this);
}

shared_ptr<ProjMatrixByBin> proj_matrix_ptr;

private:
Expand Down
13 changes: 13 additions & 0 deletions src/include/stir/recon_buildblock/ForwardProjectorByBin.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class ForwardProjectorByBin :
//inline
ForwardProjectorByBin();

/// Copy constructor
ForwardProjectorByBin(const ForwardProjectorByBin& to_copy);

//! Stores all necessary geometric info
/*!
If necessary, set_up() can be called more than once.
Expand Down Expand Up @@ -133,7 +136,17 @@ virtual void set_up(
/// Set data processor to use before forward projection. MUST BE CALLED BEFORE SET_INPUT.
void set_pre_data_processor(shared_ptr<DataProcessor<DiscretisedDensity<3,float> > > pre_data_processor_sptr);

/// Create shared clone
std::unique_ptr<ForwardProjectorByBin> create_shared_clone() const
{
return std::unique_ptr<ForwardProjectorByBin>(this->create_shared_clone_impl());
}

protected:

/// Helper method for create_shared_clone. Don't use.
virtual ForwardProjectorByBin* create_shared_clone_impl() const = 0;

//! This virtual function has to be implemented by the derived class.
virtual void actual_forward_project(RelatedViewgrams<float>&,
const DiscretisedDensity<3,float>&,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class ForwardProjectorByBinUsingProjMatrixByBin:
const shared_ptr<ProjMatrixByBin>& proj_matrix_ptr
);

/// Copy constructor. Shallow copy of proj matrix
ForwardProjectorByBinUsingProjMatrixByBin(const ForwardProjectorByBinUsingProjMatrixByBin& to_copy)
: RegisteredParsingObject<ForwardProjectorByBinUsingProjMatrixByBin, ForwardProjectorByBin>(to_copy),
proj_matrix_ptr(to_copy.proj_matrix_ptr) { }

//! Stores all necessary geometric info
/*! Note that the density_info_ptr is not stored in this object. It's only used to get some info on sizes etc.
*/
Expand All @@ -79,8 +84,20 @@ class ForwardProjectorByBinUsingProjMatrixByBin:

const DataSymmetriesForViewSegmentNumbers * get_symmetries_used() const;

/// Create shared clone. Warning, only shallow copy of ProjMatrixByBin.
std::unique_ptr<ForwardProjectorByBinUsingProjMatrixByBin> create_shared_clone() const
{
return std::unique_ptr<ForwardProjectorByBinUsingProjMatrixByBin>(this->create_shared_clone_impl());
}

private:

/// Helper method for create_shared_clone. Don't use.
virtual ForwardProjectorByBinUsingProjMatrixByBin* create_shared_clone_impl() const
{
return new ForwardProjectorByBinUsingProjMatrixByBin(*this);
}

shared_ptr<ProjMatrixByBin> proj_matrix_ptr;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,20 @@ class ForwardProjectorByBinUsingRayTracing :

virtual const DataSymmetriesForViewSegmentNumbers * get_symmetries_used() const;

/// Create shared clone
std::unique_ptr<ForwardProjectorByBinUsingRayTracing> create_shared_clone() const
{
return std::unique_ptr<ForwardProjectorByBinUsingRayTracing>(this->create_shared_clone_impl());
}

protected:
/// Helper method for create_shared_clone. Don't use.
virtual ForwardProjectorByBinUsingRayTracing* create_shared_clone_impl() const
{
error("to do");
return new ForwardProjectorByBinUsingRayTracing;
}

//! variable that determines if a cylindrical FOV or the whole image will be handled
bool restrict_to_cylindrical_FOV;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ class BackProjectorByBinNiftyPET :
//! Default constructor calls reset_timers()
BackProjectorByBinNiftyPET();

/// Copy constructor
BackProjectorByBinNiftyPET(const BackProjectorByBinNiftyPET& to_copy)
: RegisteredParsingObject<BackProjectorByBinNiftyPET, BackProjectorByBin>(to_copy),
_symmetries_sptr(nullptr), _helper(to_copy._helper), _cuda_device(to_copy._cuda_device),
_cuda_verbosity(to_copy._cuda_verbosity), _use_truncation(to_copy._use_truncation)
{
}

virtual ~BackProjectorByBinNiftyPET();

/// Keymap
Expand Down Expand Up @@ -102,8 +110,20 @@ class BackProjectorByBinNiftyPET :
/// projection and after back projection
void set_use_truncation(const bool use_truncation) { _use_truncation = use_truncation; }

/// Create shared clone
std::unique_ptr<BackProjectorByBinNiftyPET> create_shared_clone() const
{
return std::unique_ptr<BackProjectorByBinNiftyPET>(this->create_shared_clone_impl());
}

protected:

/// Helper method for create_shared_clone. Don't use.
virtual BackProjectorByBinNiftyPET* create_shared_clone_impl() const
{
return new BackProjectorByBinNiftyPET(*this);
}

virtual void actual_back_project(const RelatedViewgrams<float>&,
const int min_axial_pos_num, const int max_axial_pos_num,
const int min_tangential_pos_num, const int max_tangential_pos_num);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class ForwardProjectorByBinNiftyPET:
//inline
ForwardProjectorByBinNiftyPET();

/// Copy constructor
ForwardProjectorByBinNiftyPET(const ForwardProjectorByBinNiftyPET& to_copy)
: RegisteredParsingObject<ForwardProjectorByBinNiftyPET, ForwardProjectorByBin>(to_copy),
_symmetries_sptr(nullptr), _projected_data_sptr(nullptr), _helper(to_copy._helper),
_cuda_device(to_copy._cuda_device), _cuda_verbosity(to_copy._cuda_verbosity),
_use_truncation(to_copy._use_truncation)
{
}

/// Constructor
virtual ~ForwardProjectorByBinNiftyPET();

Expand Down Expand Up @@ -104,7 +113,20 @@ virtual void set_up(
/// projection and after back projection
void set_use_truncation(const bool use_truncation) { _use_truncation = use_truncation; }

/// Create shared clone
std::unique_ptr<ForwardProjectorByBinNiftyPET> create_shared_clone() const
{
return std::unique_ptr<ForwardProjectorByBinNiftyPET>(this->create_shared_clone_impl());
}

protected:

/// Helper method for create_shared_clone. Don't use.
virtual ForwardProjectorByBinNiftyPET* create_shared_clone_impl() const
{
return new ForwardProjectorByBinNiftyPET(*this);
}

//! This virtual function has to be implemented by the derived class.
virtual void actual_forward_project(RelatedViewgrams<float>&,
const DiscretisedDensity<3,float>&,
Expand Down
112 changes: 0 additions & 112 deletions src/include/stir/recon_buildblock/PostsmoothingBackProjectorByBin.h

This file was deleted.

Loading