Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: A new program called "BRAINSConstellationLandmarksTransform" is added #61

Merged
merged 2 commits into from
Sep 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
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>
1 change: 1 addition & 0 deletions BRAINSConstellationDetector/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set(ALL_PROGS_LIST
landmarksConstellationAligner
landmarksConstellationWeights
BinaryMaskEditorBasedOnLandmarks
BRAINSConstellationLandmarksTransform
)
foreach(prog ${ALL_PROGS_LIST})
StandardBRAINSBuildMacro(NAME ${prog} TARGET_LIBRARIES landmarksConstellationCOMMONLIB )
Expand Down
16 changes: 8 additions & 8 deletions DWIConvert/SiemensDWIConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,19 @@ class SiemensDWIConverter : public DWIConverter
void DeMosaic()
{
// de-mosaic
this->m_Rows /= this->m_MMosaic;
this->m_Cols /= this->m_NMosaic;
this->m_Cols /= this->m_MMosaic;
this->m_Rows /= this->m_NMosaic;

// center the volume since the image position patient given in the
// dicom header was useless
this->m_Origin[0] = -(this->m_Rows * (this->m_NRRDSpaceDirection[0][0])
+ this->m_Cols * (this->m_NRRDSpaceDirection[0][1])
this->m_Origin[0] = -(this->m_Cols * (this->m_NRRDSpaceDirection[0][0])
+ this->m_Rows * (this->m_NRRDSpaceDirection[0][1])
+ this->m_SlicesPerVolume * (this->m_NRRDSpaceDirection[0][2]) ) / 2.0;
this->m_Origin[1] = -(this->m_Rows * (this->m_NRRDSpaceDirection[1][0])
+ this->m_Cols * (this->m_NRRDSpaceDirection[1][1])
this->m_Origin[1] = -(this->m_Cols * (this->m_NRRDSpaceDirection[1][0])
+ this->m_Rows * (this->m_NRRDSpaceDirection[1][1])
+ this->m_SlicesPerVolume * (this->m_NRRDSpaceDirection[1][2]) ) / 2.0;
this->m_Origin[2] = -(this->m_Rows * (this->m_NRRDSpaceDirection[2][0])
+ this->m_Cols * (this->m_NRRDSpaceDirection[2][1])
this->m_Origin[2] = -(this->m_Cols * (this->m_NRRDSpaceDirection[2][0])
+ this->m_Rows * (this->m_NRRDSpaceDirection[2][1])
+ this->m_SlicesPerVolume * (this->m_NRRDSpaceDirection[2][2]) ) / 2.0;

VolumeType::Pointer img = this->m_Volume;
Expand Down