ADD_DEFINITIONS(-DHAVE_NAMESPACES)
# Remove compiler warnings
-STRING(REPLACE "/W3" "/w" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
-STRING(REPLACE "/W3" "/w" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
-STRING(REPLACE "-Wall" "-w" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
-STRING(REPLACE "-Wall" "-w" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+STRING(REPLACE "/W3" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+STRING(REPLACE "/W3" "/w" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+STRING(REPLACE "-Wall" "-w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+STRING(REPLACE "-Wall" "-w" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# MSVC specific issues
IF(MSVC)
clitkXdrImageIOFactory.cxx
clitkHndImageIO.cxx
clitkHndImageIOFactory.cxx
- clitkGateAsciiImageIO.cxx
- clitkGateAsciiImageIOFactory.cxx
clitkDicomRTDoseIO.cxx
clitkDicomRTDoseIOFactory.cxx
clitkOrientation.cxx
vvImageWriter.cxx
)
+IF(UNIX)
+ SET(clitkCommon_SRC
+ ${clitkCommon_SRC}
+ clitkGateAsciiImageIO.cxx
+ clitkGateAsciiImageIOFactory.cxx
+ )
+ENDIF(UNIX)
+
### Declare clitkCommon library
ADD_LIBRARY(clitkCommon STATIC ${clitkCommon_SRC})
while (1) {
int len;
gfov = (double*) realloc (gfov, (gfov_len + 1) * sizeof(double));
- rc = sscanf (gfov_str, "%g%n", &gfov[gfov_len], &len);
+ rc = sscanf (gfov_str, "%lf%n", &gfov[gfov_len], &len);
if (rc != 1) {
break;
}
clitk::PrintMemory(GetVerboseMemoryFlag(), "End of step");
if (GetVerboseImageSizeFlag()) {
std::ostream & os = std::cout;
- int dim = p->GetImageDimension();
+ unsigned int dim = p->GetImageDimension();
int nb = 1;
os << txt << " size = ";
for(unsigned int i=0; i<dim-1; i++) {
regmatch_t matches[4];
{ // build regex
- int ret = 0;
- ret = regcomp(&re_comment,"^#.+$",REG_EXTENDED|REG_NEWLINE);
- assert(ret == 0);
- ret = regcomp(&re_matrix_size,"^# +Matrix *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",REG_EXTENDED|REG_NEWLINE);
- assert(ret == 0);
- ret = regcomp(&re_resol,"^# +Resol *= +\\(([0-9]+),([0-9]+),([0-9]+)\\)$",REG_EXTENDED|REG_NEWLINE);
- assert(ret == 0);
- ret = regcomp(&re_voxel_size,"^# +Voxel *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",REG_EXTENDED|REG_NEWLINE);
- assert(ret == 0);
- ret = regcomp(&re_nb_value,"^# +nbVal *= +([0-9]+)$",REG_EXTENDED|REG_NEWLINE);
- assert(ret == 0);
+ assert(regcomp(&re_comment,"^#.+$",REG_EXTENDED|REG_NEWLINE) == 0);
+ assert(regcomp(&re_matrix_size,"^# +Matrix *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",REG_EXTENDED|REG_NEWLINE) == 0);
+ assert(regcomp(&re_resol,"^# +Resol *= +\\(([0-9]+),([0-9]+),([0-9]+)\\)$",REG_EXTENDED|REG_NEWLINE) == 0);
+ assert(regcomp(&re_voxel_size,"^# +Voxel *Size *= +\\(([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*),([0-9]+\\.?[0-9]*)\\)$",REG_EXTENDED|REG_NEWLINE) == 0);
+ assert(regcomp(&re_nb_value,"^# +nbVal *= +([0-9]+)$",REG_EXTENDED|REG_NEWLINE) == 0);
}
if (!ReadLine(handle,line)) return false;
uint32_t* buf = (uint32_t*)buffer;
unsigned char *pt_lut;
uint32_t a;
- float b;
unsigned char v;
int lut_idx, lut_off;
size_t num_read;
for (i = 0; i < GetDimensions(0); i++) {
fread (&a, sizeof(uint32_t), 1, fp);
buf[i] = a;
- b = a;
}
/* Read first pixel of second row */
fread (&a, sizeof(uint32_t), 1, fp);
buf[i++] = a;
- b = a;
/* Decompress the rest */
lut_idx = 0;
}
buf[i] = r21 + r12 + diff - r11;
- b = buf[i];
i++;
}
// Register factories
void clitk::RegisterClitkFactories()
{
+#ifdef unix
clitk::GateAsciiImageIOFactory::RegisterOneFactory();
+#endif
clitk::DicomRTDoseIOFactory::RegisterOneFactory();
#if ITK_VERSION_MAJOR <= 3
itk::ImageIOFactory::RegisterBuiltInFactories();
#endif
}
+#if defined(_MSC_VER)
+# include <io.h>
+# define mkstemp(x) _mktemp_s(x, sizeof(x))
+#endif
+
#endif /* end #define CLITKPORTABILITY_H */
//int forcenoswap=0;
char *file = const_cast<char *>(m_FileName.c_str());
int offset=0;
- AVSType field=UNIFORM;
+ // AVSType field=UNIFORM;
for (i=0; i<GetNumberOfDimensions(); i++) coords += GetDimensions(i);
c = scan_header(file, "field", offset, 1);
if (c) {
- if (memicmp(c, "unifo", 5) == 0) field=UNIFORM, coords=nspace*2;
- else if (memicmp(c, "recti", 5) == 0) field=RECTILINEAR;
- else if (memicmp(c, "irreg", 5) == 0) field=IRREGULAR, coords=total*nspace;
+ if (memicmp(c, "unifo", 5) == 0) /*field=UNIFORM,*/ coords=nspace*2;
+ // else if (memicmp(c, "recti", 5) == 0) field=RECTILINEAR;
+ else if (memicmp(c, "irreg", 5) == 0) /*field=IRREGULAR,*/ coords=total*nspace;
else return ER_XDR_FIELD;
} else
coords=0;
BackProjectImageFilter<InputImageType, OutputImageType>
::CalculateProjectionMatrix( void )
{
- InputSpacingType inputSpacing=this->GetInput()->GetSpacing();
+ //InputSpacingType inputSpacing=this->GetInput()->GetSpacing();
// Projection on YZ plane+pixelTrans
itk::Matrix<double,3,4> temp;
iPoint.Fill(itk::NumericTraits<double>::Zero);
OutputIndexType oIndex;
ContinuousInputIndexType iIndex;
- InputSizeType inputSize=inputPtr->GetLargestPossibleRegion().GetSize();
//Get the first output coordinate
oIndex=iterator.GetIndex();//costly but only once a thread
// get neighbor index and overlap fraction
+ bool neighbIndexSupZero = 1;
for( dim = 0; dim < ImageDimension; dim++ )
{
if ( upper & 1 )
neighIndex[dim] = baseIndex[dim];
overlap *= 1.0 - distance[dim];
}
+ if (neighIndex[dim] < 0)
+ neighbIndexSupZero = 0;
upper >>= 1;
}
//JV shouldn't we verify that the index is not over the upper border instead of zero?
// Set neighbor value only if overlap is not zero and index is still in image
- if( overlap>0.0 && neighIndex[0]>=0 && neighIndex[1]>=0 && neighIndex[2]>=0 )
+ if ( overlap>0.0 && neighbIndexSupZero )
{
//what to store? the weighted displacement vector of Input2?
totalDisplacement+=m_Input2->GetPixel(neighIndex)*overlap;
//Get pointer to the output
typename OutputImageType::Pointer outputPtr = this->GetOutput();
- typename OutputImageType::SizeType size=outputPtr->GetLargestPossibleRegion().GetSize();
+ //typename OutputImageType::SizeType size=outputPtr->GetLargestPossibleRegion().GetSize();
//Iterators over input and deformation field
typedef itk::ImageRegionConstIteratorWithIndex<InputImageType> InputImageIteratorType;
//Get pointer to the output
typename OutputImageType::Pointer outputPtr = this->GetOutput();
- typename OutputImageType::SizeType size=outputPtr->GetLargestPossibleRegion().GetSize();
+ //typename OutputImageType::SizeType size=outputPtr->GetLargestPossibleRegion().GetSize();
//Iterator over input
typedef itk::ImageRegionConstIteratorWithIndex<InputImageType> InputImageIteratorType;
upper = counter; // each bit indicates upper/lower neighbour
// get neighbor index and overlap fraction
- for( dim = 0; dim < 3; dim++ ) {
+ for( dim = 0; dim < ImageDimension; dim++ ) {
if ( upper & 1 ) {
neighIndex[dim] = baseIndex[dim] + 1;
overlap *= distance[dim];
typename OutputImageType::IndexType start;
for (unsigned int i=0; i< ImageDimension; i++) start[i]=0;
region.SetIndex(start);
- PixelType zero = itk::NumericTraits<double>::Zero;
//Allocate the weights
clitk::RelativePositionAnalyzerFilter<ImageType>::
GenerateData()
{
- static const unsigned int dim = ImageType::ImageDimension;
-
ImagePointer temp = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(0));
m_Object = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(1));
ImagePointer temp2 = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(2));
std::vector<std::string> & RelativePositionDataBase::GetListOfPatients(const IndexType & index) const
{
const MapByPatientType & o = GetMapByPatient(index);
- MapByPatientType::const_iterator iter = o.begin();
std::vector<std::string> * v = new std::vector<std::string>;
MapToVecFirst(o, *v);
return *v;
bool RelativePositionDataBase::CheckIndex(const IndexType & index) const
{
try {
- const RelativePositionInformationType & m = GetInformation(index);
+ /*const RelativePositionInformationType & m = */ GetInformation(index);
} catch (clitk::ExceptionObject e) {
// std::cout << e.what() << std::endl;
return false;
// Loop over objects
std::vector<double> m_ListOfThresholds;
- for(int i=0; i<m_ListOfObjects.size(); i++) {
+ for(unsigned int i=0; i<m_ListOfObjects.size(); i++) {
// DD(i);
// DD(m_ListOfObjects[i]);
// Set current index
db.GetListOfDirections(GetStationName(), index.object, m_ListOfDirections);
// Loop over direction
- for(int j=0; j<m_ListOfDirections.size(); j++) {
+ for(unsigned int j=0; j<m_ListOfDirections.size(); j++) {
// DD(j);
// m_ListOfDirections[j].Println();
// Set current index
// For a given station, object, direction
bool stop=false;
- int i=0;
+ unsigned int i=0;
if (index.direction.notFlag) threshold = 0.0;
else threshold = 1.0;
while (!stop && (i<ListOfPatients.size())) {
GenerateData()
{
// Load database of anatomical elements
- static const unsigned int dim = ImageType::ImageDimension;
this->LoadAFDB();
// Get some information
// Build the list of tested directions
m_ListOfAngles.clear();
- for(uint i=0; i<GetNumberOfAngles(); i++) {
+ for(int i=0; i<GetNumberOfAngles(); i++) {
double a = i*360.0/GetNumberOfAngles();
if (a>180) a = 180-a;
m_ListOfAngles.push_back(clitk::deg2rad(a));
for (int i=0; i<GetNumberOfObjects(); i++) {
m_Object = this->GetAFDB()->template GetImage <ImageType>(GetObjectName(i));
- for (int j=0; j<m_ListOfDirections.size(); j++) {
+ for (unsigned int j=0; j<m_ListOfDirections.size(); j++) {
clitk::RelativePositionDirectionType direction = m_ListOfDirections[j];
// Create the filter
iter2.GoToBegin();
double dmin = 100000.0;
typename ImageType::IndexType indexmin;
+ indexmin.Fill(0);
while (!iter1.IsAtEnd()) {
if (iter1.Get() != BG) {
double d = iter2.Get();
exit 1
fi
-find filters tools -name "clitkFooImage*" |
+find tools -name "clitkFooImage*" |
while read i
do
cp $i ${i/FooImage/$1}
// The metric region with respect to the extracted transform region:
// where should the metric be CALCULATED (depends on transform)
typename FixedImageType::RegionType metricRegion = fixedImage->GetLargestPossibleRegion();
- typename FixedImageType::RegionType::SizeType metricRegionSize=metricRegion.GetSize();
typename FixedImageType::RegionType::IndexType metricRegionIndex=metricRegion.GetIndex();
typename FixedImageType::PointType metricRegionOrigin=fixedImage->GetOrigin();
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
// MUST BE CALLED TO INITIATE PROCESSING
this->GetValueMultiThreadedInitiate();
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
// MUST BE CALLED TO INITIATE PROCESSING
this->GetValueMultiThreadedInitiate();
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
//We need the sums and the value to be calculated first
value=this->ComputeSums(parameters);
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
// MUST BE CALLED TO INITIATE PROCESSING
this->GetValueMultiThreadedInitiate();
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
// MUST BE CALLED TO INITIATE PROCESSING
this->GetValueMultiThreadedInitiate();
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
//We need the sums and the value to be calculated first
value=this->ComputeSums(parameters);
typename CoefficientImageType::RegionType sourceRegion=m_PaddedCoefficientImage->GetLargestPossibleRegion();
typename CoefficientImageType::RegionType destinationRegion=m_PaddedCoefficientImage->GetLargestPossibleRegion();
typename CoefficientImageType::RegionType::SizeType sourceSize=sourceRegion.GetSize();
- typename CoefficientImageType::RegionType::SizeType destinationSize=destinationRegion.GetSize();
typename CoefficientImageType::IndexType sourceIndex=sourceRegion.GetIndex();
typename CoefficientImageType::IndexType destinationIndex=destinationRegion.GetIndex();
{
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
// MUST BE CALLED TO INITIATE PROCESSING
this->GetValueMultiThreadedInitiate();
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
// MUST BE CALLED TO INITIATE PROCESSING ON SAMPLES
this->GetValueAndDerivativeMultiThreadedInitiate();
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
// MUST BE CALLED TO INITIATE PROCESSING
this->GetValueMultiThreadedInitiate();
// Set up the parameters in the transform
this->m_Transform->SetParameters( parameters );
+#if ITK_VERSION_MAJOR < 4
this->m_Parameters = parameters;
+#endif
// Reset the joint pdfs to zero
memset( m_ThreaderMSE,
// Read all support limits in a file and apply them
ReadSupportLimits(GetSupportLimitsFilename());
- for(int i=0; i<m_ListOfSupportLimits.size(); i++) {
+ for(unsigned int i=0; i<m_ListOfSupportLimits.size(); i++) {
SupportLimitsType s = m_ListOfSupportLimits[i];
Support_SI_Limit(s.station_limit, s.station, s.structure_limit,
s.structure, s.offset*m_Working_Support->GetSpacing()[2]);
m_Working_Support = m_ListOfSupports[station];
// Get structure or structureZ
- double z;
+ double z=0.;
int found=0;
std::string file;
// Check if station already exist in DB
// FIXME -> do nothing if not on the command line. Is it what I want ?
- bool found = false;
+ //bool found = false;
if (this->GetAFDB()->TagExist(s)) {
m_ListOfStations[station] = this->GetAFDB()->template GetImage<MaskImageType>(s);
- found = true;
+ //found = true;
}
}
MaskImagePointer bones_ant;
MaskImagePointer bones_post;
MaskImagePointType middle_AntPost_position;
+ middle_AntPost_position.Fill(NumericTraits<MaskImagePointType::ValueType>::Zero);
if (GetUseBones()) {
this->StartNewStep("[Mediastinum] Ant/Post limits with bones");
// Define the images
//---------------------------------
ImagePointer m_input = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(0));
+ const unsigned int dim = ImageType::ImageDimension;
//---------------------------------
// Cast into internalimagetype
// Compute the radius in pixel
//---------------------------------
if (m_RadiusInMMIsSet) {
- for(uint i=0; i<ImageType::ImageDimension; i++) {
+ for(uint i=0; i<dim; i++) {
m_Radius[i] = (uint)lrint(m_RadiusInMM[i]/input->GetSpacing()[i]);
}
}
padFilter->SetInput(input);
typename ImageType::SizeType lower;
typename ImageType::SizeType upper;
- for(uint i=0; i<3; i++) {
+ for(uint i=0; i<dim; i++) {
lower[i] = upper[i] = 2*(m_Radius[i]+1);
}
padFilter->SetPadLowerBound(lower);
if (mArgsInfoList[i].orientation_given) text += std::string(mArgsInfoList[i].orientation_arg[0])+" ";
else text = text+"("+toString(mArgsInfoList[i].angle1_arg)+" "+
toString(mArgsInfoList[i].angle2_arg)+" "+
- (mArgsInfoList[i].inverse_flag==true?"true":"false")+") ";
+ (mArgsInfoList[i].inverse_flag?"true":"false")+") ";
text = text+mArgsInfoList[i].object_arg+" "+toString(mArgsInfoList[i].threshold_arg);
if (mArgsInfoList[i].sliceBySlice_flag) {
text += " slice by slice";
ApplyRelativePositionList(std::string name, MaskImageType * input)
{
// Create all RelativePositionList
- for(int i=0; i<mListOfRelativePositionListFilename.size(); i++) {
+ for(unsigned int i=0; i<mListOfRelativePositionListFilename.size(); i++) {
RelPosListPointer rpl = RelPosListType::New();
rpl->SetAFDB(GetAFDB());
rpl->Read(mListOfRelativePositionListFilename[i]);
typename MedianImageFilterType::Pointer thresholdFilter=MedianImageFilterType::New();
thresholdFilter->SetInput(input);
- indexRadius[0]=mArgsInfo.radius_arg[0];
- indexRadius[1]=mArgsInfo.radius_arg[1];
- indexRadius[2]=mArgsInfo.radius_arg[2];
+ for (unsigned i = 0; i < InputImageType::ImageDimension; ++i)
+ indexRadius[i]=mArgsInfo.radius_arg[i];
// indexRadius[0] = 1;
// indexRadius[1] = 1;
f->SetAreaLossTolerance(mArgsInfo.tol_arg);
f->SetSupportName(mArgsInfo.supportName_arg);
f->SetTargetName(mArgsInfo.targetName_arg);
- for(int i=0; i<mArgsInfo.objectName_given; i++)
+ for(unsigned int i=0; i<mArgsInfo.objectName_given; i++)
f->AddObjectName(mArgsInfo.objectName_arg[i]);
}
//--------------------------------------------------------------------