TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES} )
SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINKER_LANGUAGE C)
+ install(TARGETS ${LIBRARY_NAME} DESTINATION lib)
+ install(FILES ${LIBRARY_NAME_HEADERS} DESTINATION include)
#
#----------------------------------------------------------------------------
idx = 0;
char buffer[6];
- int n = 0;
+ // int n = 0; // used to debug sprintf : n = sprintf( ...
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 6 ) n=sprintf (buffer, "%05d", i + stmsParameters->startTimePoint - 1);
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 5 ) n=sprintf (buffer, "%04d", i + stmsParameters->startTimePoint - 1);
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 4 ) n=sprintf (buffer, "%03d", i + stmsParameters->startTimePoint - 1);
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 3 ) n=sprintf (buffer, "%02d", i + stmsParameters->startTimePoint - 1);
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 2 ) n=sprintf (buffer, "%01d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 6 ) sprintf (buffer, "%05d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 5 ) sprintf (buffer, "%04d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 4 ) sprintf (buffer, "%03d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 3 ) sprintf (buffer, "%02d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 2 ) sprintf (buffer, "%01d", i + stmsParameters->startTimePoint - 1);
std::string imagePath = expDescription->experimentPath+expDescription->inputFolder+expDescription->inputCommonRoot+buffer+expDescription->imageExtension;
- ImagePointer image
- = ImageType::New();
- ReaderPointer reader
- = itk::ImageFileReader< ImageType >::New();
+ ImagePointer image = ImageType::New();
+ ReaderPointer reader = itk::ImageFileReader< ImageType >::New();
reader->SetFileName( imagePath );
reader->Update();
namespace itkSTMS
{
- template < class ImageType, class ClassImageType >
+ template < class ImageType, class ClassImageType, class OutputImageType=ImageType>
class itkSTMS_TemporalSetToImageSequence
{
public:
// Reader and writer typedefs
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef typename ReaderType::Pointer ReaderPointer;
- typedef itk::ImageFileWriter< ImageType > WriterType;
+ typedef itk::ImageFileWriter< OutputImageType > WriterType;
typedef typename WriterType::Pointer WriterPointer;
typedef itk::ImageFileWriter< ClassImageType > ClassWriterType;
typedef typename ClassWriterType::Pointer ClassWriterPointer;
namespace itkSTMS
{
-template < class ImageType, class ClassImageType >
-itkSTMS_TemporalSetToImageSequence < ImageType, ClassImageType >
+template < class ImageType, class ClassImageType, class OutputImageType>
+itkSTMS_TemporalSetToImageSequence < ImageType, ClassImageType, OutputImageType >
::itkSTMS_TemporalSetToImageSequence( IndexSampleSetType* cl, SpatialSampleSetType* sp, RangeSampleSetType* ra,
itkSTMS::ParamsAnalysisOutputType* params, itkSTMS::ParserOutputType* desc )
{
}
-template < class ImageType, class ClassImageType >
+template < class ImageType, class ClassImageType, class OutputImageType >
void
-itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType >
+itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType, OutputImageType >
::GenerateImageSequence()
{
bool first = true;
std::string outputPath, classPath;
- ClassImagePointer classImage
- = ClassImageType::New();
-
+ ClassImagePointer classImage = ClassImageType::New();
classImage->SetRegions( classRegion );
classImage->Allocate();
classImage->FillBuffer( 15.0 );
"_Y-"+std::to_string((unsigned int)stmsParameters->spScales[1])+
"_Z-"+std::to_string((unsigned int)stmsParameters->spScales[2])+
"_R-"+std::to_string(stmsParameters->rScale)+
- expDescription->outputImageExtension;
+ expDescription->outputClassExtension;
- ClassWriterPointer classWriter
- = ClassWriterType::New();
+ ClassWriterPointer classWriter = ClassWriterType::New();
classWriter->SetFileName( classPath );
// Filetered image sequence and class image saving
for( unsigned int i=1 ; i<=stmsParameters->numTimePoints - stmsParameters->startTimePoint + 1; ++i )
{
char buffer[6];
- int n;
+ // int n;
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 6 ) n=sprintf (buffer, "%05d", i + stmsParameters->startTimePoint - 1);
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 5 ) n=sprintf (buffer, "%04d", i + stmsParameters->startTimePoint - 1);
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 4 ) n=sprintf (buffer, "%03d", i + stmsParameters->startTimePoint - 1);
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 3 ) n=sprintf (buffer, "%02d", i + stmsParameters->startTimePoint - 1);
- if( sizeof(STMS_NUMBERING_FORM_ONE) == 2 ) n=sprintf (buffer, "%01d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 6 ) sprintf( buffer, "%05d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 5 ) sprintf( buffer, "%04d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 4 ) sprintf( buffer, "%03d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 3 ) sprintf( buffer, "%02d", i + stmsParameters->startTimePoint - 1);
+ if( sizeof(STMS_NUMBERING_FORM_ONE) == 2 ) sprintf( buffer, "%01d", i + stmsParameters->startTimePoint - 1);
outputPath = expDescription->experimentPath+expDescription->outputFolder+
expDescription->outputCommonRoot+
"_R-"+std::to_string(stmsParameters->rScale)+"_"+
buffer+expDescription->outputImageExtension;
- ImagePointer outImage
- = ImageType::New();
+
+ typename OutputImageType::Pointer outImage = OutputImageType::New();
outImage->SetRegions( region );
outImage->Allocate();
- outImage->FillBuffer( 15.0 );
+ outImage->FillBuffer( 0 );
- WriterPointer writer
- = WriterType::New();
+ WriterPointer writer = WriterType::New();
writer->SetFileName( outputPath );
//#pragma omp parrallel for ...
classIndex[k] = outIndex[k];
}
- outImage->SetPixel( outIndex, rangeSet->at( classSet->at(j)-1 )[i-1]*stmsParameters->rScale );
+ outImage->SetPixel( outIndex, static_cast<typename OutputImageType::PixelType>(rangeSet->at( classSet->at(j)-1 )[i-1]*stmsParameters->rScale) );
if( first )
classImage->SetPixel(classIndex, classSet->at(j));
}
-template < class ImageType, class ClassImageType>
+template < class ImageType, class ClassImageType, class OutputImageType>
void
-itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType >
+itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType, OutputImageType>
::GenerateCSVFile(const std::string &delimiter)
{
std::string CSVFilename = expDescription->experimentPath+expDescription->outputFolder+
"_Z-"+std::to_string((unsigned int)stmsParameters->spScales[2])+
"_R-"+std::to_string(stmsParameters->rScale)+".csv";
- std::cout << "Writing CSV File (classID, nb of pixels, values of time serie), : " << CSVFilename << std::endl;
+ std::cout << "Writing CSV File (classID, nb of pixels, values of time serie) : " << CSVFilename << std::endl;
std::ofstream ofs;
ofs.open (CSVFilename.c_str(), std::ofstream::out | std::ofstream::trunc);
for(unsigned int j=0 ; j<rangeSet->size() ; ++j)
{
ofs << j+1 << delimiter << std::count (classSet->begin(), classSet->end(), j+1);
+ ofs << delimiter << stmsParameters->startTimePoint << delimiter << stmsParameters->numTimePoints;
for( unsigned int i=1 ; i<=stmsParameters->numTimePoints - stmsParameters->startTimePoint + 1; ++i )
ofs << delimiter << rangeSet->at(j)[i-1]*stmsParameters->rScale ;
ofs << std::endl;
std::string experimentPath;
std::string imageExtension;
std::string outputImageExtension;
+ std::string outputClassExtension;
std::string inputCommonRoot;
std::string inputFolder;
std::string maskImage;
xmlParams.experimentPath = "";
xmlParams.imageExtension = "";
xmlParams.outputImageExtension = "";
+ xmlParams.outputClassExtension = "";
xmlParams.inputCommonRoot = "";
xmlParams.inputFolder = "";
xmlParams.maskImage = "";
xmlParams.outputImageExtension = DomObject->GetAttribute( "outputImageExtension" );
if ( xmlParams.outputImageExtension == "" )
{
- std::cout << std::endl << std::endl << "outputImageExtension not set" << std::endl << std::endl;
- std::exit( EXIT_FAILURE );
+ std::cout << std::endl << std::endl << "outputImageExtension not set, using same as input (imageExtension) : "<< xmlParams.imageExtension << std::endl << std::endl;
+ xmlParams.outputImageExtension = xmlParams.imageExtension;
}
+ xmlParams.outputClassExtension = DomObject->GetAttribute( "outputClassExtension" );
+ if ( xmlParams.outputClassExtension == "" )
+ {
+ std::cout << std::endl << std::endl << "outputClassExtension not set, .nii (nifti) used by default" << std::endl << std::endl;
+ xmlParams.outputClassExtension = ".nii";
+ }
+
+
// Read input parameters
listInput = DomObject->GetChild( "listInput" );
xmlParams.inputFolder = listInput->GetAttribute( "inputFolder" );
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES} )
SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINKER_LANGUAGE C)
+ install(TARGETS ${LIBRARY_NAME} DESTINATION lib)
+ install(FILES ${LIBRARY_NAME_HEADERS} DESTINATION include)
#
#----------------------------------------------------------------------------
#ifndef itkSTMS_BlurringSTMS_TXX
#define itkSTMS_BlurringSTMS_TXX
+#include <limits>
#include <random>
#include <algorithm>
#include <iterator>
itkSTMS_BlurringSTMS< IndexType, SpatialType, PixelType, ImageType >
::FinalMerging()
{
- unsigned int size = INFINITY;
+ unsigned int size = std::numeric_limits<unsigned int>::max() - 1; // INFINITY;
std::string imagePath = expDescription->experimentPath+expDescription->inputFolder+expDescription->inputCommonRoot+STMS_NUMBERING_FORM_ONE+expDescription->imageExtension;
while(size > classSet->size()){
idx[0] = refClass->at(m)[0]+x;
idx[1] = refClass->at(m)[1]+y;
- if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0)
+ if( ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && (idx[0]>0)
+ && (idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && (idx[1]>0) )
{
if(image->GetPixel(idx) == 2)
{
idx[0] = candClass->at(m)[0]+x;
idx[1] = candClass->at(m)[1]+y;
- if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0)
+ if( ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && ( idx[0] > 0 )
+ && ( idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && ( idx[1] > 0 ) )
{
if(image->GetPixel(idx) == 1)
{
idx[1] = refClass->at(m)[1]+y;
idx[2] = refClass->at(m)[2]+z;
- if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0 && idx[2]<image->GetBufferedRegion().GetSize()[2] && idx[2]>0)
+ if( ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && (idx[0] > 0) &&
+ ( idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && (idx[1] > 0) &&
+ ( idx[2] < static_cast<long>(image->GetBufferedRegion().GetSize()[2]) ) && (idx[2] > 0) )
{
if(image->GetPixel(idx) == 2)
{
idx[1] = candClass->at(m)[1]+y;
idx[2] = candClass->at(m)[2]+z;
- if(idx[0]<image->GetBufferedRegion().GetSize()[0] && idx[0]>0 && idx[1]<image->GetBufferedRegion().GetSize()[1] && idx[1]>0 && idx[2]<image->GetBufferedRegion().GetSize()[2] && idx[2]>0)
+ if( ( idx[0] < static_cast<long>(image->GetBufferedRegion().GetSize()[0]) ) && ( idx[0] > 0 ) &&
+ ( idx[1] < static_cast<long>(image->GetBufferedRegion().GetSize()[1]) ) && ( idx[1] > 0 ) &&
+ ( idx[2] < static_cast<long>(image->GetBufferedRegion().GetSize()[2]) ) && ( idx[2] > 0 ) )
{
if(image->GetPixel(idx) == 1)
{
#add_executable(STMS_GrayLevelFiltering_Spine STMS_GrayLevelFiltering_Spine.cxx )
#target_link_libraries(STMS_GrayLevelFiltering_Spine ${ITK_LIBRARIES})
+install(TARGETS STMS_GrayLevelFiltering DESTINATION bin)
+
add_executable(STMS_generateClosestMap STMS_generateClosestMap.cxx)
target_link_libraries(STMS_generateClosestMap ${ITK_LIBRARIES})
+install(TARGETS STMS_generateClosestMap DESTINATION bin)
#include <iomanip>
#include <ctime>
-#define STMS_NUMBERING_FORM_ONE "001"
+#define STMS_NUMBERING_FORM_ONE "0001"
#include "itkImage.h"
#include "itkSTMS_ArgumentsAnalysis.h"
typedef float PixelType;
+typedef unsigned char OutputPixelType2D;
+typedef float OutputPixelType3D;
+
double gettime_hp()
{
switch(params->dim){
case 2:
{
- typedef itk::Image< PixelType, 2 > ImageType2D;
- typedef itk::Image< unsigned char, 2 > MaskImageType2D;
+ typedef itk::Image< PixelType, 2 > ImageType2D;
+ typedef itk::Image< OutputPixelType2D, 2 > OutputImageType2D;
+ typedef itk::Image< unsigned char, 2 > MaskImageType2D;
typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType2D, MaskImageType2D >::IndexType IndexType;
dtime=gettime_hp();
- itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType2D, ClassImageType2D >* postProcess
- = new itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType2D, ClassImageType2D >(stmsFilter->GetClassMemory(),
+ itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType2D, ClassImageType2D, OutputImageType2D >* postProcess
+ = new itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType2D, ClassImageType2D, OutputImageType2D>(stmsFilter->GetClassMemory(),
stmsFilter->GetSpatialMemory(),
stmsFilter->GetRangeSet(),
params,
case 3:
{
typedef itk::Image< PixelType, 3 > ImageType3D;
+ typedef itk::Image< OutputPixelType3D, 3 > OutputImageType3D;
typedef itk::Image< unsigned char, 3 > MaskImageType3D;
typedef itkSTMS::itkSTMS_ImageSequenceToTemporalSet< ImageType3D, MaskImageType3D >::IndexType IndexType;
dtime=gettime_hp();
- itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType3D, MaskImageType3D >* postProcess
- = new itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType3D, MaskImageType3D >(stmsFilter->GetClassMemory(),
+ itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType3D, MaskImageType3D, OutputImageType3D>* postProcess
+ = new itkSTMS::itkSTMS_TemporalSetToImageSequence< ImageType3D, MaskImageType3D, OutputImageType3D >(stmsFilter->GetClassMemory(),
stmsFilter->GetSpatialMemory(),
stmsFilter->GetRangeSet(),
params,