[Insight-users] Incorrect deformation field using paraview

motes motes mort.motes at gmail.com
Tue Nov 3 10:46:13 EST 2009


And here is the code that I use to create the deformation field with:



  // Must use float for deformation fields.
  typedef itk::Point<float, Dimension>
                   PointType;
  typedef itk::Vector<float, Dimension>
                   VectorType;
  typedef itk::Image<VectorType, Dimension>
                   DeformationFieldType;
  typedef itk::ImageRegionIterator<DeformationFieldType>
                   FieldIterator;
  typedef itk::ImageFileWriter< DeformationFieldType>
                   FieldWriterType;



  void writeDeformationField(std::string filename){


    field->SetRegions( fixedRegion );
    field->SetOrigin( fixedOrigin );
    field->SetSpacing( fixedSpacing );
    field->SetDirection( fixedDirection );
    field->Allocate();
    FieldIterator fi( field, fixedRegion );
    fi.GoToBegin();
    TransformType::InputPointType  fixedPoint;
    TransformType::OutputPointType movingPoint;
    DeformationFieldType::IndexType index;
    VectorType displacement;
    while( ! fi.IsAtEnd() ) {
      index = fi.GetIndex();
      field->TransformIndexToPhysicalPoint( index, fixedPoint );
      movingPoint = bsplineTransform->TransformPoint( fixedPoint );
      displacement = movingPoint - fixedPoint;
      fi.Set( displacement );
      ++fi;
    }

    FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
    fieldWriter->SetInput(field);
    fieldWriter->SetFileName(output_path + filename);

    try {
      fieldWriter->Update();
    }
    catch( itk::ExceptionObject & excp ) {
      std::cerr << "Exception thrown " << std::endl;
      std::cerr << excp << std::endl;
    }
    std::cout << "Write deformation field to: " << output_path +
filename << std::endl;



  }

On Tue, Nov 3, 2009 at 4:24 PM, motes motes <mort.motes at gmail.com> wrote:
> Ah found it thanks! So now I do:
>
>      MetaImage_X*iHat+MetaImage_Y*jHat+0*kHat
>
> where   MetaImage_X and MetaImage_Y are selected from the scalars menu.
>
> Next I add a glyph filter, but when I press apply a empty 3D
> coordinate system appears - not a single deformation vector shows up -
> even though Max num of points = 5000.
>
> When I press the Information tab in the Glyph filter I can see that:
>
> Data Arrays:
>
> Name             Data Type      Data Ranges
> MetaImage      float              [-inf, -1e+38], [-inf, -1e+38]
> GlyphVector    float              [ 1e+38, -1e+38], [ 1e+38, -1e+38],
> [ 1e+38, -1e+38]
>
> Could this maybe have something to do with the lack of deformation vectors?
>
>
>
> On Tue, Nov 3, 2009 at 4:11 PM, Karthik Krishnan
> <karthik.krishnan at kitware.com> wrote:
>> On Tue, Nov 3, 2009 at 9:59 AM, motes motes <mort.motes at gmail.com> wrote:
>>>
>>> On Tue, Nov 3, 2009 at 3:40 PM, Karthik Krishnan
>>> <karthik.krishnan at kitware.com> wrote:
>>> > On Tue, Nov 3, 2009 at 9:33 AM, motes motes <mort.motes at gmail.com>
>>> > wrote:
>>> >>
>>> >> But when I view the .mhd file in paraview I just get:
>>> >>
>>> >> http://37133.vs.webtropia.com/apache2-default/test/test0.png
>>> >>
>>> >>
>>> >> In paraview I load the .mhd file. Then I add a calculator and type:
>>> >>
>>> >>      coordsX*iHat+coordsY*jHat+0*kHat
>>> >
>>> > It should read
>>> >
>>> > MetaImage_0*iHat + MetaImage_1*jHat +  0*kHat
>>> >
>>> > Choose MetaImage_* from the pull down menu on the calculator. You chose
>>> > coords (which are simply coordinates of the points, not the scalar
>>> > values of
>>> > the their components) which perfectly explains the image you see.
>>>
>>>
>>>
>>>
>>>
>>>
>>> Its not possible to choose MetaImage_* from any menus in the
>>> calculator.
>>
>> It is there in the the "Scalars" pull down  menu on the Calculator tab, not
>> in the attribute menu.
>>
>>>
>>> From the "attribute mode" drop down menu I can choose:
>>>
>>> Point data
>>> cell data
>>>
>>> If  I manullay type:
>>>
>>> MetaImage_0*iHat + MetaImage_1*jHat +  0*kHat
>>>
>>> into the expression editor and press apply I just get a bunch of error:
>>
>> Think its the spaces. In any case, use the menu and select what appears.
>>
>>
>>
>


More information about the Insight-users mailing list