2424#include  " stir/recon_buildblock/ProjMatrixByBinSPECTUB.h" 
2525#include  " stir/recon_buildblock/TrivialDataSymmetriesForBins.h" 
2626#include  " stir/ProjDataInfoCylindricalArcCorr.h" 
27+ #include  " stir/ProjDataInfoSubsetByView.h" 
2728#include  " stir/IO/read_from_file.h" 
2829#include  " stir/ProjDataInfo.h" 
2930#include  " stir/VoxelsOnCartesianGrid.h" 
3031#include  " stir/Succeeded.h" 
3132#include  " stir/is_null_ptr.h" 
3233#include  " stir/Coordinate3D.h" 
34+ #include  " stir/stream.h" 
3335#include  " stir/info.h" 
3436#include  " stir/warning.h" 
3537#include  " stir/error.h" 
@@ -254,9 +256,6 @@ ProjMatrixByBinSPECTUB::set_up(const shared_ptr<const ProjDataInfo>& proj_data_i
254256  this ->voxel_size  = image_info_ptr->get_voxel_size ();
255257  this ->origin  = image_info_ptr->get_origin ();
256258
257-   const  ProjDataInfoCylindricalArcCorr* proj_Data_Info_Cylindrical
258-       = dynamic_cast <const  ProjDataInfoCylindricalArcCorr*>(this ->proj_data_info_ptr .get ());
259- 
260259  CPUTimer timer;
261260  timer.start ();
262261
@@ -299,15 +298,23 @@ ProjMatrixByBinSPECTUB::set_up(const shared_ptr<const ProjDataInfo>& proj_data_i
299298  vox.thcm  = vol.thcm ;
300299
301300  // ... projecction parameters ..........................................
302-   prj.ang0  = this ->proj_data_info_ptr ->get_scanner_ptr ()->get_intrinsic_azimuthal_tilt () * float (180  / _PI);
303-   prj.incr  = proj_Data_Info_Cylindrical->get_azimuthal_angle_sampling () * float (180  / _PI);
304-   prj.thcm  = proj_Data_Info_Cylindrical->get_axial_sampling (0 ) / 10 ;
301+   prj.angles  = std::vector<float >(prj.Nang );
302+   {
303+     Bin bin;
304+     for  (int  i = 0 ; i < prj.Nang ; i++)
305+       {
306+         bin.view_num () = i;
307+         prj.angles [i] = static_cast <float >(this ->proj_data_info_ptr ->get_phi (bin) * 180  / _PI);
308+       }
309+     //  all bins will have same axial sampling
310+     prj.thcm  = this ->proj_data_info_ptr ->get_sampling_in_m (bin) / 10 ;
311+   }
305312
306313  // .......geometrical and other derived parameters of projection structure...........
307-   prj.Nsli  = proj_Data_Info_Cylindrical ->get_num_axial_poss (0 ); //  number of slices
308-   prj.lngcm  = prj.Nbin  * prj.szcm ;                               //  length in cm of the detection line
309-   prj.Nbp  = prj.Nbin  * prj.Nsli ;                                 //  number of bins for each projection angle (2D-projection)
310-   prj.Nbt  = prj.Nbp  * prj.Nang ;                                  //  total number of bins considering all the projection angles
314+   prj.Nsli  = this -> proj_data_info_ptr ->get_num_axial_poss (0 ); //  number of slices
315+   prj.lngcm  = prj.Nbin  * prj.szcm ;                            //  length in cm of the detection line
316+   prj.Nbp  = prj.Nbin  * prj.Nsli ;                              //  number of bins for each projection angle (2D-projection)
317+   prj.Nbt  = prj.Nbp  * prj.Nang ;                               //  total number of bins considering all the projection angles
311318  prj.Nbind2  = (float )prj.Nbin  / (float )2 .; //  half of the number of bins in a detection line (integer or semi-integer)
312319  prj.lngcmd2  = prj.lngcm  / (float )2 .;      //  half of the length of detection line (cm)
313320  prj.Nslid2  = (float )prj.Nsli  / (float )2 .; //  half of the number of slices (integer or semi-integer)
@@ -329,7 +336,35 @@ ProjMatrixByBinSPECTUB::set_up(const shared_ptr<const ProjDataInfo>& proj_data_i
329336                 wmh.prj .Nsli ,
330337                 vol.Nsli ));
331338  // ....rotation radius .................................................
332-   const  VectorWithOffset<float > radius_all_views = proj_Data_Info_Cylindrical->get_ring_radii_for_all_views ();
339+   VectorWithOffset<float > radius_all_views (prj.Nang );
340+   {
341+     if  (auto  proj_Data_Info_Cylindrical = dynamic_cast <const  ProjDataInfoCylindricalArcCorr*>(this ->proj_data_info_ptr .get ()))
342+       {
343+         radius_all_views = proj_Data_Info_Cylindrical->get_ring_radii_for_all_views ();
344+       }
345+     else  if  (auto  proj_data_info_subset_ptr = dynamic_cast <const  ProjDataInfoSubsetByView*>(this ->proj_data_info_ptr .get ()))
346+       {
347+         if  (auto  proj_Data_Info_Cylindrical = dynamic_cast <const  ProjDataInfoCylindricalArcCorr*>(
348+                 proj_data_info_subset_ptr->get_original_proj_data_info_sptr ().get ()))
349+           {
350+             for  (int  i = 0 ; i < prj.Nang ; ++i)
351+               {
352+                 Bin bin;
353+                 bin.view_num () = i;
354+                 const  int  org_view = proj_data_info_subset_ptr->get_original_bin (bin).view_num ();
355+                 radius_all_views[i] = proj_Data_Info_Cylindrical->get_ring_radius (org_view);
356+               }
357+           }
358+         else 
359+           {
360+             error (" ProjMatrixByBinSPECTUB: can only handle ProjDataInfoCylindricalArcCorr" 
361+           }
362+       }
363+     else 
364+       {
365+         error (" ProjMatrixByBinSPECTUB: can only handle ProjDataInfoCylindricalArcCorr" 
366+       }
367+   }
333368
334369  {
335370    const  auto  max_radius = *std::max_element (radius_all_views.begin (), radius_all_views.end ());
@@ -493,8 +528,7 @@ ProjMatrixByBinSPECTUB::set_up(const shared_ptr<const ProjDataInfo>& proj_data_i
493528  info_stream << " Number of slices: " vol .Nsli  << " \t slice_thickness: " vol .thcm  << std::endl;
494529  info_stream << " Number of bins: " prj .Nbin  << " \t bin size: " prj .szcm  << " \t axial size: " prj .thcm 
495530              << std::endl;
496-   info_stream << " Number of angles: " prj .Nang  << " \t Angle increment: " prj .incr 
497-               << " \t First angle: " prj .ang0  << std::endl;
531+   info_stream << " Number of angles: " prj .Nang  << " \t angles (deg): " prj .angles  << std::endl;
498532  info_stream << " Number of subsets: " prj .NOS  << std::endl;
499533  if  (wmh.do_att )
500534    {
0 commit comments