# Errore with some old functions

**URL:** <https://discourse.itk.org/t/errore-with-some-old-functions/4198>\
**Category:** Uncategorized\
**Created:** [June 10, 2021, 1:47pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198 "2021-06-10T13:47:50Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![alessandromauri](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@alessandromauri](https://discourse.itk.org/u/alessandromauri)\
**Post date:** [June 10, 2021, 1:47pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/1 "2021-06-10T13:47:51Z")

</div>

Hello everyone,  
i have this code on a macos on 2008.  
I’m trying to use it now with a windows pc but some problem occurred. (on red the error)  
Thanks in advance

![image](https://discourse.itk.org/uploads/default/original/2X/2/2ff7def97603bc1e55eb8046bd3dd86c259d6545.png)

 ![image](https://discourse.itk.org/uploads/default/original/2X/5/501113475a77bc920d444e7c826f968640ae2955.png)  
 ![image](https://discourse.itk.org/uploads/default/original/2X/2/2dd0e79b898424736bf1aca561ad9ba05dda46e0.png)  
 ![image](https://discourse.itk.org/uploads/default/original/2X/5/51826938220f16f6d31a378dec6fe55bf6fa0173.png)

 ![image](https://discourse.itk.org/uploads/default/original/2X/1/1731318410a5367de7965c8bb93c4e633dbff12b.png)

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [June 10, 2021, 1:52pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/2 "2021-06-10T13:52:07Z")

</div>

Welcome to the ITK community.

Please provide the text of the error message, as well as copy-pasting the [source code](https://discourse.stonehearth.net/t/discourse-guide-code-formatting/30587) instead of posting screenshots of the source code.

---

<div class="post-metadata">

**Author:** ![alessandromauri](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@alessandromauri](https://discourse.itk.org/u/alessandromauri)\
**Post date:** [June 10, 2021, 2:03pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/3 "2021-06-10T14:03:46Z")

</div>

this is the code of the part that get the error:

```cpp
#include <stdio.h>
#include <fstream>

#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

#include "itkBinaryThresholdImageFilter.h"

#include "itkScalarImageToTextureFeaturesFilter.h"
#include "itkSparseFrequencyContainer2.h"

#include "itkOtsuMultipleThresholdsCalculator.h"

#include "itkThresholdLabelerImageFilter.h"

#include "itkMaskImageFilter.h"
#include "itkImageToListSampleAdaptor.h"
#include "itkSampleToHistogramFilter.h"
#include "itkSparseFrequencyContainer2.h"

#include "itkHistogram.h"

typedef itk::Statistics::ImageToListSampleAdaptor <ImageType> ImageListSample;
typedef itk::Statistics::ImageToListSampleAdaptor <MaskImageType> MaskListSample;
typedef itk::Statistics::SelectiveSubsampleGenerator<ImageListSample, MaskListSample> SubsampleGeneratorType;
typedef itk::Statistics::SampleToHistogramFilter<SubsampleGeneratorType::OutputType, float> HistogramGeneratorType;

ImageListSample::Pointer imageListSample = ImageListSample::New();
imageListSample->SetImage(imageReader->GetOutput());

MaskListSample::Pointer maskListSample = MaskListSample::New();
maskListSample->SetImage(thresholdFilter->GetOutput());

SubsampleGeneratorType::ClassLabelVectorType selectedLabels;
selectedLabels.push_back(itk::NumericTraits<SubsampleGeneratorType::ClassLabelType>::One);

std::cout << "Generating masked subsample" << std::endl;
SubsampleGeneratorType::Pointer subsampleGenerator = SubsampleGeneratorType::New();
subsampleGenerator->SetInput(imageListSample);
subsampleGenerator->SetClassMask(maskListSample);
subsampleGenerator->SetSelectedClassLabels(selectedLabels);
try
{
	subsampleGenerator->GenerateData();
}
catch (itk::ExceptionObject& exp)
{
	std::cerr << exp << std::endl;
}

std::cout << "Generating histogram" << std::endl;
HistogramGeneratorType::HistogramSizeType numberOfBins;
numberOfBins.Fill(512);
HistogramGeneratorType::Pointer histogramGenerator = HistogramGeneratorType::New();
histogramGenerator->SetListSample(subsampleGenerator->GetOutput());
histogramGenerator->SetNumberOfBins(numberOfBins);
try
{
	histogramGenerator->Update();
}
catch (itk::ExceptionObject& exp)
{
	std::cerr << exp << std::endl;
}

typedef HistogramGeneratorType::HistogramType HistogramType;

HistogramType::ConstPointer histogram = histogramGenerator->GetOutput();

HistogramType::FrequencyType maxFrequency = itk::NumericTraits<HistogramType::FrequencyType>::min();
HistogramType::MeasurementType mode;
for (HistogramType::ConstIterator iter = histogram->Begin(); iter != histogram->End(); ++iter)
{
	if (maxFrequency < iter.GetFrequency())
	{
		maxFrequency = iter.GetFrequency();
		mode = iter.GetMeasurementVector()[0];
	}
}

// double lowQuantile = histogram->Quantile(0,0.001);
// double highQuantile = histogram->Quantile(0,0.999);

double lowQuantile = histogram->Quantile(0, 0.01);
double highQuantile = histogram->Quantile(0, 0.99);

// double fatThreshold = 10.0;
if (numberOfClasses == 3 && lowQuantile < fatThreshold)
{
	lowQuantile = fatThreshold;
}

HistogramType::Pointer cleanHistogram = HistogramType::New();
HistogramType::SizeType size;
size.Fill(histogram->Size());
HistogramType::MeasurementVectorType lowerBound, upperBound;

HistogramType::IndexType index;
index[0] = 0;
lowerBound[0] = histogram->GetBinMin(0, index[0]);
upperBound[0] = histogram->GetBinMax(0, histogram->Size() - 1);
cleanHistogram->Initialize(size, lowerBound, upperBound);

HistogramType::ConstIterator histiter;
HistogramType::Iterator cleaniter;

for (histiter = histogram->Begin(), cleaniter = cleanHistogram->Begin(); histiter != histogram->End(); ++histiter, ++cleaniter)
{
	if ((histiter.GetMeasurementVector()[0] > lowQuantile) && (histiter.GetMeasurementVector()[0] < highQuantile))
	{
		cleaniter.SetFrequency(histiter.GetFrequency());
	}
	else
	{
		cleaniter.SetFrequency(0.0);
	}
}

HistogramType::MeasurementType previousMeasurement = histogram->Begin().GetMeasurementVector()[0];
for (HistogramType::ConstIterator iter = histogram->Begin(); iter != histogram->End(); ++iter)
{
	int thresholdMarker = 0;
	for (unsigned int i = 0; i < numberOfActualClasses - 1; i++)
	{
		if (thresholds[i] > previousMeasurement && thresholds[i] <= iter.GetMeasurementVector()[0])
		{
			thresholdMarker = 1;
		}
	}
	dataFileStream << iter.GetMeasurementVector()[0] << "\t" << iter.GetFrequency() << "\t" << thresholdMarker << std::endl;
	previousMeasurement = iter.GetMeasurementVector()[0];
}

dataFileStream.close();
		}

```

This is the error when compiled  
 ![image](https://discourse.itk.org/uploads/default/original/2X/a/a190ce71a47e2ea0725a4837b1bb729528fbc968.png)

 ![image](https://discourse.itk.org/uploads/default/original/2X/8/87934d0e494f9aa657ce2227b77a8b2f5989715b.png)

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [June 10, 2021, 2:12pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/4 "2021-06-10T14:12:55Z")

</div>

Your code uses class [SelectiveSubsampleGenerator](https://itk.org/Doxygen320/html/classitk_1_1Statistics_1_1SelectiveSubsampleGenerator.html), which has been removed in version 4 of ITK, and therefore does not exist in current, version 5 of ITK either.

You can use old versions of compilers with ITK 3.20, or [migrate](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Documentation/ITK5MigrationGuide.md) your code to use newer ITK.

---

<div class="post-metadata">

**Author:** ![alessandromauri](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@alessandromauri](https://discourse.itk.org/u/alessandromauri)\
**Post date:** [June 10, 2021, 2:56pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/5 "2021-06-10T14:56:11Z")

</div>

i compiled a itk 3.20, all the classes are recognized but there is one different error:  
impossible open ITKStatistics.lib.

Thanks

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [June 10, 2021, 3:23pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/6 "2021-06-10T15:23:53Z")

</div>

Did you [use CMake](https://preshing.com/20170511/how-to-build-a-cmake-based-project/) to configure your application? If your application is not CMake-based, you can turn it into one by following this [hello world example](https://itk.org/Wiki/ITK/HelloInsight).

---

<div class="post-metadata">

**Author:** ![alessandromauri](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@alessandromauri](https://discourse.itk.org/u/alessandromauri)\
**Post date:** [June 10, 2021, 7:38pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/7 "2021-06-10T19:38:07Z")

</div>

Yes I used Cmake to configure!

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [June 10, 2021, 9:13pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/8 "2021-06-10T21:13:26Z")

</div>

When asking these kinds of questions, sharing the error message is usually helpful. In this case, sharing your program’s `CMakeLists.txt` would be helpful too.

Error messages are best copy-pasted, because that makes them searchable as text (as opposed to screenshots of error messages). Also, text can be copy-pasted into google translate, which would be helpful as I don’t understand Italian.

---

<div class="post-metadata">

**Author:** ![alessandromauri](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@alessandromauri](https://discourse.itk.org/u/alessandromauri)\
**Post date:** [June 11, 2021, 10:24am UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/9 "2021-06-11T10:24:10Z")

</div>

The cmakelist.txt of the itk is:

> [CMakeLists.txt - Google Drive](https://drive.google.com/file/d/1oma4ynjCr17gRiKZz9hBdx5APR7vW4pR/view?usp=sharing)

the cmakelist.txt of the code is:

```cmake
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)

project(pkdDicomSeriesToVolume)

# Find ITK.
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

add_executable(pkdDicomSeriesToVolume adpkdotsu.cxx)

target_link_libraries(pkdDicomSeriesToVolume ${ITK_LIBRARIES})

```

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [June 11, 2021, 2:31pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/10 "2021-06-11T14:31:08Z")

</div>

Your CMake code is simplest possible, so I think that the problem is that ITK was not compiled successfully or completely. Can you do an incremental build of ITK?

---

<div class="post-metadata">

**Author:** ![alessandromauri](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@alessandromauri](https://discourse.itk.org/u/alessandromauri)\
**Post date:** [June 11, 2021, 3:29pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/11 "2021-06-11T15:29:57Z")

</div>

how can i do an incremental build?

---

<div class="post-metadata">

**Author:** ![alessandromauri](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@alessandromauri](https://discourse.itk.org/u/alessandromauri)\
**Post date:** [June 11, 2021, 3:37pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/12 "2021-06-11T15:37:37Z")

</div>

the compile always came with this error:  
#error The C++ Standard Library forbids macroizing the keyword “export”.   
Enable warning C4005 to find the forbidden define.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [June 11, 2021, 3:38pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/13 "2021-06-11T15:38:00Z")

</div>

On the “Build” menu choose “Build Solution”. That does an incremental build.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [June 11, 2021, 3:43pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/14 "2021-06-11T15:43:46Z")

</div>

> [@alessandromauri](#):
>
> #error The C++ Standard Library forbids macroizing the keyword “export”.

You need to build ITK 3.20 with an older compiler. The branch `release-3.20` [seems like](https://github.com/InsightSoftwareConsortium/ITK/commits/release-3.20) it should build with Visual Studio 2013 and GCC 5.3.1. These commits have been added since 3.20.1 release.

---

<div class="post-metadata">

**Author:** ![alessandromauri](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@alessandromauri](https://discourse.itk.org/u/alessandromauri)\
**Post date:** [June 11, 2021, 4:11pm UTC](https://discourse.itk.org/t/errore-with-some-old-functions/4198/15 "2021-06-11T16:11:16Z")

</div>

ok ok thanks a lot
