Hello,
I have a nii file. I can use SimpleITK to read it in c#.
But it’s didn’t combine the transform information.
It’s seems display the original image.
I think maybe I should use the “Resample” to do this.
But I don’t know how should I create the Transform by using the information in nii.
Please clarify what you mean by “didn’t combine the transformation information”.
If you mean that when the image was read its internal meta-data information (origin, direction cosine matrix) was not applied, then please share the data as that would be a bug in ITK/SimpleITK. Less likely because it is widely used, still always a possibility.
If the scenario is that you performed registration, then that is a different thing. The output of the registration is a transformation. Registration itself does not modify the input images. You can either save the transformation and use it with software that knows how to work with transformations and images and how to combine them (e.g. Slicer) or you can resample the image and save that. The relevant methods are sitk.Resample, sitk.WriteTransform, sitk.WriteImage.
And I showed the image with VTK, but the orientation is not correct.
The files were got from other people.
It’s should be a pair registered data.
When I use “Matlab/SPM/Check Reg”, the data seems correct.
But use my code is not correct.
What version of VTK are you using? Support for image orientation is relatively recent in VTK. Also not all filters in VTK actually use the orientation matrix. I know that Marching Cubes does not.
I think direction support for vtkImageData was only added with VTK 9. If you don’t have SetDataDirection that suggest that you’re using a version older than that. Calling vtkVersion.vetGetVersion() will tell you.
I haven’t used Activiz.NET, but it wouldn’t surprise me if it isn’t on the latest VTK version.
I wrote a SimpleITK Python function to ‘regularize’ a volume. It resamples the volume so that the orientation matrix is identity and voxels are cubicly spaced. You can see it here:
You are right. My vtkversion is 5.8. So I don’t have the SetDataDirection.
And I think the key point is Resample like yours code in python.
I will try to re-write it in C# at first.