diff --git a/src/Registration/cReg/NiftiImageData.cpp b/src/Registration/cReg/NiftiImageData.cpp index 6afbbe56c..9f9e25d30 100644 --- a/src/Registration/cReg/NiftiImageData.cpp +++ b/src/Registration/cReg/NiftiImageData.cpp @@ -220,7 +220,7 @@ void NiftiImageData::construct_NiftiImageData_from_complex_im_real_com auto &it_in = in_sptr->begin(); auto &it_out = out_sptr->begin(); - for (; it_in!=in_sptr->end(); ++it_in, ++it_out) + for (; it_out != out_sptr->end(); ++it_in, ++it_out) *it_out = (*it_in).complex_float().real(); } @@ -235,7 +235,7 @@ void NiftiImageData::construct_NiftiImageData_from_complex_im_imag_com auto &it_in = in_sptr->begin(); auto &it_out = out_sptr->begin(); - for (; it_in!=in_sptr->end(); ++it_in, ++it_out) + for (; it_out != out_sptr->end(); ++it_in, ++it_out) *it_out = (*it_in).complex_float().imag(); } diff --git a/src/Registration/pReg/Reg.py b/src/Registration/pReg/Reg.py index d05103eb9..9f588663a 100644 --- a/src/Registration/pReg/Reg.py +++ b/src/Registration/pReg/Reg.py @@ -1108,10 +1108,26 @@ def set_padding_value(self, val): def norm(self, num_iter=2, verb=0): '''Computes the norm of the forward projection operator. ''' + # reference and floating images need to be real. + if self.reference_image.is_complex(): + reference_image, _ = NiftiImageData.construct_from_complex_image(self.reference_image) + parms.set_parameter( + self.handle, self.name, 'reference_image', reference_image.handle) + if self.floating_image.is_complex(): + floating_image, _ = NiftiImageData.construct_from_complex_image(self.floating_image) + parms.set_parameter( + self.handle, self.name, 'floating_image', floating_image.handle) handle = pyreg.cReg_NiftyResampler_norm(self.handle, num_iter, verb) check_status(handle) r = pyiutil.floatDataFromHandle(handle) pyiutil.deleteDataHandle(handle) + # Restore reference and floating images. + if self.reference_image.is_complex(): + parms.set_parameter( + self.handle, self.name, 'reference_image', self.reference_image.handle) + if self.floating_image.is_complex(): + parms.set_parameter( + self.handle, self.name, 'floating_image', self.floating_image.handle) return r; def process(self):