-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from aghayoor/landmarksTransformation
ENH: A new program called "BRAINSConstellationLandmarksTransform" is added
- Loading branch information
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
BRAINSConstellationDetector/src/BRAINSConstellationLandmarksTransform.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Author: Ali Ghayoor | ||
* at Psychiatry Imaging Lab, | ||
* University of Iowa Health Care 2013 | ||
*/ | ||
|
||
/* | ||
This program program uses the input transform to propagate | ||
reference landmarks to the target landmark file. | ||
*/ | ||
|
||
#include "itkPoint.h" | ||
#include "itkTransformFileReader.h" | ||
#include "itkCompositeTransform.h" | ||
#include "Slicer3LandmarkIO.h" | ||
|
||
#include "BRAINSConstellationLandmarksTransformCLP.h" | ||
|
||
|
||
int main( int argc, char *argv[] ) | ||
{ | ||
PARSE_ARGS; | ||
|
||
if( inputLandmarksFile == "" | ||
|| inputTransformFile == "" | ||
|| outputLandmarksFile == "") | ||
{ | ||
std::cerr << "Input and output file names should be given by commandline. " << std::endl; | ||
std::cerr << "Usage:\n" | ||
<< "~/BRAINSConstellationLandmarksTransform\n" | ||
<< "--inputLandmarksFile (-i)\n" | ||
<< "--inputTransformFile (-t)\n" | ||
<< "--outputLandmarksFile (-o)" | ||
<< std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
const unsigned int Dimension = 3; | ||
|
||
typedef itk::Point<double,Dimension> PointType; | ||
typedef std::map< std::string, PointType > LandmarksMapType; | ||
|
||
LandmarksMapType origLandmarks = ReadSlicer3toITKLmk( inputLandmarksFile ); | ||
LandmarksMapType transformedLandmarks; | ||
|
||
typedef itk::TransformFileReader ReaderType; | ||
ReaderType::Pointer reader = ReaderType::New(); | ||
reader->SetFileName( inputTransformFile ); | ||
reader->Update(); | ||
|
||
ReaderType::TransformListType *transformList = reader->GetTransformList(); | ||
|
||
typedef itk::CompositeTransform<double, Dimension> CompositeTransformType; | ||
|
||
CompositeTransformType::Pointer inputCompTrans = | ||
dynamic_cast<CompositeTransformType *>( transformList->front().GetPointer() ); | ||
if( inputCompTrans.IsNull() ) | ||
{ | ||
std::cerr << "The input transform should be a composite transform." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
LandmarksMapType::const_iterator it = origLandmarks.begin(); | ||
for(; it!=origLandmarks.end(); it++) | ||
{ | ||
transformedLandmarks[it->first] = inputCompTrans->TransformPoint( it->second ); | ||
} | ||
|
||
WriteITKtoSlicer3Lmk( outputLandmarksFile, transformedLandmarks ); | ||
std::cout << "The transformed landmarks file is written." << std::endl; | ||
|
||
return EXIT_SUCCESS; | ||
} |
48 changes: 48 additions & 0 deletions
48
BRAINSConstellationDetector/src/BRAINSConstellationLandmarksTransform.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<executable> | ||
<category>Utilities.BRAINS</category> | ||
<title>Landmarks Transformation</title> | ||
<description> | ||
This program converts the original landmark file to the target landmark file using the input transform. | ||
</description> | ||
<version>1.0</version> | ||
<documentation-url> </documentation-url> | ||
<license> </license> | ||
<contributor>Ali Ghayoor</contributor> | ||
<acknowledgements> | ||
</acknowledgements> | ||
|
||
<parameters> | ||
<label>IO</label> | ||
<description>Input/output parameters</description> | ||
|
||
<file fileExtensions=".fcsv"> | ||
<name>inputLandmarksFile</name> | ||
<flag>i</flag> | ||
<longflag>inputLandmarksFile</longflag> | ||
<label>Input landmarks file</label> | ||
<channel>input</channel> | ||
<description>Input landmarks file (.fcsv)</description> | ||
</file> | ||
|
||
<transform fileExtensions=".h5,.hdf5"> | ||
<name>inputTransformFile</name> | ||
<flag>t</flag> | ||
<longflag>inputTransformFile</longflag> | ||
<label>Input transform file</label> | ||
<channel>input</channel> | ||
<description>input composite transform file (.h5,.hdf5)</description> | ||
</transform> | ||
|
||
<file fileExtensions=".fcsv"> | ||
<name>outputLandmarksFile</name> | ||
<flag>o</flag> | ||
<longflag>outputLandmarksFile</longflag> | ||
<label>Output landmarks file</label> | ||
<channel>output</channel> | ||
<description>Output landmarks file (.fcsv)</description> | ||
</file> | ||
|
||
</parameters> | ||
|
||
</executable> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters