Skip to content
Open
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
13 changes: 7 additions & 6 deletions CCSeg/CCsegtool.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ int main(int argc, char *argv[])
/* Preview */
if(debug)
std::cout<<"INITIALIZE"<<std::endl;
initialize(Image_filename, Mask_filename, CCAtlasDirectory, OuputFolder, nameofproject,
interpolationlinear, vesselRemoveOn, segLabel, averageNum, permute_x_y, reflectXOn,
reflectYOn, openOn, doubleOn, sliceDir, MidPlaneSliceNumber, Number_Pts,
FSXForm, PSDistance, Unconstrained, WMintensity, MPSDisplacement, Number_iteration,
Lambdamax, Coefofoptim, debug, false, ViewImage, parameters, &lastX, &lastY, &lastScale,
&lastRot,scalefactor, othercompo,addangle);
if (!initialize(Image_filename, Mask_filename, CCAtlasDirectory, OuputFolder, nameofproject,
interpolationlinear, vesselRemoveOn, segLabel, averageNum, permute_x_y, reflectXOn,
reflectYOn, openOn, doubleOn, sliceDir, MidPlaneSliceNumber, Number_Pts,
FSXForm, PSDistance, Unconstrained, WMintensity, MPSDisplacement, Number_iteration,
Lambdamax, Coefofoptim, debug, false, ViewImage, parameters, &lastX, &lastY, &lastScale,
&lastRot,scalefactor, othercompo,addangle))
return 0;

/* Run */
if(debug)
Expand Down
26 changes: 10 additions & 16 deletions CCSeg/CCsegtool_initialization.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ 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,
bool segLabel, int averageNum, bool permute_x_y, bool reflectXOn, bool reflectYOn, bool openOn,
int CCsegtool_initialization::compute_initialization(std::string inputFileName,std::string segFileName, bool vesselRemoveOn,
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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
}
Expand All @@ -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
{
Expand All @@ -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();
}
Expand Down Expand Up @@ -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();
Expand Down
13 changes: 6 additions & 7 deletions CCSeg/CCsegtool_initialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ 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,
bool segLabel, int averageNum, bool permute_x_y, bool reflectXOn,
bool reflectYOn, bool openOn, bool doubleOn, int sliceDir,
int compute_initialization(std::string inputFileName, std::string segFileName, bool vesselRemoveOn,
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;}
Expand All @@ -151,20 +151,19 @@ class CCsegtool_initialization
ImagePointer Get3DImage();

protected:
void loadinginputimage(std::string inputFileName, std::string segFile);
void vesselremoval(bool segLabel);
void loadinginputimage(std::string inputFileName, std::string segFileName);
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<short,ImageEDimension> CCLOutputImageType;
Expand Down
36 changes: 25 additions & 11 deletions CCSeg/CCsegtool_parameters.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ CCsegtool_parameters::CCsegtool_parameters (ExtractImageConstPointer Image, //fi
//load the Image
SetImage(Image);

//Each files have a number
//Each file has a number
//SSMean
readf4(Way,1);
if (!readf4(Way,1)) throw std::runtime_error("Could not read model file");
//Eigenvectors
readf4(Way,2);
if (!readf4(Way,2)) throw std::runtime_error("Could not read model file");
//Bounds
readf(Way,3);
if (!readf(Way,3)) throw std::runtime_error("Could not read model file");
//PMMean
readf(Way,4);
if (!readf(Way,4)) throw std::runtime_error("Could not read model file");
//PMSigmaInv
readf(Way,5);
if (!readf(Way,5)) throw std::runtime_error("Could not read model file");

if(debug)
{
Expand Down Expand Up @@ -95,9 +95,9 @@ CCsegtool_parameters::CCsegtool_parameters (ExtractImageConstPointer Image, //fi


/*********************************************************************************
* Fill a vector with the CC atlas directory
* Fill a vector with model data from the CC atlas directory
********************************************************************************/
void CCsegtool_parameters::readf(std::string way, int nbfile)
bool CCsegtool_parameters::readf(std::string way, int nbfile)
{
int i[3];
float j;
Expand All @@ -115,6 +115,9 @@ void CCsegtool_parameters::readf(std::string way, int nbfile)
case 5:
filename=way + "/Profile_sigmainv.asc";
break;
default:
cerr << "Error (readf): Wrong file number" << endl;
return false;
}

std::ifstream file(filename.c_str() , ios::in); // open in reading
Expand Down Expand Up @@ -164,16 +167,20 @@ void CCsegtool_parameters::readf(std::string way, int nbfile)
}

file.close();
return true;
}
else {
cerr << "Error: The opening of the file failed" << endl;
return false;
}
else cerr << "Error: The opening of the file failed" << endl;
}


/*********************************************************************************
* Fill a vector with the data of a file where there are 4 value on a line
* like in CC atlas directory
********************************************************************************/
void CCsegtool_parameters::readf4(std::string way, int nbfile)
bool CCsegtool_parameters::readf4(std::string way, int nbfile)
{
char c;
int i[2];
Expand All @@ -188,6 +195,9 @@ void CCsegtool_parameters::readf4(std::string way, int nbfile)
case 2:
filename = way + "/Shape_eigvecs.asc";
break;
default:
cerr << "Error (readf4): Wrong file number" << endl;
return false;
}

std::ifstream file(filename.c_str() , ios::in); // open in reading
Expand Down Expand Up @@ -228,9 +238,13 @@ void CCsegtool_parameters::readf4(std::string way, int nbfile)
}

file.close();
return true;
}

else cerr << "Error: The opening of the file failed" << endl;
else {
cerr << "Error: The opening of the file failed" << endl;
return false;
}
}


Expand Down
8 changes: 4 additions & 4 deletions CCSeg/CCsegtool_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class CCsegtool_parameters
int numSlice, int X, int Y,float Rotation, float Scale, bool FSXForm,
double PSDistance, int WMIntensity,int MPSDisplacement, int OSteps,
SizeType ImageSize, bool Debug=false);
//to accede to the private attributs
//Methods for Parameter Specifications
void readf(std::string way, int nbfile);
void readf4(std::string way, int nbfile);
//to access the private attributes
//Methods for parameter specifications
bool readf(std::string way, int nbfile);
bool readf4(std::string way, int nbfile);
void getsizeof(int *i, int nbfile);
void writeoutput(std::string path_output, std::string _nameofproject);
void setparam(double X, double Y, double Scale, double Rot);
Expand Down
19 changes: 12 additions & 7 deletions CCSeg/Globalfunc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,18 @@ int initialize( std::string Image_filename, std::string Seg_filename, std::strin
int numslice = initialization->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());
Expand Down