[ITK-users] [ITK] cannot save transform to file: Can't Create IO object

Andras Lasso lasso at queensu.ca
Thu May 26 12:36:44 EDT 2016


You can have a look at the workaround that has been implemented in 3D Slicer:
https://github.com/Slicer/Slicer/commit/12743c6fcebb67ff9b22319cbe52a322a3738134

Some more background information:
http://slicer-devel.65872.n3.nabble.com/Empty-deformable-transforms-with-Mac-build-td4036248.html

I think it's unacceptable in the long term that dynamic_cast is broken for ITK transform objects but at least we have a workaround for now. It would be nice if somebody could implement a proper solution.

Andras

-----Original Message-----
From: Community [mailto:community-bounces at itk.org] On Behalf Of Lowekamp, Bradley (NIH/NLM/LHC) [C]
Sent: May 26, 2016 8:32 AM
To: Sebastian Ordas <sebastian.ordas at gmail.com>
Cc: insight-users at itk.org
Subject: Re: [ITK] [ITK-users] cannot save transform to file: Can't Create IO object

Hello,

That branch makes some improvements, but there really does need a redesign of a few key initializations and shared library policies to work correctly.

Brad

> On May 25, 2016, at 6:38 PM, Sebastian Ordas <sebastian.ordas at gmail.com> wrote:
> 
> Yes, this is within a plugin in a very complex framework (MITK)
> 
> I will try to use that ITK branch but will take some time. Before that, I will try to do the save/load functionality from a MITK module.
> 
> Anyway, I will share your hint with the MITK team and come back to the 
> ITK list
> 
> thank you,
> 
> sebastian
> 
> 
> On 25/05/2016 12:38 a.m., Matt McCormick wrote:
>> Hi Sebastian,
>> 
>> Is this in a plugin? There are significant issues when dealing with 
>> dynamic_cast's of the templates in plugins.
>> 
>> Does building against ITK with this branch checked out help?:
>> 
>>   http://review.source.kitware.com/#/c/21102
>> 
>> Thanks,
>> Matt
>> 
>> On Mon, May 23, 2016 at 8:42 PM, Sebastian Ordas 
>> <sebastian.ordas at gmail.com> wrote:
>>> Thanks Matt,
>>> 
>>> The retrieved transformIO is null
>>> 
>>> I looked into my ITK 4.9 build and I am trying something like this:
>>> 
>>> itk::TransformFileWriterTemplate<double>::Pointer writer =
>>>     itk::TransformFileWriterTemplate<double>::New();
>>> 
>>> // are .tfm and .txt the right file extensions?
>>> 
>>> itk::TransformIOFactoryTemplate<double>::TransformIOBasePointer 
>>> tranformIO = 
>>> itk::TransformIOFactoryTemplate<double>::CreateTransformIO(
>>> "fiducials_transform.tfm", 
>>> itk::TransformIOFactoryFileModeType::WriteMode );
>>> 
>>>   if (tranformIO.IsNull())
>>>   {
>>>     MITK_ERROR << "transform IO is null";
>>>     return;
>>>   }
>>> 
>>> writer->SetTransformIO(tranformIO);
>>> 
>>> writer->SetFileName("fiducials_transform.tfm");
>>> 
>>> writer->SetInput(transform);
>>> 
>>> try
>>>   {
>>>     writer->Update();
>>>   }
>>>   catch (itk::ExceptionObject& e)
>>>   {
>>>     MITK_ERROR << "Caught exception: " << e.GetDescription();
>>>     QMessageBox::information( this, "Save transform", "Could not 
>>> save transform. See error log for details." );
>>>   }
>>> 
>>> thank you
>>> sebastian
>>> 
>>> 
>>> On 23/05/2016 05:35 p.m., Matt McCormick wrote:
>>>> Hello Sebastian,
>>>> 
>>>> By running against ITK with this patch checked out:
>>>> 
>>>>    http://review.source.kitware.com/#/c/21115/
>>>> 
>>>> the error message will state what transform IO classes are registered.
>>>> 
>>>> HTH,
>>>> Matt
>>>> 
>>>> On Mon, May 23, 2016 at 4:29 PM, Sebastian Ordas 
>>>> <sebastian.ordas at gmail.com> wrote:
>>>>> Hello, I am trying to run the code bellow from my application 
>>>>> (using ITK
>>>>> 4.9)  but I get the following error :
>>>>> 
>>>>> ERROR: Caught exception: itk::ERROR:
>>>>> TransformFileWriterTemplate(000000000CD770E0): Can't Create IO 
>>>>> object for file test.tfm
>>>>> 
>>>>> I am sure that if I test it from a simple test application this 
>>>>> should work, but I am trying to understand what I am missing from 
>>>>> within my project (maybe some factory not yet registered or even 
>>>>> some registration-related module not yet enabled in cmake?)
>>>>> 
>>>>> typedef itk::VersorRigid3DTransform< double > TransformType; 
>>>>> TransformType::Pointer trf = TransformType::New();
>>>>> trf->SetIdentity();
>>>>> 
>>>>> itk::TransformFileWriterTemplate<double>::Pointer writer =
>>>>>      itk::TransformFileWriterTemplate<double>::New();
>>>>> 
>>>>>    writer->SetFileName("test.tfm");
>>>>>    writer->SetInput(trf);
>>>>> 
>>>>>    try
>>>>>    {
>>>>>      writer->Update();
>>>>>    }
>>>>>    catch (itk::ExceptionObject& e)
>>>>>    {
>>>>>      std::cerr << "Caught exception: " << e.GetDescription() << 
>>>>> std::endl;
>>>>>    }
>>>>> 
>>>>> 
>>>>> _____________________________________
>>>>> 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://public.kitware.com/mailman/listinfo/insight-users
>>>>> 
>>> _____________________________________
>>> 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://public.kitware.com/mailman/listinfo/insight-users
> 
> _____________________________________
> 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://public.kitware.com/mailman/listinfo/insight-users

_____________________________________
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://public.kitware.com/mailman/listinfo/insight-users
_______________________________________________
Community mailing list
Community at itk.org
http://public.kitware.com/mailman/listinfo/community


More information about the Insight-users mailing list