Get vtkImageData with correct origin from vtkMRMLScarlarVolumeNode

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Get vtkImageData with correct origin from vtkMRMLScarlarVolumeNode

Haiyong Xu-2
Hi there,

In vtkMRMLScalarVolumeNode, there is IjkToRas matrix which is used to
define the orientation of an image, i.e., the image pixels are from
left to right or right to left. Since vtkImageData does not have
orientation information, the vtkMRMLScalarVolumeNode::GetImageData()
will return a vtkImageData that is flipped sometimes. I usually use
itk::OrientImageFilter to handle this, but that need transform the
vtkImageData  to itk::Image< >, apply the filter, and transform the
image back. Is there a convenient method in Slicer to get a
vtkImageData with right origin and pixel order? Thanks.

Haiyong Xu
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: Get vtkImageData with correct origin from vtkMRMLScarlarVolumeNode

pieper
Administrator
Hi Haiyong -

To do this you could look at code in the CropVolumeApply procedure in
Modules/CropVolume/CropVolumeGUI.tcl.  The issue, as you noted, is that
vtkImageData doesn't know about orientation, so to ensure that a output
volume is properly transformed you need to specify the target space
dimensions that you need to have (i.e. you may want to resample to the
same grid and orientations as another volume you have as a reference).

Best,
Steve

On 01/12/2011 11:00 AM, Haiyong Xu wrote:

> Hi there,
>
> In vtkMRMLScalarVolumeNode, there is IjkToRas matrix which is used to
> define the orientation of an image, i.e., the image pixels are from
> left to right or right to left. Since vtkImageData does not have
> orientation information, the vtkMRMLScalarVolumeNode::GetImageData()
> will return a vtkImageData that is flipped sometimes. I usually use
> itk::OrientImageFilter to handle this, but that need transform the
> vtkImageData  to itk::Image<  >, apply the filter, and transform the
> image back. Is there a convenient method in Slicer to get a
> vtkImageData with right origin and pixel order? Thanks.
>
> Haiyong Xu
> _______________________________________________
> slicer-users mailing list
> [hidden email]
> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
> To unsubscribe: send email to [hidden email] with unsubscribe as the subject
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: Get vtkImageData with correct origin from vtkMRMLScarlarVolumeNode

Haiyong Xu-2
Thanks Steve. The procedure in CropVolumeGUI.tcl uses vtkImageReslice
filter. Now I get the same filter works in my function: given a volume
node, it always return a vtkImageData in RAS a coordinate system which
has the same spatial position as the image in the volume node.

In this function:
1. The origin of the vtkImageData will not be the same as the
volume_node->GetOrigin() if the IJKToRAS matrix is not identity.
2. The pixels will be permuted according to the IJKToRAS matrix.

How about add this function to vtkMRMLScalarVolumeNode, e.g.,
GetRASImageData()? With this helper function, the impact of
orientation differences in volumes will be greatly reduced. I can
share my code (in C++).

Cheers,
Haiyong



On Thu, Jan 13, 2011 at 1:18 AM, Steve Pieper <[hidden email]> wrote:

> Hi Haiyong -
>
> To do this you could look at code in the CropVolumeApply procedure in
> Modules/CropVolume/CropVolumeGUI.tcl.  The issue, as you noted, is that
> vtkImageData doesn't know about orientation, so to ensure that a output
> volume is properly transformed you need to specify the target space
> dimensions that you need to have (i.e. you may want to resample to the same
> grid and orientations as another volume you have as a reference).
>
> Best,
> Steve
>
> On 01/12/2011 11:00 AM, Haiyong Xu wrote:
>>
>> Hi there,
>>
>> In vtkMRMLScalarVolumeNode, there is IjkToRas matrix which is used to
>> define the orientation of an image, i.e., the image pixels are from
>> left to right or right to left. Since vtkImageData does not have
>> orientation information, the vtkMRMLScalarVolumeNode::GetImageData()
>> will return a vtkImageData that is flipped sometimes. I usually use
>> itk::OrientImageFilter to handle this, but that need transform the
>> vtkImageData  to itk::Image<  >, apply the filter, and transform the
>> image back. Is there a convenient method in Slicer to get a
>> vtkImageData with right origin and pixel order? Thanks.
>>
>> Haiyong Xu
>> _______________________________________________
>> slicer-users mailing list
>> [hidden email]
>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
>> To unsubscribe: send email to
>> [hidden email] with unsubscribe as the
>> subject
>
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
Reply | Threaded
Open this post in threaded view
|

Re: Get vtkImageData with correct origin from vtkMRMLScarlarVolumeNode

pieper
Administrator
Hi Haiyong -

I agree, it would be good to have this functionality in a convenient
method.  I'm cross-posting this to slicer-devel list for comments
(coding follow-ups to that list only, please).

Can Andriy or others comment on this?  I know the cropvolume and itk
resample CLI modules can do some of this, but where should this kind of
convenience method go, in the mrml node or in the volumes logic?

-Steve

On 01/13/2011 12:27 PM, Haiyong Xu wrote:

> Thanks Steve. The procedure in CropVolumeGUI.tcl uses vtkImageReslice
> filter. Now I get the same filter works in my function: given a volume
> node, it always return a vtkImageData in RAS a coordinate system which
> has the same spatial position as the image in the volume node.
>
> In this function:
> 1. The origin of the vtkImageData will not be the same as the
> volume_node->GetOrigin() if the IJKToRAS matrix is not identity.
> 2. The pixels will be permuted according to the IJKToRAS matrix.
>
> How about add this function to vtkMRMLScalarVolumeNode, e.g.,
> GetRASImageData()? With this helper function, the impact of
> orientation differences in volumes will be greatly reduced. I can
> share my code (in C++).
>
> Cheers,
> Haiyong
>
>
>
> On Thu, Jan 13, 2011 at 1:18 AM, Steve Pieper<[hidden email]>  wrote:
>> Hi Haiyong -
>>
>> To do this you could look at code in the CropVolumeApply procedure in
>> Modules/CropVolume/CropVolumeGUI.tcl.  The issue, as you noted, is that
>> vtkImageData doesn't know about orientation, so to ensure that a output
>> volume is properly transformed you need to specify the target space
>> dimensions that you need to have (i.e. you may want to resample to the same
>> grid and orientations as another volume you have as a reference).
>>
>> Best,
>> Steve
>>
>> On 01/12/2011 11:00 AM, Haiyong Xu wrote:
>>>
>>> Hi there,
>>>
>>> In vtkMRMLScalarVolumeNode, there is IjkToRas matrix which is used to
>>> define the orientation of an image, i.e., the image pixels are from
>>> left to right or right to left. Since vtkImageData does not have
>>> orientation information, the vtkMRMLScalarVolumeNode::GetImageData()
>>> will return a vtkImageData that is flipped sometimes. I usually use
>>> itk::OrientImageFilter to handle this, but that need transform the
>>> vtkImageData  to itk::Image<    >, apply the filter, and transform the
>>> image back. Is there a convenient method in Slicer to get a
>>> vtkImageData with right origin and pixel order? Thanks.
>>>
>>> Haiyong Xu
>>> _______________________________________________
>>> slicer-users mailing list
>>> [hidden email]
>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
>>> To unsubscribe: send email to
>>> [hidden email] with unsubscribe as the
>>> subject
>>
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject