1 #include "bbSlicerGeneralRegistrationBRAINS.h"
2 #include "bbSlicerPackage.h"
5 BBTK_ADD_BLACK_BOX_TO_PACKAGE ( Slicer, GeneralRegistrationBRAINS )
6 BBTK_BLACK_BOX_IMPLEMENTATION ( GeneralRegistrationBRAINS, bbtk::AtomicBlackBox );
8 void GeneralRegistrationBRAINS::Process ( ) {
13 std::string lib = "/home/riveros/.slicer/Slicer4-bin/Slicer-build/lib/Slicer-4.0/cli-modules/libBRAINSFitLib.so";
14 char * _argv[ ] = { Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--fixedVolume" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputfixedVolume( ) ) ) ,"@@@@@"," --fixedVolume ") ),
15 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--movingVolume" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputmovingVolume( ) ) ) ,"@@@@@"," --movingVolume ") ),
16 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--bsplineTransform" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputbsplineTransform( ) ) ) ,"@@@@@"," --bsplineTransform ") ),
17 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--linearTransform" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputlinearTransform( ) ) ) ,"@@@@@"," --linearTransform ") ),
18 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--outputVolume" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputoutputVolume( ) ) ) ,"@@@@@"," --outputVolume ") ),
19 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--initialTransform" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputinitialTransform( ) ) ) ,"@@@@@"," --initialTransform ") ),
20 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--initializeTransformMode" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputinitializeTransformMode( ) ) ) ,"@@@@@"," --initializeTransformMode ") ),
21 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--useRigid" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseRigid( ) ) ) ,"@@@@@"," --useRigid ") ),
22 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--useScaleVersor3D" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseScaleVersor3D( ) ) ) ,"@@@@@"," --useScaleVersor3D ") ),
23 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--useScaleSkewVersor3D" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseScaleSkewVersor3D( ) ) ) ,"@@@@@"," --useScaleSkewVersor3D ") ),
24 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--useAffine" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseAffine( ) ) ) ,"@@@@@"," --useAffine ") ),
25 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--useBSpline" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseBSpline( ) ) ) ,"@@@@@"," --useBSpline ") ),
26 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--numberOfSamples" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputnumberOfSamples( ) ) ) ,"@@@@@"," --numberOfSamples ") ),
27 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--splineGridSize" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputsplineGridSize( ) ) ) ,"@@@@@"," --splineGridSize ") ),
28 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--numberOfIterations" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputnumberOfIterations( ) ) ) ,"@@@@@"," --numberOfIterations ") ),
29 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--maskProcessingMode" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputmaskProcessingMode( ) ) ) ,"@@@@@"," --maskProcessingMode ") ),
30 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--fixedBinaryVolume" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputfixedBinaryVolume( ) ) ) ,"@@@@@"," --fixedBinaryVolume ") ),
31 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--movingBinaryVolume" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputmovingBinaryVolume( ) ) ) ,"@@@@@"," --movingBinaryVolume ") ),
32 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--outputFixedVolumeROI" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputoutputFixedVolumeROI( ) ) ) ,"@@@@@"," --outputFixedVolumeROI ") ),
33 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--outputMovingVolumeROI" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputoutputMovingVolumeROI( ) ) ) ,"@@@@@"," --outputMovingVolumeROI ") ),
34 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--outputVolumePixelType" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputoutputVolumePixelType( ) ) ) ,"@@@@@"," --outputVolumePixelType ") ),
35 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--backgroundFillValue" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputbackgroundFillValue( ) ) ) ,"@@@@@"," --backgroundFillValue ") ),
36 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--maskInferiorCutOffFromCenter" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputmaskInferiorCutOffFromCenter( ) ) ) ,"@@@@@"," --maskInferiorCutOffFromCenter ") ),
37 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--scaleOutputValues" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputscaleOutputValues( ) ) ) ,"@@@@@"," --scaleOutputValues ") ),
38 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--interpolationMode" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputinterpolationMode( ) ) ) ,"@@@@@"," --interpolationMode ") ),
39 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--minimumStepLength" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputminimumStepLength( ) ) ) ,"@@@@@"," --minimumStepLength ") ),
40 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--translationScale" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputtranslationScale( ) ) ) ,"@@@@@"," --translationScale ") ),
41 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--reproportionScale" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputreproportionScale( ) ) ) ,"@@@@@"," --reproportionScale ") ),
42 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--skewScale" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputskewScale( ) ) ) ,"@@@@@"," --skewScale ") ),
43 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--maxBSplineDisplacement" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputmaxBSplineDisplacement( ) ) ) ,"@@@@@"," --maxBSplineDisplacement ") ),
44 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "-e" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputhistogramMatch( ) ) ) ,"@@@@@"," -e ") ),
45 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--numberOfHistogramBins" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputnumberOfHistogramBins( ) ) ) ,"@@@@@"," --numberOfHistogramBins ") ),
46 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--numberOfMatchPoints" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputnumberOfMatchPoints( ) ) ) ,"@@@@@"," --numberOfMatchPoints ") ),
47 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--strippedOutputTransform" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputstrippedOutputTransform( ) ) ) ,"@@@@@"," --strippedOutputTransform ") ),
48 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--transformType" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputtransformType( ) ) ) ,"@@@@@"," --transformType ") ),
49 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--outputTransform" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputoutputTransform( ) ) ) ,"@@@@@"," --outputTransform ") ),
50 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--fixedVolumeTimeIndex" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputfixedVolumeTimeIndex( ) ) ) ,"@@@@@"," --fixedVolumeTimeIndex ") ),
51 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--movingVolumeTimeIndex" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputmovingVolumeTimeIndex( ) ) ) ,"@@@@@"," --movingVolumeTimeIndex ") ),
52 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--medianFilterSize" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputmedianFilterSize( ) ) ) ,"@@@@@"," --medianFilterSize ") ),
53 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--removeIntensityOutliers" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputremoveIntensityOutliers( ) ) ) ,"@@@@@"," --removeIntensityOutliers ") ),
54 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--useCachingOfBSplineWeightsMode" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseCachingOfBSplineWeightsMode( ) ) ) ,"@@@@@"," --useCachingOfBSplineWeightsMode ") ),
55 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--useExplicitPDFDerivativesMode" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseExplicitPDFDerivativesMode( ) ) ) ,"@@@@@"," --useExplicitPDFDerivativesMode ") ),
56 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--ROIAutoDilateSize" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputROIAutoDilateSize( ) ) ) ,"@@@@@"," --ROIAutoDilateSize ") ),
57 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--ROIAutoClosingSize" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputROIAutoClosingSize( ) ) ) ,"@@@@@"," --ROIAutoClosingSize ") ),
58 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--relaxationFactor" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputrelaxationFactor( ) ) ) ,"@@@@@"," --relaxationFactor ") ),
59 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--maximumStepLength" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputmaximumStepLength( ) ) ) ,"@@@@@"," --maximumStepLength ") ),
60 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--failureExitCode" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputfailureExitCode( ) ) ) ,"@@@@@"," --failureExitCode ") ),
61 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--writeTransformOnFailure" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputwriteTransformOnFailure( ) ) ) ,"@@@@@"," --writeTransformOnFailure ") ),
62 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--numberOfThreads" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputnumberOfThreads( ) ) ) ,"@@@@@"," --numberOfThreads ") ),
63 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--forceMINumberOfThreads" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputforceMINumberOfThreads( ) ) ) ,"@@@@@"," --forceMINumberOfThreads ") ),
64 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--debugLevel" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputdebugLevel( ) ) ) ,"@@@@@"," --debugLevel ") ),
65 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--costFunctionConvergenceFactor" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputcostFunctionConvergenceFactor( ) ) ) ,"@@@@@"," --costFunctionConvergenceFactor ") ),
66 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--projectedGradientTolerance" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputprojectedGradientTolerance( ) ) ) ,"@@@@@"," --projectedGradientTolerance ") ),
67 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "-G" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputUseDebugImageViewer( ) ) ) ,"@@@@@"," -G ") ),
68 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "-p" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputPromptAfterImageSend( ) ) ) ,"@@@@@"," -p ") ),
69 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--NEVER_USE_THIS_FLAG_IT_IS_OUTDATED_00" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseMomentsAlign( ) ) ) ,"@@@@@"," --NEVER_USE_THIS_FLAG_IT_IS_OUTDATED_00 ") ),
70 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--NEVER_USE_THIS_FLAG_IT_IS_OUTDATED_01" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseGeometryAlign( ) ) ) ,"@@@@@"," --NEVER_USE_THIS_FLAG_IT_IS_OUTDATED_01 ") ),
71 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--NEVER_USE_THIS_FLAG_IT_IS_OUTDATED_02" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputuseCenterOfHeadAlign( ) ) ) ,"@@@@@"," --NEVER_USE_THIS_FLAG_IT_IS_OUTDATED_02 ") ),
72 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--permitParameterVariation" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputpermitParameterVariation( ) ) ) ,"@@@@@"," --permitParameterVariation ") ),
73 Mthd::Aux::toCharArrray( Mthd::Aux::toString( "--costMetric" ) + Mthd::Aux::replace_str ( ( Mthd::Aux::toString( bbGetInputcostMetric( ) ) ) ,"@@@@@"," --costMetric ") ) };
76 this->execute( lib, _argc, _argv );
80 void GeneralRegistrationBRAINS::execute ( std::string lib, int _argc, char * _argv[] ) {
81 void* handle = dlopen( lib.c_str( ), RTLD_NOW | RTLD_GLOBAL );
83 std::cerr << "CAN'T OPEN LIBRARY: " << dlerror( ) << '\n';
86 typedef int (*method_t )( int argc, char * argv[] );
90 method_t myMethod = ( method_t ) dlsym( handle, "ModuleEntryPoint" );
91 const char *dlsym_error = dlerror( );
93 std::cerr << "CAN'T LOAD SYMBOL 'ModuleEntryPoint':" << dlsym_error << '\n';
98 myMethod( _argc, _argv );
103 void GeneralRegistrationBRAINS::bbUserSetDefaultValues ( ) {
106 void GeneralRegistrationBRAINS::bbUserInitializeProcessing ( ) {
109 void GeneralRegistrationBRAINS::bbUserFinalizeProcessing ( ) {
112 // EO namespace bbSlicer