Converting ITK image to Slicer ScalarVolumeNode

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

Converting ITK image to Slicer ScalarVolumeNode

andrey.fedorov
Hi,

I need to get ScalarVolume node from ITK image in C++. It is a very
common operation that I don't want to reimplement. Is there a helper
function I can reuse for this? I am having troubles finding one.
thanks

AF
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Reply | Threaded
Open this post in threaded view
|

Re: Converting ITK image to Slicer ScalarVolumeNode

Steve Pieper-2
Hi Andrey - 

The CLI logic and vtkITKArchetype code does this via IO - it's not as simple as you might hope given the polymorphic nature of ITK images and how the map to different Slicer types.

Here's some simple code for going back and forth from vtk to itk:


Centralizing some helper code would be great.

-Steve

On Thu, Oct 29, 2015 at 3:41 PM, Andrey Fedorov <[hidden email]> wrote:
Hi,

I need to get ScalarVolume node from ITK image in C++. It is a very
common operation that I don't want to reimplement. Is there a helper
function I can reuse for this? I am having troubles finding one.
thanks

AF
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: Converting ITK image to Slicer ScalarVolumeNode

Dzenan Zukic
I recently needed the opposite: converting Slicer's ScalarVolumeNode to itk::Image. The attached code is what I came up with. This is for posterity.

Dženan Zukić, R&D Engineer, Kitware (Carrboro, NC Office)

On Fri, Oct 30, 2015 at 8:04 AM, Steve Pieper <[hidden email]> wrote:
Hi Andrey - 

The CLI logic and vtkITKArchetype code does this via IO - it's not as simple as you might hope given the polymorphic nature of ITK images and how the map to different Slicer types.

Here's some simple code for going back and forth from vtk to itk:


Centralizing some helper code would be great.

-Steve

On Thu, Oct 29, 2015 at 3:41 PM, Andrey Fedorov <[hidden email]> wrote:
Hi,

I need to get ScalarVolume node from ITK image in C++. It is a very
common operation that I don't want to reimplement. Is there a helper
function I can reuse for this? I am having troubles finding one.
thanks

AF
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

MRMLVolume2ITKImage.cpp (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Converting ITK image to Slicer ScalarVolumeNode

andrey.fedorov
In reply to this post by Steve Pieper-2
Dženan,

Thank you for sharing!

For going the other way, SlicerRT guys have a nice class:
https://github.com/SlicerRt/SlicerRT/tree/master/SlicerRtCommon.

This is the point - we all keep reimplementing those functions over
and over and over, instead of putting them in Slicer and providing as
helpers!...

AF



On Mon, Nov 2, 2015 at 9:20 AM, Dzenan Zukic <[hidden email]> wrote:

> I recently needed the opposite: converting Slicer's ScalarVolumeNode to
> itk::Image. The attached code is what I came up with. This is for posterity.
>
> Dženan Zukić, R&D Engineer, Kitware (Carrboro, NC Office)
>
> On Fri, Oct 30, 2015 at 8:04 AM, Steve Pieper <[hidden email]> wrote:
>>
>> Hi Andrey -
>>
>> The CLI logic and vtkITKArchetype code does this via IO - it's not as
>> simple as you might hope given the polymorphic nature of ITK images and how
>> the map to different Slicer types.
>>
>> Here's some simple code for going back and forth from vtk to itk:
>>
>>
>> https://github.com/Slicer/Slicer/blob/master/Libs/vtkITK/vtkITKDistanceTransform.cxx#L39-L86
>>
>> Centralizing some helper code would be great.
>>
>> -Steve
>>
>> On Thu, Oct 29, 2015 at 3:41 PM, Andrey Fedorov <[hidden email]>
>> wrote:
>>>
>>> Hi,
>>>
>>> I need to get ScalarVolume node from ITK image in C++. It is a very
>>> common operation that I don't want to reimplement. Is there a helper
>>> function I can reuse for this? I am having troubles finding one.
>>> thanks
>>>
>>> AF
>>> _______________________________________________
>>> slicer-devel mailing list
>>> [hidden email]
>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>> To unsubscribe: send email to [hidden email] with
>>> unsubscribe as the subject
>>>
>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>>>
>>>
>>> The information in this e-mail is intended only for the person to whom it
>>> is
>>> addressed. If you believe this e-mail was sent to you in error and the
>>> e-mail
>>> contains patient information, please contact the Partners Compliance
>>> HelpLine at
>>> http://www.partners.org/complianceline . If the e-mail was sent to you in
>>> error
>>> but does not contain patient information, please contact the sender and
>>> properly
>>> dispose of the e-mail.
>>>
>>
>>
>> _______________________________________________
>> slicer-devel mailing list
>> [hidden email]
>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>> To unsubscribe: send email to [hidden email] with
>> unsubscribe as the subject
>>
>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>>
>>
>> The information in this e-mail is intended only for the person to whom it
>> is
>> addressed. If you believe this e-mail was sent to you in error and the
>> e-mail
>> contains patient information, please contact the Partners Compliance
>> HelpLine at
>> http://www.partners.org/complianceline . If the e-mail was sent to you in
>> error
>> but does not contain patient information, please contact the sender and
>> properly
>> dispose of the e-mail.
>>
>
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Converting ITK image to Slicer ScalarVolumeNode

andrey.fedorov
On Mon, Nov 2, 2015 at 12:26 PM, San Jose Estepar, Raul,Ph.D.
<[hidden email]> wrote:
> Hi Andrey,
>
> For conversion between ITK and VTK we have been using the ITKVtk Glue module in ITK ([1] is an example of use in one of the CLIs in CIP).
> Do you need any extra functionality?

Raul, I am aware of that module, the issue with ITKVtk Glue is that it
does not initialize image orientation IJK2RAS matrix in the
Slicer-specific way.

> I would say this would be the prefer way and I believe this module is now part of ITK in Slicer. If not, my vote would be for its inclusion.
>
> I agree that this is something that can be implemented at the MRML  level so there is a easy to use helper function that directly give you the corresponding ITK image from a MRML node and the other way around.
>

I discussed this further with Steve today, and his take on this is
that the best way to integrate ITK functionality is using CLIs,
delegating the issue of conversion to Slicer/ITK IO mechanisms. Maybe
Steve can elaborate a bit further.


> /R
>
>
> [1] https://github.com/acil-bwh/ChestImagingPlatform/blob/master/CommandLineTools/GenerateModel/GenerateModel.cxx#L43-L47
>
>
>
>> On Nov 2, 2015, at 9:44 AM, Andrey Fedorov <[hidden email]> wrote:
>>
>> Dženan,
>>
>> Thank you for sharing!
>>
>> For going the other way, SlicerRT guys have a nice class:
>> https://github.com/SlicerRt/SlicerRT/tree/master/SlicerRtCommon.
>>
>> This is the point - we all keep reimplementing those functions over
>> and over and over, instead of putting them in Slicer and providing as
>> helpers!...
>>
>> AF
>>
>>
>>
>> On Mon, Nov 2, 2015 at 9:20 AM, Dzenan Zukic <[hidden email]> wrote:
>>> I recently needed the opposite: converting Slicer's ScalarVolumeNode to
>>> itk::Image. The attached code is what I came up with. This is for posterity.
>>>
>>> Dženan Zukić, R&D Engineer, Kitware (Carrboro, NC Office)
>>>
>>> On Fri, Oct 30, 2015 at 8:04 AM, Steve Pieper <[hidden email]> wrote:
>>>>
>>>> Hi Andrey -
>>>>
>>>> The CLI logic and vtkITKArchetype code does this via IO - it's not as
>>>> simple as you might hope given the polymorphic nature of ITK images and how
>>>> the map to different Slicer types.
>>>>
>>>> Here's some simple code for going back and forth from vtk to itk:
>>>>
>>>>
>>>> https://github.com/Slicer/Slicer/blob/master/Libs/vtkITK/vtkITKDistanceTransform.cxx#L39-L86
>>>>
>>>> Centralizing some helper code would be great.
>>>>
>>>> -Steve
>>>>
>>>> On Thu, Oct 29, 2015 at 3:41 PM, Andrey Fedorov <[hidden email]>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I need to get ScalarVolume node from ITK image in C++. It is a very
>>>>> common operation that I don't want to reimplement. Is there a helper
>>>>> function I can reuse for this? I am having troubles finding one.
>>>>> thanks
>>>>>
>>>>> AF
>>>>> _______________________________________________
>>>>> slicer-devel mailing list
>>>>> [hidden email]
>>>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>>>> To unsubscribe: send email to [hidden email] with
>>>>> unsubscribe as the subject
>>>>>
>>>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>>>>>
>>>>>
>>>>> The information in this e-mail is intended only for the person to whom it
>>>>> is
>>>>> addressed. If you believe this e-mail was sent to you in error and the
>>>>> e-mail
>>>>> contains patient information, please contact the Partners Compliance
>>>>> HelpLine at
>>>>> http://www.partners.org/complianceline . If the e-mail was sent to you in
>>>>> error
>>>>> but does not contain patient information, please contact the sender and
>>>>> properly
>>>>> dispose of the e-mail.
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> slicer-devel mailing list
>>>> [hidden email]
>>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>>> To unsubscribe: send email to [hidden email] with
>>>> unsubscribe as the subject
>>>>
>>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>>>>
>>>>
>>>> The information in this e-mail is intended only for the person to whom it
>>>> is
>>>> addressed. If you believe this e-mail was sent to you in error and the
>>>> e-mail
>>>> contains patient information, please contact the Partners Compliance
>>>> HelpLine at
>>>> http://www.partners.org/complianceline . If the e-mail was sent to you in
>>>> error
>>>> but does not contain patient information, please contact the sender and
>>>> properly
>>>> dispose of the e-mail.
>>>>
>>>
>> _______________________________________________
>> slicer-devel mailing list
>> [hidden email]
>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>> To unsubscribe: send email to [hidden email] with unsubscribe as the subject
>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Converting ITK image to Slicer ScalarVolumeNode

Steve Pieper-2
Hi - 

Yes, Andrey and I talked about this yesterday and I would summarize my suggested architecture for using ITK code to process Slicer MRML data as follows:

1) develop an ITK pipeline that implements the desired behavior

2) wrap the pipeline in a high level pure C++ ITK class that exposes the key inputs, output, parameters, and events

3) write a thin CLI wrapper around (2) using the Slicer Execution mode

4a) use the CLI in Slicer as-is

4b) write a scripted module that presents a higher level interface and calls the CLI

4c) if you need more interactivity, write a vtkITK wrapper around (2) that exposes the high level ITK class aspects using VTK conventions; expose this via a scripted or loadable module.


A nice thing about this approach is that (1) through (3) are all highly reusable in different contexts both in and out of Slicer.

Also this path, steps (1) through (4b) all the data types and orientation mappings between itk::Image and vtkMRMLScalarVolumeNode are handled automatically with existing mechanisms.  Since the CLI is built as a shared library by default there is no file system overhead, just a few memcpys which is not much different than using the ITK pipeline directly.

Another option is to implement the pipeline in SimpleITK, but adding custom C++ code into the SimpleITK is more complex and I don't think it's even possible to do this as an extension, whereas the path described above is completely compatible with our extension process.

Note that the use case for the code that Raul points to is the opposite case, using a VTK class inside of an ITK pipeline.  In this case ITKVtkGlue is very appropriate.  The IJKToRAS transforms are not relevant since vtkImageData class does not support orientation and all the operations need to be performed in pixel space.

That said, the code Dzenan, Csaba and the SlicerRT team use to get an itk::Image of the right type and orientation from a MRML volume is reasonable and could be added as helper code to Slicer, but it's not the way I would typically organize the code.

-Steve




On Mon, Nov 2, 2015 at 1:38 PM, Andrey Fedorov <[hidden email]> wrote:
On Mon, Nov 2, 2015 at 12:26 PM, San Jose Estepar, Raul,Ph.D.
<[hidden email]> wrote:
> Hi Andrey,
>
> For conversion between ITK and VTK we have been using the ITKVtk Glue module in ITK ([1] is an example of use in one of the CLIs in CIP).
> Do you need any extra functionality?

Raul, I am aware of that module, the issue with ITKVtk Glue is that it
does not initialize image orientation IJK2RAS matrix in the
Slicer-specific way.

> I would say this would be the prefer way and I believe this module is now part of ITK in Slicer. If not, my vote would be for its inclusion.
>
> I agree that this is something that can be implemented at the MRML  level so there is a easy to use helper function that directly give you the corresponding ITK image from a MRML node and the other way around.
>

I discussed this further with Steve today, and his take on this is
that the best way to integrate ITK functionality is using CLIs,
delegating the issue of conversion to Slicer/ITK IO mechanisms. Maybe
Steve can elaborate a bit further.


> /R
>
>
> [1] https://github.com/acil-bwh/ChestImagingPlatform/blob/master/CommandLineTools/GenerateModel/GenerateModel.cxx#L43-L47
>
>
>
>> On Nov 2, 2015, at 9:44 AM, Andrey Fedorov <[hidden email]> wrote:
>>
>> Dženan,
>>
>> Thank you for sharing!
>>
>> For going the other way, SlicerRT guys have a nice class:
>> https://github.com/SlicerRt/SlicerRT/tree/master/SlicerRtCommon.
>>
>> This is the point - we all keep reimplementing those functions over
>> and over and over, instead of putting them in Slicer and providing as
>> helpers!...
>>
>> AF
>>
>>
>>
>> On Mon, Nov 2, 2015 at 9:20 AM, Dzenan Zukic <[hidden email]> wrote:
>>> I recently needed the opposite: converting Slicer's ScalarVolumeNode to
>>> itk::Image. The attached code is what I came up with. This is for posterity.
>>>
>>> Dženan Zukić, R&D Engineer, Kitware (Carrboro, NC Office)
>>>
>>> On Fri, Oct 30, 2015 at 8:04 AM, Steve Pieper <[hidden email]> wrote:
>>>>
>>>> Hi Andrey -
>>>>
>>>> The CLI logic and vtkITKArchetype code does this via IO - it's not as
>>>> simple as you might hope given the polymorphic nature of ITK images and how
>>>> the map to different Slicer types.
>>>>
>>>> Here's some simple code for going back and forth from vtk to itk:
>>>>
>>>>
>>>> https://github.com/Slicer/Slicer/blob/master/Libs/vtkITK/vtkITKDistanceTransform.cxx#L39-L86
>>>>
>>>> Centralizing some helper code would be great.
>>>>
>>>> -Steve
>>>>
>>>> On Thu, Oct 29, 2015 at 3:41 PM, Andrey Fedorov <[hidden email]>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I need to get ScalarVolume node from ITK image in C++. It is a very
>>>>> common operation that I don't want to reimplement. Is there a helper
>>>>> function I can reuse for this? I am having troubles finding one.
>>>>> thanks
>>>>>
>>>>> AF
>>>>> _______________________________________________
>>>>> slicer-devel mailing list
>>>>> [hidden email]
>>>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>>>> To unsubscribe: send email to [hidden email] with
>>>>> unsubscribe as the subject
>>>>>
>>>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>>>>>
>>>>>
>>>>> The information in this e-mail is intended only for the person to whom it
>>>>> is
>>>>> addressed. If you believe this e-mail was sent to you in error and the
>>>>> e-mail
>>>>> contains patient information, please contact the Partners Compliance
>>>>> HelpLine at
>>>>> http://www.partners.org/complianceline . If the e-mail was sent to you in
>>>>> error
>>>>> but does not contain patient information, please contact the sender and
>>>>> properly
>>>>> dispose of the e-mail.
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> slicer-devel mailing list
>>>> [hidden email]
>>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>>> To unsubscribe: send email to [hidden email] with
>>>> unsubscribe as the subject
>>>>
>>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>>>>
>>>>
>>>> The information in this e-mail is intended only for the person to whom it
>>>> is
>>>> addressed. If you believe this e-mail was sent to you in error and the
>>>> e-mail
>>>> contains patient information, please contact the Partners Compliance
>>>> HelpLine at
>>>> http://www.partners.org/complianceline . If the e-mail was sent to you in
>>>> error
>>>> but does not contain patient information, please contact the sender and
>>>> properly
>>>> dispose of the e-mail.
>>>>
>>>
>> _______________________________________________
>> slicer-devel mailing list
>> [hidden email]
>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>> To unsubscribe: send email to [hidden email] with unsubscribe as the subject
>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
>
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: Converting ITK image to Slicer ScalarVolumeNode

pinter
In reply to this post by andrey.fedorov
Hi Andrey,

As we agreed before, I implemented the missing ITK image to MRML volume node conversion function in SlicerRtCommon (where numerous similar conversions already exist). This function considers directions too, and can apply LPS to RAS conversion.
The ticket for this change is
https://www.assembla.com/spaces/slicerrt/tickets/777-implement-itk-image-to-mrml-volume-node-conversion/details
You can find my commit there too, which includes an example for how to use it.

I hope it helps!

Cheers,
csaba

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Andrey Fedorov
Sent: November 2, 2015 13:39
To: San Jose Estepar, Raul,Ph.D. <[hidden email]>
Cc: SPL Slicer Devel <[hidden email]>
Subject: Re: [slicer-devel] Converting ITK image to Slicer ScalarVolumeNode

On Mon, Nov 2, 2015 at 12:26 PM, San Jose Estepar, Raul,Ph.D.
<[hidden email]> wrote:
> Hi Andrey,
>
> For conversion between ITK and VTK we have been using the ITKVtk Glue module in ITK ([1] is an example of use in one of the CLIs in CIP).
> Do you need any extra functionality?

Raul, I am aware of that module, the issue with ITKVtk Glue is that it does not initialize image orientation IJK2RAS matrix in the Slicer-specific way.

> I would say this would be the prefer way and I believe this module is now part of ITK in Slicer. If not, my vote would be for its inclusion.
>
> I agree that this is something that can be implemented at the MRML  level so there is a easy to use helper function that directly give you the corresponding ITK image from a MRML node and the other way around.
>

I discussed this further with Steve today, and his take on this is that the best way to integrate ITK functionality is using CLIs, delegating the issue of conversion to Slicer/ITK IO mechanisms. Maybe Steve can elaborate a bit further.


> /R
>
>
> [1]
> https://github.com/acil-bwh/ChestImagingPlatform/blob/master/CommandLi
> neTools/GenerateModel/GenerateModel.cxx#L43-L47
>
>
>
>> On Nov 2, 2015, at 9:44 AM, Andrey Fedorov <[hidden email]> wrote:
>>
>> Dženan,
>>
>> Thank you for sharing!
>>
>> For going the other way, SlicerRT guys have a nice class:
>> https://github.com/SlicerRt/SlicerRT/tree/master/SlicerRtCommon.
>>
>> This is the point - we all keep reimplementing those functions over
>> and over and over, instead of putting them in Slicer and providing as
>> helpers!...
>>
>> AF
>>
>>
>>
>> On Mon, Nov 2, 2015 at 9:20 AM, Dzenan Zukic <[hidden email]> wrote:
>>> I recently needed the opposite: converting Slicer's ScalarVolumeNode
>>> to itk::Image. The attached code is what I came up with. This is for posterity.
>>>
>>> Dženan Zukić, R&D Engineer, Kitware (Carrboro, NC Office)
>>>
>>> On Fri, Oct 30, 2015 at 8:04 AM, Steve Pieper <[hidden email]> wrote:
>>>>
>>>> Hi Andrey -
>>>>
>>>> The CLI logic and vtkITKArchetype code does this via IO - it's not
>>>> as simple as you might hope given the polymorphic nature of ITK
>>>> images and how the map to different Slicer types.
>>>>
>>>> Here's some simple code for going back and forth from vtk to itk:
>>>>
>>>>
>>>> https://github.com/Slicer/Slicer/blob/master/Libs/vtkITK/vtkITKDist
>>>> anceTransform.cxx#L39-L86
>>>>
>>>> Centralizing some helper code would be great.
>>>>
>>>> -Steve
>>>>
>>>> On Thu, Oct 29, 2015 at 3:41 PM, Andrey Fedorov
>>>> <[hidden email]>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I need to get ScalarVolume node from ITK image in C++. It is a
>>>>> very common operation that I don't want to reimplement. Is there a
>>>>> helper function I can reuse for this? I am having troubles finding one.
>>>>> thanks
>>>>>
>>>>> AF
>>>>> _______________________________________________
>>>>> slicer-devel mailing list
>>>>> [hidden email]
>>>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>>>> To unsubscribe: send email to [hidden email]
>>>>> with unsubscribe as the subject
>>>>>
>>>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/D
>>>>> evelopers/FAQ
>>>>>
>>>>>
>>>>> The information in this e-mail is intended only for the person to
>>>>> whom it is addressed. If you believe this e-mail was sent to you
>>>>> in error and the e-mail contains patient information, please
>>>>> contact the Partners Compliance HelpLine at
>>>>> http://www.partners.org/complianceline . If the e-mail was sent to
>>>>> you in error but does not contain patient information, please
>>>>> contact the sender and properly dispose of the e-mail.
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> slicer-devel mailing list
>>>> [hidden email]
>>>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>>>> To unsubscribe: send email to [hidden email]
>>>> with unsubscribe as the subject
>>>>
>>>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/De
>>>> velopers/FAQ
>>>>
>>>>
>>>> The information in this e-mail is intended only for the person to
>>>> whom it is addressed. If you believe this e-mail was sent to you in
>>>> error and the e-mail contains patient information, please contact
>>>> the Partners Compliance HelpLine at
>>>> http://www.partners.org/complianceline . If the e-mail was sent to
>>>> you in error but does not contain patient information, please
>>>> contact the sender and properly dispose of the e-mail.
>>>>
>>>
>> _______________________________________________
>> slicer-devel mailing list
>> [hidden email]
>> http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
>> To unsubscribe: send email to [hidden email]
>> with unsubscribe as the subject
>> http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Deve
>> lopers/FAQ
>
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Converting ITK image to Slicer ScalarVolumeNode

Lowekamp, Bradley (NIH/NLM/LHC) [C]
In reply to this post by Steve Pieper-2

On Nov 3, 2015, at 12:06 PM, Steve Pieper <[hidden email]> wrote:

> Another option is to implement the pipeline in SimpleITK, but adding custom C++ code into the SimpleITK is more complex and I don't think it's even possible to do this as an extension, whereas the path described above is completely compatible with our extension process.
>

Hello,

Extension for SimpleITK has been done before, and is attainable with a little work and a use case. It will require the SimpleITK core libraries to be shared, a minor patch to the SimpleITK SWIG interface, and a little bit of CPython written to write for the extension.

If anyone is interested in this approach  let me know and I can get the SimpleITK interface out there to be tested.

Brad

_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Reply | Threaded
Open this post in threaded view
|

Re: Converting ITK image to Slicer ScalarVolumeNode

andrey.fedorov
In reply to this post by Steve Pieper-2
Thank you all for the input!

In the end, the approach I adopted is CLI. The reason is the
functionality was originally implemented as a CLI, and it didn't seem
to worth the effort to migrate it into a loadable module logic.

Thank you very much Csaba for adding this function. It will be very
helpful. I added an entry to developers' FAQ with the discussion here,
feel free to update:
http://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ/General#How_to_convert_between_ITK_images_and_Slicer_scalar_volume_nodes.3F

On Tue, Nov 3, 2015 at 1:15 PM, Bradley Lowekamp <[hidden email]> wrote:

>
> On Nov 3, 2015, at 12:06 PM, Steve Pieper <[hidden email]> wrote:
>
>> Another option is to implement the pipeline in SimpleITK, but adding custom C++ code into the SimpleITK is more complex and I don't think it's even possible to do this as an extension, whereas the path described above is completely compatible with our extension process.
>>
>
> Hello,
>
> Extension for SimpleITK has been done before, and is attainable with a little work and a use case. It will require the SimpleITK core libraries to be shared, a minor patch to the SimpleITK SWIG interface, and a little bit of CPython written to write for the extension.
>
> If anyone is interested in this approach  let me know and I can get the SimpleITK interface out there to be tested.
>
> Brad
>
_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.