# Modernize this code

**URL:** https://discourse.itk.org/t/modernize-this-code/4207
**Category:** Uncategorized
**Created:** [June 14, 2021, 11:18am UTC](https://discourse.itk.org/t/modernize-this-code/4207 "2021-06-14T11:18:54Z")
**Posts on this page:** 1
**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 14, 2021, 11:18am UTC](https://discourse.itk.org/t/modernize-this-code/4207/1 "2021-06-14T11:18:54Z")

</div>

hello,  
i have this old code and io want to adapt to the newer ITK,

```auto
typedef itk::Statistics::ScalarImageToListAdaptor<ImageType> ImageListSample;
  typedef itk::Statistics::ScalarImageToListAdaptor<MaskImageType> MaskListSample;
  typedef itk::Statistics::SelectiveSubsampleGenerator<ImageListSample,MaskListSample> SubsampleGeneratorType;
  typedef itk::Statistics::ListSampleToHistogramGenerator<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);

```

what functions replace this one:

- ScalarImageToListAdaptor
- SelectiveSubsampleGenerator
- ListSampleToHistogramGenerator
