From ee6fd999ae0ec7924512ebb574abfb88a20b16b9 Mon Sep 17 00:00:00 2001 From: Christina Rossmanith Date: Wed, 14 Sep 2016 15:40:57 +0200 Subject: [PATCH 1/3] variable name: segFile -> segFileName to have it consistent with inputFileName --- CCSeg/CCsegtool_initialization.cxx | 8 ++++---- CCSeg/CCsegtool_initialization.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CCSeg/CCsegtool_initialization.cxx b/CCSeg/CCsegtool_initialization.cxx index 5851ab0..70f889e 100644 --- a/CCSeg/CCsegtool_initialization.cxx +++ b/CCSeg/CCsegtool_initialization.cxx @@ -36,7 +36,7 @@ CCsegtool_initialization::CCsegtool_initialization(bool interpolationlinear, flo * Compute the initialization, transform the input image (3D to 2D) and * several other operation ( opening, rotation ....) ***************************************************************************/ -int CCsegtool_initialization::compute_initialization(std::string inputFileName,std::string segFile, bool vesselRemoveOn, +int CCsegtool_initialization::compute_initialization(std::string inputFileName,std::string segFileName, bool vesselRemoveOn, bool segLabel, int averageNum, bool permute_x_y, bool reflectXOn, bool reflectYOn, bool openOn, bool doubleOn, int sliceDir, std::string outfileBase, std::string nameofproject, std::string MidPlaneSliceNumber, bool othercompo, int angle, bool debug) @@ -49,7 +49,7 @@ int CCsegtool_initialization::compute_initialization(std::string inputFileName,s m_angle = angle; // load - loadinginputimage(inputFileName, segFile); + loadinginputimage(inputFileName, segFileName); //Vessel removal if(vesselRemoveOn) @@ -166,7 +166,7 @@ int CCsegtool_initialization::compute_initialization(std::string inputFileName,s /*************************************************************************** * Load the input and Mask image ***************************************************************************/ -void CCsegtool_initialization::loadinginputimage(std::string inputFileName, std::string segFile) +void CCsegtool_initialization::loadinginputimage(std::string inputFileName, std::string segFileName) { try { @@ -221,7 +221,7 @@ void CCsegtool_initialization::loadinginputimage(std::string inputFileName, std: { // load segmentation BinaryVolumeReaderType::Pointer binaryImageReader = BinaryVolumeReaderType::New(); - binaryImageReader->SetFileName(segFile.c_str()) ; + binaryImageReader->SetFileName(segFileName.c_str()) ; binaryImageReader->Update(); m_loadMask=binaryImageReader->GetOutput(); } diff --git a/CCSeg/CCsegtool_initialization.h b/CCSeg/CCsegtool_initialization.h index c0a7550..0c32161 100644 --- a/CCSeg/CCsegtool_initialization.h +++ b/CCSeg/CCsegtool_initialization.h @@ -127,7 +127,7 @@ class CCsegtool_initialization static const int LABEL_VALUE = 1; static const int NUM_COMPONENTS = 5; - int compute_initialization(std::string inputFileName, std::string segFile, bool vesselRemoveOn, + int compute_initialization(std::string inputFileName, std::string segFileName, bool vesselRemoveOn, bool segLabel, int averageNum, bool permute_x_y, bool reflectXOn, bool reflectYOn, bool openOn, bool doubleOn, int sliceDir, std::string outfilebase, std::string nameofproject, @@ -151,7 +151,7 @@ class CCsegtool_initialization ImagePointer Get3DImage(); protected: - void loadinginputimage(std::string inputFileName, std::string segFile); + void loadinginputimage(std::string inputFileName, std::string segFileName); void vesselremoval(bool segLabel); void extract_Midsagittal_planes(int sliceDir, std::string MidPlaneSliceNumber); void averaging(int averageNum, int sliceDir, std::string MidPlaneSliceNumber); From ef7a70db887657f29367d81766936a03b2e6fe07 Mon Sep 17 00:00:00 2001 From: Christina Rossmanith Date: Fri, 16 Sep 2016 13:44:48 +0200 Subject: [PATCH 2/3] added error handling if files with model data can't be read --- CCSeg/CCsegtool.cxx | 13 ++++++------ CCSeg/CCsegtool_parameters.cxx | 36 +++++++++++++++++++++++----------- CCSeg/CCsegtool_parameters.h | 8 ++++---- CCSeg/Globalfunc.cxx | 19 +++++++++++------- 4 files changed, 48 insertions(+), 28 deletions(-) diff --git a/CCSeg/CCsegtool.cxx b/CCSeg/CCsegtool.cxx index e0edd4b..12c45a6 100644 --- a/CCSeg/CCsegtool.cxx +++ b/CCSeg/CCsegtool.cxx @@ -54,12 +54,13 @@ int main(int argc, char *argv[]) /* Preview */ if(debug) std::cout<<"INITIALIZE"<GetImageSSize(); if(MidPlaneSliceNumber.compare("default")==0) numslice = (numslice-1)/2; - - CCsegtool_parameters* parameters = new CCsegtool_parameters(initialization->GetOutputImage(), CCAtlasDirectory, - initialization->Get3DImage(), permute_x_y, reflectXOn, reflectYOn, doubleOn, - sliceDir, numslice ,initialization->GetCenterX(),initialization->GetCenterY(), - initialization->GetRotation(),initialization->GetScale(), FSXForm, PSDistance, - WMvalue1,10,50,initialization->Get3DImageSize(), debug); - + CCsegtool_parameters* parameters; + try { + parameters = new CCsegtool_parameters(initialization->GetOutputImage(), CCAtlasDirectory, + initialization->Get3DImage(), permute_x_y, reflectXOn, reflectYOn, doubleOn, + sliceDir, numslice ,initialization->GetCenterX(),initialization->GetCenterY(), + initialization->GetRotation(),initialization->GetScale(), FSXForm, PSDistance, + WMvalue1,10,50,initialization->Get3DImageSize(), debug); + } + catch (std::exception &ex) { + std::cerr << ex.what() << std::endl; + return 0; + } // Save the value from the initialization in parameters parameters->SetGlobalvalue(initialization->GetWMvalue(), initialization->GetvoxelsizeX(), initialization->GetvoxelsizeY()); From 3173add93af9f6d8791db3d6b54488b1de292bc5 Mon Sep 17 00:00:00 2001 From: Christina Rossmanith Date: Wed, 21 Sep 2016 14:46:34 +0200 Subject: [PATCH 3/3] change segLabel's data type from boolean to int --- CCSeg/CCsegtool_initialization.cxx | 18 ++++++------------ CCSeg/CCsegtool_initialization.h | 9 ++++----- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/CCSeg/CCsegtool_initialization.cxx b/CCSeg/CCsegtool_initialization.cxx index 70f889e..51144e3 100644 --- a/CCSeg/CCsegtool_initialization.cxx +++ b/CCSeg/CCsegtool_initialization.cxx @@ -37,7 +37,7 @@ CCsegtool_initialization::CCsegtool_initialization(bool interpolationlinear, flo * several other operation ( opening, rotation ....) ***************************************************************************/ int CCsegtool_initialization::compute_initialization(std::string inputFileName,std::string segFileName, bool vesselRemoveOn, - bool segLabel, int averageNum, bool permute_x_y, bool reflectXOn, bool reflectYOn, bool openOn, + int segLabel, int averageNum, bool permute_x_y, bool reflectXOn, bool reflectYOn, bool openOn, bool doubleOn, int sliceDir, std::string outfileBase, std::string nameofproject, std::string MidPlaneSliceNumber, bool othercompo, int angle, bool debug) { @@ -235,7 +235,7 @@ void CCsegtool_initialization::loadinginputimage(std::string inputFileName, std: /*************************************************************************** * Do a vesselremoval ***************************************************************************/ -void CCsegtool_initialization::vesselremoval(bool segLabel) +void CCsegtool_initialization::vesselremoval(int segLabel) { try { @@ -253,13 +253,10 @@ void CCsegtool_initialization::vesselremoval(bool segLabel) try { //Vessel removal - int seglabel=1; - if(segLabel) - seglabel=0; VesselRemover::Pointer VesselFilter = VesselRemover::New(); VesselFilter->SetImage(m_loadImage); VesselFilter->SetEMSseg(m_castfilter->GetOutput()); - VesselFilter->SetWMlabel(seglabel); + VesselFilter->SetWMlabel(segLabel); VesselFilter->RemoveVessels(); m_preProcImage = VesselFilter->GetResultImage(); } @@ -506,17 +503,14 @@ void CCsegtool_initialization::reflectY() /*************************************************************************** * Extract the Label ***************************************************************************/ -void CCsegtool_initialization::extractLabel(bool segLabel) +void CCsegtool_initialization::extractLabel(int segLabel) { try { - int seglabel=1; - if(segLabel) - seglabel=0; m_threshFilter = BinaryThresholdFilterType::New(); m_threshFilter->SetInput(m_mask); - m_threshFilter->SetUpperThreshold(seglabel); - m_threshFilter->SetLowerThreshold(seglabel); + m_threshFilter->SetUpperThreshold(segLabel); + m_threshFilter->SetLowerThreshold(segLabel); m_threshFilter->SetOutsideValue(BG_VALUE); m_threshFilter->SetInsideValue(LABEL_VALUE); m_threshFilter->Update(); diff --git a/CCSeg/CCsegtool_initialization.h b/CCSeg/CCsegtool_initialization.h index 0c32161..a38a6e3 100644 --- a/CCSeg/CCsegtool_initialization.h +++ b/CCSeg/CCsegtool_initialization.h @@ -128,8 +128,8 @@ class CCsegtool_initialization static const int NUM_COMPONENTS = 5; int compute_initialization(std::string inputFileName, std::string segFileName, bool vesselRemoveOn, - bool segLabel, int averageNum, bool permute_x_y, bool reflectXOn, - bool reflectYOn, bool openOn, bool doubleOn, int sliceDir, + int segLabel, int averageNum, bool permute_x_y, bool reflectXOn, + bool reflectYOn, bool openOn, bool doubleOn, int sliceDir, std::string outfilebase, std::string nameofproject, std::string MidPlaneSliceNumber, bool othercompo, int angle, bool debug=false); void SetLambdaMax(int lambdaMax){m_LambdaMax=lambdaMax;} @@ -152,19 +152,18 @@ class CCsegtool_initialization protected: void loadinginputimage(std::string inputFileName, std::string segFileName); - void vesselremoval(bool segLabel); + void vesselremoval(int segLabel); void extract_Midsagittal_planes(int sliceDir, std::string MidPlaneSliceNumber); void averaging(int averageNum, int sliceDir, std::string MidPlaneSliceNumber); void dopermute_x_y(); void reflectX(); void reflectY(); - void extractLabel(bool segLabel); + void extractLabel(int segLabel); void closingop(); void dodoubleOn(); void writeInput(std::string outfilebase, std::string nameofproject); void writeoutput(std::string outfilebase, std::string nameofproject); - private: /** Use in compute_parameters **/ typedef itk::Image CCLOutputImageType;