@@ -640,6 +640,7 @@ actual_compute_sub_gradient_without_penalty(TargetT& gradient,
640640 this ->zero_seg0_end_planes !=0 ,
641641 NULL ,
642642 this ->additive_proj_data_sptr ,
643+ this ->normalisation_sptr ,
643644 caching_info_ptr,
644645 do_subtraction);
645646}
@@ -1106,6 +1107,7 @@ void distributable_compute_gradient(const shared_ptr<ForwardProjectorByBin>& for
11061107 bool zero_seg0_end_planes,
11071108 double * log_likelihood_ptr,
11081109 shared_ptr<ProjData> const & additive_binwise_correction,
1110+ shared_ptr<BinNormalisation> const & normalisation_sptr,
11091111 DistributedCachingInformation* caching_info_ptr,
11101112 const bool do_subtraction
11111113 )
@@ -1122,7 +1124,8 @@ void distributable_compute_gradient(const shared_ptr<ForwardProjectorByBin>& for
11221124 zero_seg0_end_planes,
11231125 log_likelihood_ptr,
11241126 additive_binwise_correction,
1125- /* normalisation info to be ignored */ shared_ptr<BinNormalisation>(), 0 ., 0 .,
1127+ normalisation_sptr,
1128+ 0 ., 0 .,
11261129 &RPC_process_related_viewgrams_gradient<true >,
11271130 caching_info_ptr
11281131 );
@@ -1233,8 +1236,6 @@ void RPC_process_related_viewgrams_gradient(
12331236 const RelatedViewgrams<float >* mult_viewgrams_ptr)
12341237{
12351238 assert (measured_viewgrams_ptr != NULL );
1236- if (!is_null_ptr (mult_viewgrams_ptr))
1237- error (" Internal error: mult_viewgrams_ptr should be zero when computing gradient" );
12381239
12391240 RelatedViewgrams<float > estimated_viewgrams = measured_viewgrams_ptr->get_empty_copy ();
12401241
@@ -1257,17 +1258,21 @@ void RPC_process_related_viewgrams_gradient(
12571258 }
12581259*/
12591260 forward_projector_sptr->forward_project (estimated_viewgrams);
1260-
1261-
1262-
1261+
12631262 if (additive_binwise_correction_ptr != NULL )
12641263 estimated_viewgrams += (*additive_binwise_correction_ptr);
12651264
12661265 // for sinogram division
12671266 divide_and_truncate (*measured_viewgrams_ptr, estimated_viewgrams, rim_truncation_sino, count, count2, log_likelihood_ptr);
12681267 if (do_subtraction){
1269- // subtract ones from estimated data [y/ybar - 1]
1270- estimated_viewgrams -= 1 ;
1268+ if (mult_viewgrams_ptr)
1269+ {
1270+ // subtract normalised ones from the data [y/ybar - 1/N]
1271+ *measured_viewgrams_ptr -= *mult_viewgrams_ptr;
1272+ } else {
1273+ // subtract ones from the data [y/ybar - 1]
1274+ *measured_viewgrams_ptr -= 1 ;
1275+ }
12711276 }
12721277 back_projector_sptr->back_project (*measured_viewgrams_ptr);
12731278};
0 commit comments