Commit f34a8cee authored by Cyril Poupon's avatar Cyril Poupon
Browse files

bug fix in DwiResampling3d

parent c7e6d7f0
......@@ -4,7 +4,6 @@
#include <gkg-processing-resampling/ResamplerFactory.h>
#include <gkg-processing-resampling/SplineResampler.h>
#include <gkg-processing-transform/RigidTransform3d.h>
#include <gkg-processing-transform/AffineWoShearingTransform3d.h>
#include <gkg-processing-transform/AffineTransform3d.h>
#include <gkg-core-io/TypeOf.h>
#include <gkg-processing-process/Process.h>
......@@ -390,6 +389,7 @@ void DwiResamplingProcess::resample( gkg::Process& process,
}
gkg::Transform3d< double >* transform3d = 0;
std::string foundTransformText = "undefined transform type";
try
{
......@@ -399,24 +399,13 @@ void DwiResamplingProcess::resample( gkg::Process& process,
rigidTransform3d->readTrm( is );
is.close();
transform3d = rigidTransform3d;
foundTransformText = "rigid transformation detected";
}
catch ( std::exception& )
{
try
{
gkg::AffineWoShearingTransform3d< double >*
affineWoShearingTransform3d =
new gkg::AffineWoShearingTransform3d< double >;
std::ifstream is( dwiResamplingProcess.getFileNameTransform().c_str() );
affineWoShearingTransform3d->readTrm( is );
is.close();
transform3d = affineWoShearingTransform3d;
}
catch ( std::exception& )
{
gkg::AffineTransform3d< double >*
......@@ -426,6 +415,14 @@ void DwiResamplingProcess::resample( gkg::Process& process,
affineTransform3d->readTrm( is );
is.close();
transform3d = affineTransform3d;
foundTransformText = "affine transformation detected";
}
catch ( std::exception& )
{
throw std::runtime_error(
"unable to find an adequate linear transform" );
}
......@@ -434,6 +431,7 @@ void DwiResamplingProcess::resample( gkg::Process& process,
{
std::cout << "done" << std::endl;
std::cout << foundTransformText << std::endl;
}
......@@ -566,21 +564,6 @@ void DwiResamplingProcess::resample( gkg::Process& process,
angles.y = ( float )parameters[ 1 ];
angles.z = ( float )parameters[ 2 ];
}
else if ( dynamic_cast< gkg::AffineWoShearingTransform3d< double >* >(
transform3d ) )
{
gkg::AffineWoShearingTransform3d< double >*
affineWoShearingTransform3d =
dynamic_cast< gkg::AffineWoShearingTransform3d< double >* >(
transform3d );
std::vector< double > parameters( 9U );
affineWoShearingTransform3d->getDirectParameters( parameters );
angles.x = ( float )parameters[ 0 ];
angles.y = ( float )parameters[ 1 ];
angles.z = ( float )parameters[ 2 ];
}
else if ( dynamic_cast< gkg::AffineTransform3d< double >* >(
transform3d ) )
......@@ -591,9 +574,9 @@ void DwiResamplingProcess::resample( gkg::Process& process,
dynamic_cast< gkg::AffineTransform3d< double >* >( transform3d );
std::vector< double > parameters( 12U );
affineTransform3d->getDirectParameters( parameters );
angles.x = ( float )parameters[ 0 ];
angles.y = ( float )parameters[ 1 ];
angles.z = ( float )parameters[ 2 ];
angles.x = ( float )parameters[ 6 ];
angles.y = ( float )parameters[ 7 ];
angles.z = ( float )parameters[ 8 ];
}
......
......@@ -495,7 +495,7 @@ if ( ( options.transformationType == 'affine_and_diffeomorphic' ) or
# converting NIFTI direct diffeomorphism to GIS
fileNameDirectNiiDiffeomorphism = fileNameAntsTransform + \
'1InverseWarp.nii.gz'
'1Warp.nii.gz'
fileNameDirectImaDiffeomorphism = os.path.join( intermediateDirectory,
'diffeomorphism_direct.ima')
gkg.executeCommand( { 'algorithm' : 'Nifti2GisConverter',
......@@ -510,7 +510,8 @@ if ( ( options.transformationType == 'affine_and_diffeomorphic' ) or
# converting NIFTI iinverse diffeomorphism to GIS
fileNameInverseNiiDiffeomorphism = fileNameAntsTransform + '1Warp.nii.gz'
fileNameInverseNiiDiffeomorphism = fileNameAntsTransform + \
'1InverseWarp.nii.gz'
fileNameInverseImaDiffeomorphism = os.path.join( intermediateDirectory,
'diffeomorphism_inverse.ima' )
gkg.executeCommand( { 'algorithm' : 'Nifti2GisConverter',
......
......@@ -4,7 +4,6 @@
#include <gkg-processing-resampling/ResamplerFactory.h>
#include <gkg-processing-resampling/SplineResampler.h>
#include <gkg-processing-transform/RigidTransform3d.h>
#include <gkg-processing-transform/AffineWoShearingTransform3d.h>
#include <gkg-processing-transform/AffineTransform3d.h>
#include <gkg-processing-transform/NonLinearTransform3d.h>
#include <gkg-core-io/TypeOf.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment