[ITK Community] [Insight-users] coordinate system

WANG Chengjia wangchengjia1986 at gmail.com
Wed Feb 19 14:16:42 EST 2014


Hi all,

Thank you very much for all your suggestions! Just realize that ITK
assuming a LPS coordinate, I need to invert all the image coordinate values
to get right transformation matrix. Especially thanks to Alex and Luis's
help!

However, the transformed result is still a little wrong: I found before and
after resampling the image,  the origin in the original image was a little
shifted (centre of [0 0 0] point in original volume shifted to [x0, y0,
z0], and this shifted value is different in upsample and downsample cases).
What I exactly need for resampling is to have the centre of the origin
pixel fixed.

Thank you very much!

Best,





On Wed, Feb 19, 2014 at 2:05 PM, Alex Taylor <Alex.Taylor at mathworks.com>wrote:

>  Hi,
>
>  I have a couple suggestions based on what you've told me.
>
>
>    1. As Luis pointed out, ITK always performs resampling in a world
>    coordinate system. You are discussing isotropic vs. non-isotropic voxels.
>    It sounds to me like in ITK you may not be working in the default pixel
>    based coordinate system and you are specifying an original and spacing with
>    your ITK images. If this is the case, you should look at the function
>    IMWARP for resampling your images:
>
> http://www.mathworks.com/help/images/ref/imwarp.html
>
>  Using IMWARP, you can specify optional spatial referencing arguments
> along with your geometric transformation. These spatial referencing
> arguments define the position of the image grid in a world coordinate
> system, and are analogous to the Spacing/Origin properties of the ITK image
> object.
>
>  http://www.mathworks.com/help/images/ref/imref3dclass.html
>
>  What I suspect is happening is that there is a difference in world units
> per pixel in your ITK images vs. your MATLAB images. If this is the case,
> you would expect that the "rotation matrix" portion of your transform would
> be consistent between ITK and MATLAB but that your translation factors
> would be off by the difference in scale in each dimension between ITK and
> MATLAB. To confirm this, you should either register your images in ITK
> using an isotropic spacing of 1 unit/pixel in all dimensions to be
> consistent with the default MATLAB coordinate system, or you should use
> IMWARP and define a world coordinate system when solving your
> registration/resampling that is consistent with the coordinate system in
> ITK.
>
>  2) I work on the Image Processing Toolbox and don't have very much
> experience at all with Neural Networks in MATLAB. I would recommend posting
> your second question to MATLAB Answers. MATLAB Answers is a very responsive
> forum and should provide you with good information:
>
>  http://www.mathworks.com/matlabcentral/answers/
>
>  *- Alex*
>
>   From: WANG Chengjia <wangchengjia1986 at gmail.com>
> Date: Tuesday, February 18, 2014 11:13 PM
> To: Alex Taylor <Alex.Taylor at mathworks.com>
> Subject: Re: [Insight-users] coordinate system
>
>   Hi Alex,
>
>  Sorry to bother again, two additional questions as it is a very valuable
> chance to talk to a developer from the MathWorks.
>
>  1. Do you know how to get the same performance of Matlab function
> "interp3" in ITK so that I can control the number of slices I want to
> insert between two original slice?
>
>  2. The main reason I'm developing my present algorithm using c++
> (ITK+OpenCV) is because of training of Radial basis neural network (NN). I
> found in Matlab, to train a NN, I have to put all the inputs in one matrix,
> then the NN training goes automatically one iteration after another. But my
> problem is there are huge amount of NN inputs and I will encounter a memory
> overflow to complete the training process. So is there a way in Matlab to
> perform just one iteration of NN training?
>
>  Thank you very much for all your helps!
>
>  Best,
>
>
> On Wed, Feb 19, 2014 at 4:00 AM, WANG Chengjia <wangchengjia1986 at gmail.com
> > wrote:
>
>> Hi Alex,
>>
>>  Thank you very much for fast response!
>>
>>  I'm using linear interpolation in both Matlab and ITK.  It's strange
>> that because the rotation matrix (used in transform->SetMatrix(rot)) was
>> the same in both ITK and Matlab, I only need to x/y coordinate for
>> translation (when doing trainsform->SetTranslation()) to get close result.
>>
>>  I've just realized that when I resample the data for isotropic voxels,
>> ITK produced a few more slices, which may changed the Origin of the volume.
>> Because in Matlab, the first slice in the original anisotropic volume is
>> still the first slice in the interpolated isotropic volume. But the result
>> seems that in ITK this may not be true.
>>
>>  Thank you very much!
>>
>>  Best,
>>  Chengjia
>>
>>
>>
>> On Wed, Feb 19, 2014 at 3:51 AM, Alex Taylor <Alex.Taylor at mathworks.com>wrote:
>>
>>>  Hi Wang,
>>>
>>>  I'm a developer from the MathWorks who is also familiar with ITK. The
>>> x/y transpose issue is likely due to row major vs. column major differences
>>> between MATLAB and ITK. I'd have see the corresponding matlab and ITK code
>>> to say for sure.
>>>
>>>  When you resample your images in matlab/itk, which interpolation
>>> method are you using?
>>>
>>>  Best,
>>>
>>>  Alex
>>>
>>>
>>>
>>>
>>>
>>> On Feb 18, 2014, at 10:41 PM, "WANG Chengjia" <
>>> wangchengjia1986 at gmail.com> wrote:
>>>
>>>   More generally, I have a transformation matrix calculated, anyone
>>> know how to transform a volume using this matrix?
>>>
>>>  It is just a simple Rigid 3D transformation. In Matlab, I just use
>>> "tform = maketform('affine', transM');" to make up the transformation and
>>> apply it using " tformarray " then the images are perfectly aligned. But in
>>> ITK, I find I have to switch the x, y coordinate of translation when doing
>>> "targetTransform->SetTranslation(trans)". The result was still wrong,
>>> although quite close to the one I got in Matlab.
>>>
>>>  Can anyone help? Thanks in advance!
>>>
>>>  Best,
>>>
>>>
>>>
>>> On Tue, Feb 18, 2014 at 7:39 PM, WANG Chengjia <
>>> wangchengjia1986 at gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>>  I'm now working on a machine learning based 3D image registration
>>>> work. To create the ground truth registration, I need to firstly using
>>>> simple least square method to calculate a transformation from the
>>>> corresponding point (I'm using RIRE datasets).
>>>>
>>>>  The same working flow in matlab and itk produced the same
>>>> transformation matrix, but different transformed volume! In matlab, it's
>>>> well aligned using the coordinates of control points given by RIRE dataset.
>>>> But in ITK I have to inverse and switch the translation parameters. Then I
>>>> realized it's because of the different coordinate system in itk and Matlab.
>>>>
>>>>  Can anyone tell me a method to convert transformation matrix
>>>> calculated from the common coordinate system into the ITK one?
>>>>
>>>>  Thank you very much!
>>>>
>>>>  Best,
>>>>
>>>>  --
>>>> Chengjia Wang
>>>> Phd Student,
>>>> University of Edinburgh
>>>> Clinical Research Imaging Center (CRIC)
>>>> Toshiba Medical Visualization Systems Europe, Ltd
>>>> Email: wangchengjia1986 at gmail.com
>>>>
>>>
>>>
>>>
>>>  --
>>> Chengjia Wang
>>> Phd Student,
>>> University of Edinburgh
>>> Clinical Research Imaging Center (CRIC)
>>> Toshiba Medical Visualization Systems Europe, Ltd
>>> Email: wangchengjia1986 at gmail.com
>>>
>>>   _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.php
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>
>>
>>  --
>> Chengjia Wang
>> Phd Student,
>> University of Edinburgh
>> Clinical Research Imaging Center (CRIC)
>> Toshiba Medical Visualization Systems Europe, Ltd
>> Email: wangchengjia1986 at gmail.com
>>
>
>
>
>  --
> Chengjia Wang
> Phd Student,
> University of Edinburgh
> Clinical Research Imaging Center (CRIC)
> Toshiba Medical Visualization Systems Europe, Ltd
> Email: wangchengjia1986 at gmail.com
>



-- 
Chengjia Wang
Phd Student,
University of Edinburgh
Clinical Research Imaging Center (CRIC)
Toshiba Medical Visualization Systems Europe, Ltd
Email: wangchengjia1986 at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140219/5dd1362e/attachment-0002.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Community mailing list