<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif; "><div>Hi All,</div><div><br></div><div>I am trying to copy a displacement field transform returned by a SyN registration process at each iteration. I have used two ways for this purpose. </div><div><br></div><div>1)</div><div>* First I ask virtual image from metric:</div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><br></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">typename VirtualImageType::ConstPointer virtualDomainImage = inputMetric->GetVirtualImage();</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><br></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">* Then, I define my new transform having a zero displacement field.</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><br></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">typename DisplacementFieldTransformType::Pointer myTransform = DisplacementFieldTransformType::New();</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><br></p></p></div><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">const typename DisplacementFieldType::PixelType zeroVector( 0.0 );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "> </p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">typename DisplacementFieldType::Pointer DisplacementField = DisplacementFieldType::New();</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">DisplacementField->CopyInformation( virtualDomainImage );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">DisplacementField->SetRegions( virtualDomainImage->GetBufferedRegion() );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">DisplacementField->Allocate();</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">DisplacementField->FillBuffer( zeroVector );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "> </p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">typename DisplacementFieldType::Pointer InverseDisplacementField = DisplacementFieldType::New();</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">InverseDisplacementField->CopyInformation( virtualDomainImage );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">InverseDisplacementField->SetRegions( virtualDomainImage->GetBufferedRegion() );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">InverseDisplacementField->Allocate();</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">InverseDisplacementField->FillBuffer( zeroVector );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "> </p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">myTransform->SetDisplacementField( DisplacementField );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">myTransform->SetInverseDisplacementField( InverseDisplacementField );</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">* After that I set the parameters of the new transform from the old one:</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">typename TransformBaseType::ParametersType paras( inputTransform->GetParameters() );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">typename TransformBaseType::ParametersType fixed_paras( inputTransform->GetFixedParameters() );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">myTransform->SetParameters( paras );</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">myTransform->SetFixedParameters( fixed_paras );</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">2)</p><div>* In the second way I use an ImageDuplicator to copy the DisplacementField:</div><div><br></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">typedef itk::ImageDuplicator<DisplacementFieldType> DisplacementFieldDuplicatorType;</p></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">typename DisplacementFieldDuplicatorType::Pointer disDuplicator = DisplacementFieldDuplicatorType::New();</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">disDuplicator->SetInputImage( inputTransform->GetDisplacementField() );</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo">disDuplicator->Update();</p></div><div><br></div><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">typename DisplacementFieldDuplicatorType::Pointer disInverseDuplicator = DisplacementFieldDuplicatorType::New();</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">disInverseDuplicator->SetInputImage( inputTransform->GetInverseDisplacementField() );</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">disInverseDuplicator->Update();</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">myTransform->SetDisplacementField( disDuplicator->GetOutput()<span class="Apple-style-span"> );</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-style-span">myTransform->SetInverseDisplacementField( </span>disInverseDuplicator->GetOutput()<span class="Apple-style-span"> );</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-style-span"><br></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">-----------</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">However, non of above two methods do not return meaningful results.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">Does anybody know where I am wrong, and How can we copy a displacement field transform properly?</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">Thanks,</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">Ali</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(74, 130, 15); "><span class="Apple-style-span"><br></span></p></p></div></p></div></body></html>