-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add ConvertToITKTransform
example
#243
ENH: Add ConvertToITKTransform
example
#243
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
View / edit / reply to this conversation on ReviewNB dzenanz commented on 2023-08-28T17:13:48Z Line #1. itk_composite_transform = itk.CompositeTransform[itk.D, 2].New() Why not use this, more convenient form:
thewtex commented on 2023-08-28T20:10:18Z +1 |
comb_transform = registration_method.GetCombinationTransform()
itk_composite_transform = registration_method.ConvertToItkTransform(comb_transform) ReviewNB messed up formatting. |
Thanks for this PR @tbirdso! ConvertToItkTransform does indeed support converting a "single" transform (as returned by |
@dzenanz @N-Dekker Thanks for the notes! I will add a cell to demonstrate In practice I am not getting an For the given example: > print(registration_method.GetCombinationTransform())
AdvancedBSplineTransform (000001B7546E2960)
RTTI typeinfo: class elastix::AdvancedBSplineTransform<class elastix::ElastixTemplate<class itk::Image<float,2>,class itk::Image<float,2> > >
Reference Count: 14
Modified Time: 121552
Debug: Off
Object Name:
Observers:
none The transform cannot be cast to a > itk.CompositeTransform[itk.D,2].cast(registration_method.GetCombinationTransform())
RuntimeError Traceback (most recent call last)
Cell In[17], line 1
----> 1 itk.CompositeTransform[itk.D,2].cast(registration_method.GetCombinationTransform())
RuntimeError: bad cast However, calling > print(registration_method.GetCombinationTransform().TransformPoint([0,0]))
itkPointD2 ([-0.944895, 1.38383])
> print(itk_composite_transform.TransformPoint([0,0]))
itkPointD2 ([-0.944895, 1.38383]) For demonstration purposes, I believe it is easier to understand what is happening in the EDIT: As another (perhaps more important) distinction, I am not able to serialize the result of > itk.transformwrite([registration_method.GetCombinationTransform()],'testout_advanced.h5',compression=False)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[16], line 1
----> 1 itk.transformwrite([registration_method.GetCombinationTransform()],'testout_advanced.h5',compression=False)
File C:\venvs\venv-itk\lib\site-packages\itk\support\extras.py:1447, in transformwrite(transforms, filename, compression)
1445 for transform in transforms:
1446 writer.AddTransform(transform)
-> 1447 writer.Update()
RuntimeError: C:\P\IPP\ITK-source\ITK\Modules\IO\TransformHDF5\src\itkHDF5TransformIO.cxx:462:
ITK ERROR: HDF5TransformIOTemplate(00000201B49C4B80): H5Fcreate failed > itk.transformwrite([itk_composite_transform],'testout_composite_transform.h5',compression=False)
> itk.transformread('testout_composite_transform.h5')
[<itk.itkCompositeTransformPython.itkCompositeTransformD2; proxy of <Swig Object of type 'itkCompositeTransformD2 *' at 0x00000223FBBE81B0> >] |
You need to convert the resulting thing into an ITK transform, like this: |
Thanks @dzenanz , this is the step I was missing. I will revise the notebook to prefer this approach 👍 |
Since you already did the work, you could leave the current thing as an alternative approach. |
Adds a Jupyter Notebook example demonstrating how to convert Elastix registration transform results into standard ITK transform format.
b42f29a
to
fc53574
Compare
To avoid confusion between two approaches I've opted to remove the previous approach manually composing an |
Update GitHub `actions/checkout` to v3 for linting
+1 View entire conversation on ReviewNB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this!! 📖 ❤️
Adds a Jupyter Notebook example demonstrating how to convert Elastix registration transform results into standard ITK transform format.