22 #ifndef EXTRA_STIR_TYPES
23 #define EXTRA_STIR_TYPES
25 #define WIN32_LEAN_AND_MEAN
40 #include "sirf/common/JacobiCG.h"
42 #include "stir/recon_buildblock/PoissonLogLikelihoodWithLinearModelForMeanAndProjData.h"
43 #include "stir/recon_buildblock/PoissonLogLikelihoodWithLinearModelForMeanAndListModeDataWithProjMatrixByBin.h"
45 #define MIN_BIN_EFFICIENCY 1.0e-20f
47 #define SIRF_DYNAMIC_CAST(T, X, Y) T& X = dynamic_cast<T&>(Y)
100 norm_.reset(
new stir::ChainedBinNormalisation(mod1.data(), mod2.data()));
103 void set_up(
const stir::shared_ptr<const stir::ExamInfo>& exam_info_sptr,
104 const stir::shared_ptr<stir::ProjDataInfo>&);
108 set_up(ad.get_exam_info_sptr(), ad.get_proj_data_info_sptr()->create_shared_clone());
118 std::shared_ptr<STIRAcquisitionData> sptr_ad = ad.new_acquisition_data();
120 this->unnormalise(*sptr_ad);
126 std::shared_ptr<STIRAcquisitionData> sptr_ad = ad.new_acquisition_data();
128 this->normalise(*sptr_ad);
132 stir::shared_ptr<stir::BinNormalisation> data()
139 stir::shared_ptr<stir::BinNormalisation> norm_;
209 void set_subset(
int sub_num)
213 void set_num_subsets(
int num_sub)
217 virtual std::shared_ptr<STIRImageData> apply(
const STIRImageData& image_data)
219 std::shared_ptr<STIRAcquisitionData> sptr_fwd =
220 sptr_am_->forward(image_data, sub_num_, num_sub_);
221 std::shared_ptr<STIRImageData> sptr_bwd =
222 sptr_am_->backward(*sptr_fwd, sub_num_, num_sub_);
226 std::shared_ptr<const PETAcquisitionModel> sptr_am_;
239 float norm(
int subset_num = 0,
int num_subsets = 1,
int num_iter = 2,
int verb = 0)
const
242 bf.set_subset(subset_num);
243 bf.set_num_subsets(num_subsets);
245 jcg.set_num_iterations(num_iter);
247 image_data.fill(1.0);
248 float lmd = jcg.largest(bf, image_data, verb);
249 return std::sqrt(lmd);
252 void set_projectors(stir::shared_ptr<stir::ProjectorByBinPair> sptr_projectors)
254 sptr_projectors_ = sptr_projectors;
256 const stir::shared_ptr<stir::ProjectorByBinPair> projectors_sptr()
const
258 return sptr_projectors_;
260 void set_additive_term(std::shared_ptr<STIRAcquisitionData> sptr)
264 std::shared_ptr<const STIRAcquisitionData> additive_term_sptr()
const
268 void set_background_term(std::shared_ptr<STIRAcquisitionData> sptr)
270 sptr_background_ = sptr;
272 std::shared_ptr<const STIRAcquisitionData> background_term_sptr()
const
274 return sptr_background_;
276 std::shared_ptr<const STIRAcquisitionData> acq_template_sptr()
const
278 return sptr_acq_template_;
280 std::shared_ptr<const STIRImageData> image_template_sptr()
const
282 return sptr_image_template_;
288 const stir::shared_ptr<stir::BinNormalisation> normalisation_sptr()
const
291 return sptr_asm_->data();
292 stir::shared_ptr<stir::BinNormalisation> sptr;
301 void set_asm(std::shared_ptr<PETAcquisitionSensitivityModel> sptr_asm)
304 sptr_asm_ = sptr_asm;
306 stir::shared_ptr<PETAcquisitionSensitivityModel> asm_sptr()
const
315 void cancel_background_term()
317 sptr_background_.reset();
319 void cancel_additive_term()
323 void cancel_normalisation()
328 std::shared_ptr<const PETAcquisitionModel> linear_acq_mod_sptr()
const
330 std::shared_ptr<PETAcquisitionModel> sptr_am(
new PETAcquisitionModel);
331 sptr_am->set_projectors(sptr_projectors_);
332 sptr_am->set_asm(sptr_asm_);
333 sptr_am->sptr_acq_template_ = sptr_acq_template_;
334 sptr_am->sptr_image_template_ = sptr_image_template_;
339 std::shared_ptr<STIRAcquisitionData> sptr_acq,
340 std::shared_ptr<STIRImageData> sptr_image);
345 std::shared_ptr<STIRAcquisitionData>
346 forward(
const STIRImageData& image,
347 int subset_num = 0,
int num_subsets = 1,
bool do_linear_only =
false)
const;
358 void forward(STIRAcquisitionData& acq_data,
const STIRImageData& image,
359 int subset_num,
int num_subsets,
bool zero =
false,
bool do_linear_only =
false)
const;
362 std::shared_ptr<STIRImageData> backward(
const STIRAcquisitionData& ad,
363 int subset_num = 0,
int num_subsets = 1)
const;
365 void backward(STIRImageData& image,
const STIRAcquisitionData& ad,
366 int subset_num = 0,
int num_subsets = 1)
const;
369 stir::shared_ptr<stir::ProjectorByBinPair> sptr_projectors_;
370 std::shared_ptr<STIRAcquisitionData> sptr_acq_template_;
371 std::shared_ptr<STIRImageData> sptr_image_template_;
372 std::shared_ptr<STIRAcquisitionData> sptr_add_;
373 std::shared_ptr<STIRAcquisitionData> sptr_background_;
374 std::shared_ptr<PETAcquisitionSensitivityModel> sptr_asm_;
396 this->sptr_projectors_.reset(
new ProjectorPairUsingMatrix);
398 void set_matrix(stir::shared_ptr<stir::ProjMatrixByBin> sptr_matrix)
400 sptr_matrix_ = sptr_matrix;
401 ((ProjectorPairUsingMatrix*)this->sptr_projectors_.get())->
402 set_proj_matrix_sptr(sptr_matrix);
404 stir::shared_ptr<stir::ProjMatrixByBin> matrix_sptr()
411 std::shared_ptr<STIRAcquisitionData> sptr_acq,
412 std::shared_ptr<STIRImageData> sptr_image)
414 if (!sptr_matrix_.get())
415 THROW(
"PETAcquisitionModelUsingMatrix setup failed - matrix not set");
416 PETAcquisitionModel::set_up(sptr_acq, sptr_image);
422 sptr_matrix_->enable_cache(v);
426 stir::shared_ptr<stir::ProjMatrixByBin> sptr_matrix_;
435 stir::shared_ptr<RayTracingMatrix> matrix_sptr(
new RayTracingMatrix);
436 matrix_sptr->set_num_tangential_LORs(num_LORs);
437 set_matrix(matrix_sptr);
439 void set_num_tangential_LORs(
int num_LORs)
442 auto matrix =
dynamic_cast<RayTracingMatrix&
>(*matrix_sptr());
444 matrix.set_num_tangential_LORs(num_LORs);
450 auto matrix =
dynamic_cast<const RayTracingMatrix&
>(*matrix_sptr());
451 return matrix.get_num_tangential_LORs();
456 auto matrix =
dynamic_cast<RayTracingMatrix&
>(*matrix_sptr());
457 matrix.set_restrict_to_cylindrical_FOV(v);
462 void set_do_symmetry_90degrees_min_phi(
bool v =
true)
464 auto matrix =
dynamic_cast<RayTracingMatrix&
>(*matrix_sptr());
465 matrix.set_do_symmetry_90degrees_min_phi(v);
468 void set_do_symmetry_180degrees_min_phi(
bool v =
true)
470 auto matrix =
dynamic_cast<RayTracingMatrix&
>(*matrix_sptr());
471 matrix.set_do_symmetry_180degrees_min_phi(v);
474 void set_do_symmetry_swap_segment(
bool v =
true)
476 auto matrix =
dynamic_cast<RayTracingMatrix&
>(*matrix_sptr());
477 matrix.set_do_symmetry_swap_segment(v);
480 void set_do_symmetry_swap_s(
bool v =
true)
482 auto matrix =
dynamic_cast<RayTracingMatrix&
>(*matrix_sptr());
483 matrix.set_do_symmetry_swap_s(v);
486 void set_do_symmetry_shift_z(
bool v =
true)
488 auto matrix =
dynamic_cast<RayTracingMatrix&
>(*matrix_sptr());
489 matrix.set_do_symmetry_shift_z(v);
493 typedef PETAcquisitionModel AcqMod3DF;
494 typedef PETAcquisitionModelUsingMatrix AcqModUsingMatrix3DF;
495 typedef std::shared_ptr<AcqMod3DF> sptrAcqMod3DF;
497 #ifdef STIR_WITH_NiftyPET_PROJECTOR
503 class PETAcquisitionModelUsingNiftyPET :
public PETAcquisitionModel {
505 PETAcquisitionModelUsingNiftyPET()
507 _NiftyPET_projector_pair_sptr.reset(
new ProjectorPairUsingNiftyPET);
508 this->sptr_projectors_ = _NiftyPET_projector_pair_sptr;
510 _NiftyPET_projector_pair_sptr->set_verbosity(0);
512 void set_cuda_verbosity(
const bool verbosity)
const
514 _NiftyPET_projector_pair_sptr->set_verbosity(verbosity);
516 void set_use_truncation(
const bool use_truncation)
const
518 _NiftyPET_projector_pair_sptr->set_use_truncation(use_truncation);
521 stir::shared_ptr<stir::ProjectorPairUsingNiftyPET> _NiftyPET_projector_pair_sptr;
523 typedef PETAcquisitionModelUsingNiftyPET AcqModUsingNiftyPET3DF;
526 #ifdef STIR_WITH_Parallelproj_PROJECTOR
532 class PETAcquisitionModelUsingParallelproj :
public PETAcquisitionModel {
534 PETAcquisitionModelUsingParallelproj()
536 this->sptr_projectors_.reset(
new ProjectorByBinPairUsingParallelproj);
539 typedef PETAcquisitionModelUsingParallelproj AcqModUsingParallelproj;
563 std::shared_ptr<STIRAcquisitionData>& af_sptr,
564 std::shared_ptr<STIRAcquisitionData>& acf_sptr)
566 af_sptr = acq_templ.clone();
568 acf_sptr = af_sptr->clone();
570 acf_sptr->inv(0, *af_sptr);
574 stir::shared_ptr<stir::ForwardProjectorByBin> sptr_forw_projector_;
596 store_prompts =
true;
597 store_delayeds =
false;
598 delayed_increment = 0;
600 display_interval = 1;
605 void set_input(
const STIRListmodeData& lm_data_v)
607 input_filename =
"UNKNOWN";
609 this->set_input_data(lm_data_v.data());
610 exam_info_sptr_.reset(
new ExamInfo(lm_data_ptr->get_exam_info()));
611 proj_data_info_sptr_.reset(lm_data_ptr->get_proj_data_info_sptr()->clone());
613 void set_input(std::string lm_file)
615 this->set_input(STIRListmodeData(lm_file));
616 this->input_filename = lm_file;
623 output_filename_prefix = proj_data_file;
625 void set_template(std::string proj_data_file)
628 set_template(acq_data_template);
630 void set_template(
const STIRAcquisitionData& acq_data_template)
632 template_proj_data_info_ptr =
633 acq_data_template.get_proj_data_info_sptr()->create_shared_clone();
635 void set_time_interval(
double start,
double stop)
637 std::pair<double, double> interval(start, stop);
638 std::vector < std::pair<double, double> > intervals;
639 intervals.push_back(interval);
640 frame_defs = stir::TimeFrameDefinitions(intervals);
641 do_time_frame =
true;
643 int set_flag(
const char* flag,
bool value)
646 store_prompts = value;
648 store_delayeds = value;
651 do_pre_normalisation = value;
653 do_time_frame = value;
661 bool get_store_prompts()
const
663 return store_prompts;
665 bool get_store_delayeds()
const
667 return store_delayeds;
669 virtual stir::Succeeded set_up()
671 if (LmToProjData::set_up() == Succeeded::no)
672 THROW(
"LmToProjData setup failed");
674 #if STIR_VERSION < 060000
675 const auto max_fan_size =
676 lm_data_ptr->get_scanner_ptr()->get_max_num_non_arccorrected_bins();
678 const auto max_fan_size =
679 lm_data_ptr->get_scanner().get_max_num_non_arccorrected_bins();
682 fan_size = max_fan_size;
685 std::min(fan_size, max_fan_size);
686 half_fan_size = fan_size / 2;
687 fan_size = 2 * half_fan_size + 1;
689 exam_info_sptr_->set_time_frame_definitions(frame_defs);
690 const float h = proj_data_info_sptr_->get_bed_position_horizontal();
691 const float v = proj_data_info_sptr_->get_bed_position_vertical();
692 stir::shared_ptr<ProjDataInfo> temp_proj_data_info_sptr(template_proj_data_info_ptr->clone());
693 temp_proj_data_info_sptr->set_bed_position_horizontal(h);
694 temp_proj_data_info_sptr->set_bed_position_vertical(v);
695 randoms_sptr.reset(
new STIRAcquisitionDataInMemory(exam_info_sptr_, temp_proj_data_info_sptr));
697 return stir::Succeeded::yes;
699 int estimate_randoms();
702 std::string filename =
"randoms_f1g1d0b0.hs";
703 randoms_sptr->write(filename.c_str());
705 std::shared_ptr<STIRAcquisitionData> get_output()
707 std::string filename = output_filename_prefix +
"_f1g1d0b0.hs";
708 return std::shared_ptr<STIRAcquisitionData>
709 (
new STIRAcquisitionDataInFile(filename.c_str()));
711 std::shared_ptr<STIRAcquisitionData> get_randoms_sptr()
723 int max_ring_diff_for_fansums;
725 int display_interval;
728 stir::shared_ptr<ExamInfo> exam_info_sptr_;
729 stir::shared_ptr<ProjDataInfo> proj_data_info_sptr_;
730 stir::shared_ptr<std::vector<stir::Array<2, float> > > fan_sums_sptr;
731 stir::shared_ptr<stir::DetectorEfficiencies> det_eff_sptr;
732 std::shared_ptr<STIRAcquisitionData> randoms_sptr;
733 void compute_fan_sums_(
bool prompt_fansum =
false);
734 int compute_singles_();
736 static unsigned long compute_num_bins_(
const int num_rings,
737 const int num_detectors_per_ring,
738 const int max_ring_diff,
const int half_fan_size);
761 stir::SingleScatterSimulation(filename)
764 void set_up(std::shared_ptr<const STIRAcquisitionData> sptr_acq_template,
765 std::shared_ptr<const STIRImageData> sptr_act_image_template)
767 this->sptr_acq_template_ = sptr_acq_template;
769 stir::SingleScatterSimulation::set_template_proj_data_info(
770 *sptr_acq_template_->get_proj_data_info_sptr());
771 stir::SingleScatterSimulation::set_exam_info(
772 *sptr_acq_template_->get_exam_info_sptr());
776 auto& tmp = stir::SingleScatterSimulation::get_attenuation_image();
780 THROW(
"Fatal error in PETSingleScatterSimulator::set_up: attenuation_image has not been set");
782 this->set_activity_image_sptr(sptr_act_image_template);
784 if (stir::SingleScatterSimulation::set_up() == Succeeded::no)
785 THROW(
"Fatal error in PETSingleScatterSimulator::set_up() failed.");
788 void set_activity_image_sptr(std::shared_ptr<const STIRImageData> arg)
790 #if STIR_VERSION < 050000
792 stir::shared_ptr<Image3DF> sptr_image_copy(arg->data_sptr()->clone());
793 stir::SingleScatterSimulation::set_activity_image_sptr(sptr_image_copy);
795 stir::SingleScatterSimulation::set_activity_image_sptr(arg->data_sptr());
799 void set_attenuation_image_sptr(std::shared_ptr<const STIRImageData> arg)
801 #if STIR_VERSION < 050000
803 stir::shared_ptr<Image3DF> sptr_image_copy(arg->data_sptr()->clone());
804 stir::SingleScatterSimulation::set_density_image_sptr(sptr_image_copy);
806 stir::SingleScatterSimulation::set_density_image_sptr(arg->data_sptr());
810 std::shared_ptr<STIRAcquisitionData> forward(
const STIRImageData& activity_img)
812 if (!sptr_acq_template_.get())
813 THROW(
"Fatal error in PETSingleScatterSimulator::forward: acquisition template not set");
814 std::shared_ptr<STIRAcquisitionData> sptr_ad =
815 sptr_acq_template_->new_acquisition_data();
816 this->forward( *sptr_ad, activity_img);
820 void forward(STIRAcquisitionData& ad,
const STIRImageData& activity_img)
822 stir::shared_ptr<ProjData> sptr_fd = ad.data();
823 this->set_output_proj_data_sptr(sptr_fd);
825 this->process_data();
829 std::shared_ptr<const STIRAcquisitionData> sptr_acq_template_;
847 using recon_type = stir::OSMAPOSLReconstruction<DiscretisedDensity<3,float>>;
857 auto obj_sptr = std::make_shared<PoissonLogLikelihoodWithLinearModelForMeanAndProjData<DiscretisedDensity<3,float>>>();
858 auto recon_sptr = std::make_shared<recon_type>();
859 recon_sptr->set_num_subiterations(8);
860 recon_sptr->set_num_subsets(7);
861 recon_sptr->set_disable_output(
true);
862 recon_sptr->set_objective_function_sptr(obj_sptr);
863 stir::shared_ptr<stir::SeparableGaussianImageFilter<float> >
864 filter_sptr(
new stir::SeparableGaussianImageFilter<float>);
865 filter_sptr->set_fwhms(stir::make_coordinate(15.F,15.F,15.F));
866 recon_sptr->set_post_processor_sptr(filter_sptr);
867 stir::ScatterEstimation::set_reconstruction_method_sptr(recon_sptr);
871 stir::ScatterEstimation(filename)
877 stir::ScatterEstimation::set_input_proj_data_sptr(arg->data());
882 stir::ScatterEstimation::set_attenuation_correction_proj_data_sptr(arg->data());
885 void set_asm(std::shared_ptr<PETAcquisitionSensitivityModel> arg)
887 stir::ScatterEstimation::set_normalisation_sptr(arg->data());
892 stir::ScatterEstimation::set_background_proj_data_sptr(arg->data());
895 void set_attenuation_image_sptr(std::shared_ptr<const STIRImageData> arg)
897 #if STIR_VERSION < 050000
899 stir::shared_ptr<Image3DF> sptr_image_copy(arg->data_sptr()->clone());
900 stir::ScatterEstimation::set_attenuation_image_sptr(sptr_image_copy);
902 stir::ScatterEstimation::set_attenuation_image_sptr(arg->data_sptr());
915 stir::ScatterEstimation::set_export_scatter_estimates_of_each_iteration(!prefix.empty());
916 stir::ScatterEstimation::set_output_scatter_estimate_prefix(prefix);
919 void set_num_iterations(
int arg)
921 stir::ScatterEstimation::set_num_iterations(arg);
924 int get_num_iterations()
const
926 return stir::ScatterEstimation::get_num_iterations();
929 void set_OSEM_num_subiterations(
int arg)
931 this->get_reconstruction_method().set_num_subiterations(arg);
934 int get_OSEM_num_subiterations()
const
936 return this->get_reconstruction_method().get_num_subiterations();
939 void set_OSEM_num_subsets(
int arg)
941 this->get_reconstruction_method().set_num_subsets(arg);
942 this->_already_set_up_sirf =
false;
945 int get_OSEM_num_subsets()
const
947 return this->get_reconstruction_method().get_num_subsets();
953 stir::ScatterEstimation::set_max_scale_value(v);
959 stir::ScatterEstimation::set_min_scale_value(v);
962 std::shared_ptr<STIRAcquisitionData> get_scatter_estimate(
int est_num = -1)
const
965 est_num = num_scatter_iterations;
966 if (est_num == num_scatter_iterations)
969 if (output_scatter_estimate_prefix.empty())
970 THROW(
"output_scatter_estimate_prefix not set, so scatter estimates were not saved to file.");
971 const std::string filename = output_scatter_estimate_prefix +
"_" + std::to_string(est_num) +
".hs";
972 return std::make_shared<STIRAcquisitionDataInFile>(filename.c_str());
978 auto stir_proj_data_sptr = stir::ScatterEstimation::get_output();
979 if (!stir_proj_data_sptr)
980 THROW(
"output not yet computed");
981 std::shared_ptr<STIRAcquisitionData> sptr_acq_data
982 (STIRAcquisitionData::storage_template()->same_acquisition_data(stir_proj_data_sptr->get_exam_info_sptr(),
983 stir_proj_data_sptr->get_proj_data_info_sptr()->create_shared_clone()));
984 sptr_acq_data->data()->fill(*stir_proj_data_sptr);
985 return sptr_acq_data;
998 const float zoom = 0.2F;
999 stir::shared_ptr<Voxels3DF>
1000 image_sptr(
new Voxels3DF(MAKE_SHARED<stir::ExamInfo>(*this->get_input_data()->get_exam_info_sptr()),
1001 *this->get_input_data()->get_proj_data_info_sptr(),
1003 image_sptr->fill(1.F);
1004 stir::ScatterEstimation::set_initial_activity_image_sptr(image_sptr);
1005 if (stir::ScatterEstimation::set_up() == Succeeded::no)
1006 THROW(
"scatter estimation set_up failed");
1007 this->_already_set_up_sirf =
true;
1008 return Succeeded::yes;
1012 if (!this->_already_set_up_sirf)
1013 THROW(
"scatter estimation needs to be set-up first");
1014 if (!stir::ScatterEstimation::already_setup())
1015 THROW(
"scatter estimation needs to be set-up first");
1016 if (stir::ScatterEstimation::process_data() == Succeeded::no)
1017 THROW(
"scatter estimation failed");
1021 bool _already_set_up_sirf;
1024 recon_type& get_reconstruction_method()
const
1026 return dynamic_cast<recon_type&
>(*this->reconstruction_template_sptr);
1041 void set_length_x(
float v)
1045 void set_length_y(
float v)
1049 void set_length_z(
float v)
1053 float get_length_x()
const
1057 float get_length_y()
const
1061 float get_length_z()
const
1069 void multiply_with_Hessian(Image3DF& output,
const Image3DF& curr_image_est,
1070 const Image3DF& input)
const
1073 accumulate_Hessian_times_input(output, curr_image_est, input);
1082 void only2D(
int only) {
1083 only_2D = only != 0;
1089 void only2D(
int only) {
1090 only_2D = only != 0;
1096 void only2D(
int only) {
1097 only_2D = only != 0;
1103 void only2D(
int only) {
1104 only_2D = only != 0;
1109 public stir::GeneralisedObjectiveFunction < Image3DF > {
1111 void multiply_with_Hessian(Image3DF& output,
const Image3DF& curr_image_est,
1112 const Image3DF& input,
const int subset)
const
1116 accumulate_sub_Hessian_times_input(output, curr_image_est, input, subset);
1118 for (
int s = 0; s < get_num_subsets(); s++) {
1119 accumulate_sub_Hessian_times_input(output, curr_image_est, input, s);
1132 public stir::PoissonLogLikelihoodWithLinearModelForMeanAndProjData < Image3DF > {
1134 void set_input_file(
const char* filename) {
1135 input_filename = filename;
1137 void set_acquisition_data(std::shared_ptr<STIRAcquisitionData> sptr)
1140 set_proj_data_sptr(sptr->data());
1142 void set_acquisition_model(std::shared_ptr<AcqMod3DF> sptr_am);
1144 std::shared_ptr<AcqMod3DF> acquisition_model_sptr()
1149 std::shared_ptr<STIRAcquisitionData> sptr_ad_;
1150 std::shared_ptr<AcqMod3DF> sptr_am_;
1157 public stir::PoissonLogLikelihoodWithLinearModelForMeanAndListModeDataWithProjMatrixByBin<Image3DF> {
1161 void set_acquisition_data(std::shared_ptr<PETAcquisitionData> sptr)
1164 set_proj_data_info(*sptr->data());
1167 void set_acquisition_model(std::shared_ptr<AcqMod3DF> sptr_am);
1169 void set_cache_path(
const std::string filepath)
1171 stir::PoissonLogLikelihoodWithLinearModelForMeanAndListModeDataWithProjMatrixByBin<Image3DF>::
1172 set_cache_path(filepath);
1175 void set_time_interval(
double start,
double stop)
1177 std::pair<double, double> interval(start, stop);
1178 std::vector < std::pair<double, double> > intervals;
1179 intervals.push_back(interval);
1180 frame_defs = stir::TimeFrameDefinitions(intervals);
1181 do_time_frame =
true;
1186 std::shared_ptr<PETAcquisitionModelUsingMatrix> sptr_am_;
1192 public stir::IterativeReconstruction < Image3DF > {
1200 void update(Image3DF &image) {
1201 update_estimate(image);
1202 end_of_iteration_processing(image);
1209 void update(stir::shared_ptr<STIRImageData> sptr_id)
1213 int& subiteration() {
1214 return subiteration_num;
1216 int subiteration()
const {
1217 return subiteration_num;
1219 void set_initial_estimate_file(
const char* filename) {
1220 initial_data_filename = filename;
1226 int& subiteration() {
1227 return subiteration_num;
1229 int subiteration()
const {
1230 return subiteration_num;
1236 void compute_kernelised_image_x(
1237 Image3DF& kernelised_image_out,
1238 const Image3DF& image_to_kernelise,
1239 const Image3DF& current_alpha_estimate)
1241 compute_kernelised_image(
1242 kernelised_image_out,
1244 current_alpha_estimate);
1250 float& relaxation_parameter_value() {
1251 return relaxation_parameter;
1253 float& relaxation_gamma_value() {
1254 return relaxation_gamma;
1256 double& upper_bound_value() {
1269 set_input_data(acq.data());
1271 void set_zoom(
float v)
1276 void set_alpha_ramp(
double alpha)
1280 if (!(alpha > 0 && alpha <= 1.0))
1282 (
"wrong ramp filter parameter alpha", __FILE__, __LINE__);
1285 void set_frequency_cut_off(
double fc)
1287 if (!(fc > 0 && fc <= 0.5))
1289 (
"wrong frequency cut-off", __FILE__, __LINE__);
1292 void set_up(std::shared_ptr<STIRImageData> sptr_id)
1295 stir::Succeeded s = stir::Reconstruction<Image3DF>::set_up(_sptr_image_data->data_sptr());
1296 if (s != stir::Succeeded::yes)
1297 THROW(
"stir::Reconstruction setup failed");
1306 stir::Succeeded s = stir::Succeeded::no;
1308 stir::shared_ptr<Image3DF> sptr_image(construct_target_image_ptr());
1310 stir::Reconstruction<Image3DF>::set_up(sptr_image);
1311 s = reconstruct(sptr_image);
1314 s = reconstruct(_sptr_image_data->data_sptr());
1315 if (s != stir::Succeeded::yes)
1316 THROW(
"stir::AnalyticReconstruction::reconstruct failed");
1318 std::shared_ptr<STIRImageData> get_output()
1320 return _sptr_image_data;
1324 std::shared_ptr<STIRImageData> _sptr_image_data;
1328 public stir::SeparableGaussianImageFilter<float> {
1338 void set_fwhms_xyz(
char xyz,
float f)
1340 stir::BasicCoordinate<3, float> v = get_fwhms();
1353 void set_max_kernel_sizes_xyz(
char xyz,
int s)
1355 stir::BasicCoordinate<3, int> v = get_max_kernel_sizes();
1366 set_max_kernel_sizes(v);
Definition: LocalisedException.h:32
Definition: JacobiCG.h:37
void set_output(std::string proj_data_file)
Specifies the prefix for the output file(s),.
Definition: stir_x.h:621
float get_time_at_which_num_prompts_exceeds_threshold(const unsigned long threshold) const
Definition: stir_x.cpp:53
ListmodeToSinograms(const char *par)
Constructor.
Definition: stir_x.h:591
Class for the product of backward and forward projectors of a PET acquisition model.
Definition: stir_x.h:206
Class for a PET acquisition model.
Definition: stir_x.h:197
void set_image_data_processor(stir::shared_ptr< ImageDataProcessor > sptr_processor)
sets data processor to use on the image before forward projection and after back projection
Definition: stir_x.cpp:510
std::shared_ptr< STIRAcquisitionData > forward(const STIRImageData &image, int subset_num=0, int num_subsets=1, bool do_linear_only=false) const
computes and returns a subset of forward-projected data
Definition: stir_x.cpp:558
float norm(int subset_num=0, int num_subsets=1, int num_iter=2, int verb=0) const
Method computing the norm of the linear part S G of the PET acquisition model operator F.
Definition: stir_x.h:239
Ray tracing matrix implementation of the PET acquisition model.
Definition: stir_x.h:392
void enable_cache(bool v=true)
Enables or disables the caching mechanism.
Definition: stir_x.h:420
int get_num_tangential_LORs()
@
Definition: stir_x.h:448
void set_restrict_to_cylindrical_FOV(bool v=true)
Enables or disables using a circular axial FOV (vs rectangular)
Definition: stir_x.h:454
Listmode-to-sinograms converter.
Definition: stir_x.h:89
Attenuation model.
Definition: stir_x.h:548
virtual void unnormalise(STIRAcquisitionData &ad) const
multiply by bin efficiencies (here attenuation factors), i.e. attenuate data in ad
Definition: stir_x.cpp:449
static void compute_ac_factors(const STIRAcquisitionData &acq_templ, const PETAttenuationModel &acq_sens_mod, std::shared_ptr< STIRAcquisitionData > &af_sptr, std::shared_ptr< STIRAcquisitionData > &acf_sptr)
Definition: stir_x.h:558
Class for estimating the scatter contribution in PET projection data.
Definition: stir_x.h:846
void set_attenuation_correction_factors_sptr(std::shared_ptr< const STIRAcquisitionData > arg)
Set attenuation correction factors as acq_data.
Definition: stir_x.h:880
void set_max_scale_value(float v)
Set maximal scale factor value of the SSS algorithm to use.
Definition: stir_x.h:951
PETScatterEstimator()
constructor.
Definition: stir_x.h:855
void set_min_scale_value(float v)
Set minimal scale factor value of the SSS algorithm to use.
Definition: stir_x.h:957
void set_input_sptr(std::shared_ptr< const STIRAcquisitionData > arg)
Set the input data.
Definition: stir_x.h:875
std::shared_ptr< STIRAcquisitionData > get_output() const
get last scatter estimate
Definition: stir_x.h:976
void set_background_sptr(std::shared_ptr< const STIRAcquisitionData > arg)
Set the background data (normally equal to the randoms in PET)
Definition: stir_x.h:890
Succeeded set_up()
set up the object and performs checks
Definition: stir_x.h:995
void set_asm(std::shared_ptr< PETAcquisitionSensitivityModel > arg)
Set acquisition sensitivity model specifying detection efficiencies (without attenuation)
Definition: stir_x.h:885
void set_output_prefix(std::string prefix)
Set prefix for filenames with scatter estimates.
Definition: stir_x.h:913
PETScatterEstimator(std::string filename)
Overloaded constructor which takes the parameter file.
Definition: stir_x.h:870
Class for simulating the scatter contribution to PET data.
Definition: stir_x.h:754
PETSingleScatterSimulator(std::string filename)
Overloaded constructor which takes the parameter file.
Definition: stir_x.h:760
PETSingleScatterSimulator()
Default constructor.
Definition: stir_x.h:757
STIR ProjData wrapper with added functionality.
Definition: stir_data_containers.h:161
In-file implementation of STIRAcquisitionData.
Definition: stir_data_containers.h:541
STIR DiscretisedDensity<3, float> wrapper with added functionality.
Definition: stir_data_containers.h:965
Accessor classes.
Definition: stir_x.h:1039
Definition: stir_x.h:1261
Definition: stir_x.h:1109
Definition: stir_x.h:1067
Definition: stir_x.h:1192
Definition: stir_x.h:1234
Definition: stir_x.h:1087
Definition: stir_x.h:1224
Definition: stir_x.h:1248
Definition: stir_x.h:1101
Definition: stir_x.h:1157
Definition: stir_x.h:1132
Definition: stir_x.h:1080
Definition: stir_x.h:1094
Definition: stir_x.h:1328
Abstract base class for SIRF image data.
Definition: GeometricalInfo.cpp:141
bool iequals(const std::string &a, const std::string &b)
Case insensitive string comparison, replaces boost::iequals.
Definition: iequals.cpp:7
DataProcessor3DF ImageDataProcessor
A typedef to use SIRF terminology for DataProcessors.
Definition: stir_x.h:150
Specification file for data handling types not present in STIR.