From e525c6653b5524746ffefe6626bc159891749e37 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 4 Jun 2020 13:21:27 +0100 Subject: [PATCH] remove NiftyResample::process deprecation, improve documentation --- CHANGES.md | 2 +- doc/UserGuide.md | 29 ++++++++++++++----- .../cReg/include/sirf/Reg/NiftyResample.h | 4 +-- .../cReg/include/sirf/Reg/Resample.h | 4 +-- .../mReg/+sirf/+Reg/NiftyResample.m | 2 +- src/Registration/pReg/Reg.py.in | 5 +--- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 950afeed0..451727b94 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,7 @@ * A passthrough for both the maximum and minimum relative change during OSMAPOSL reconstruction has been added. * We have now corrected the geometrical information of `.h5` images (coming from ISMRMRD and Gadgetron). This means we can now convert them to other SIRF image types (e.g., `NiftiImageData` and `STIRImageData`). This is necessary for any kind of synergistic reconstruction. Further, to the best of our knowledge, this is the first ISMRMRD to NIfTI converter out there! * The adjoint transformation has now been implemented for `NiftyResample` through the wrapping of NiftyMoMo. -* `Resample::process()` has been marked as deprecated. Instead, the following methods have been added to C++, python and matlab NiftyResample: +* The following methods have been added to C++, python and matlab NiftyResample: * `out = forward(in)` * `forward(out, in)` * `out = adjoint(in)` diff --git a/doc/UserGuide.md b/doc/UserGuide.md index 814998d35..80ad2b406 100644 --- a/doc/UserGuide.md +++ b/doc/UserGuide.md @@ -594,12 +594,22 @@ Below examples are given for rigid/affine and non-rigid registrations, as well a ##### Resampling (NiftyResample) ###### Methods - set_reference_image Set the reference image - set_floating_image Set the floating - process Start the registration process - get_output Get the registered image - add_transformation Add transformation (any type) - set_interpolation_type Set interpolation type + set_reference_image Set the reference image + set_floating_image Set the floating + process Start the resampling process. + This is the equivalent of + forward(floating_image). + get_output Get the registered image + add_transformation Add transformation (any type) + clear_transformations Remove all transformations + set_interpolation_type Set interpolation type + forward(im, out=None) Resample image in forward direction. + Image should have same properties as + floating image used in set_up. + backward(im, out=None) Resample image in backward/adjoint direction. + Image should have same properties as + reference image used in set_up. + adjoint(im, out=None) Alias of backward. ###### Example res = NiftyResample() @@ -608,8 +618,11 @@ Below examples are given for rigid/affine and non-rigid registrations, as well a res.set_interpolation_type(1) res.add_transformation(trans1) res.add_transformation(trans2) - res.process() - output = res.get_output() + out = res.forward(flo) + # No allocation, faster + res.forward(flo, out=out) + # Backwards/adjoint + out2 = res.adjoint(ref) ### Other classes diff --git a/src/Registration/cReg/include/sirf/Reg/NiftyResample.h b/src/Registration/cReg/include/sirf/Reg/NiftyResample.h index a321eee2a..b169d97b6 100644 --- a/src/Registration/cReg/include/sirf/Reg/NiftyResample.h +++ b/src/Registration/cReg/include/sirf/Reg/NiftyResample.h @@ -108,8 +108,8 @@ class NiftyResample : public Resample /// Destructor virtual ~NiftyResample() {} - /// Process - DEPRECATED virtual void process(); + /// Process. Equivalent of calling forward(floating_image). Use get_output to get resampled image. + virtual void process(); /// Do the forward transformation virtual std::shared_ptr forward(const std::shared_ptr input_sptr); diff --git a/src/Registration/cReg/include/sirf/Reg/Resample.h b/src/Registration/cReg/include/sirf/Reg/Resample.h index 6afd6f443..def8cd6dc 100644 --- a/src/Registration/cReg/include/sirf/Reg/Resample.h +++ b/src/Registration/cReg/include/sirf/Reg/Resample.h @@ -104,8 +104,8 @@ class Resample /// Set padding value void set_padding_value(const float padding_value) { _padding_value = padding_value; } - /// Process - will call forward - DEPRECATED virtual void process() = 0; + /// Process. Equivalent of calling forward(floating_image). Use get_output to get resampled image. + virtual void process() = 0; /// Get output const std::shared_ptr get_output_sptr() const { return _output_image_sptr; } diff --git a/src/Registration/mReg/+sirf/+Reg/NiftyResample.m b/src/Registration/mReg/+sirf/+Reg/NiftyResample.m index 6c7849d25..48e291b0d 100644 --- a/src/Registration/mReg/+sirf/+Reg/NiftyResample.m +++ b/src/Registration/mReg/+sirf/+Reg/NiftyResample.m @@ -97,7 +97,7 @@ function set_padding_value(self, val) sirf.Reg.setParameter(self.handle_, self.name, 'padding', val, 'f') end function process(self) - %Process. + %Process. Equivalent of calling forward(floating_image). Use get_output to get resampled image. h = calllib('mreg', 'mReg_NiftyResample_process', self.handle_); sirf.Utilities.check_status([self.name ':process'], h); sirf.Utilities.delete(h) diff --git a/src/Registration/pReg/Reg.py.in b/src/Registration/pReg/Reg.py.in index ce85da154..f8f94c297 100644 --- a/src/Registration/pReg/Reg.py.in +++ b/src/Registration/pReg/Reg.py.in @@ -21,7 +21,6 @@ Object-Oriented wrap for the cReg-to-Python interface pyreg.py import abc import sys -import deprecation from pUtilities import * from sirf import SIRF @@ -954,10 +953,8 @@ class NiftyResample(object): """Set padding value.""" parms.set_float_par(self.handle, self.name, 'padding', val) - @deprecation.deprecated(deprecated_in="2.1.0", - details="Use forward(image) instead") def process(self): - """Process.""" + """Process. Equivalent of calling forward(floating_image). Use get_output to get resampled image.""" try_calling(pyreg.cReg_NiftyResample_process(self.handle)) def get_output(self):