<commit_before>/*=========================================================================
 *
 *  Copyright RTK Consortium
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/

#include "rtkramp_ggo.h"
#include "rtkMacro.h"

#include "rtkProjectionsReader.h"
#include "rtkFFTRampImageFilter.h"
#include "rtkConfiguration.h"
#if CUDA_FOUND
#  include "rtkCudaFFTRampImageFilter.h"
#endif

#include <itkImageFileWriter.h>
#include <itkRegularExpressionSeriesFileNames.h>
#include <itkStreamingImageFilter.h>
#include <itkTimeProbe.h>

int main(int argc, char * argv[])
{
  GGO(rtkramp, args_info);

  typedef float OutputPixelType;
  const unsigned int Dimension = 3;

#if CUDA_FOUND
  typedef itk::CudaImage< OutputPixelType, Dimension > OutputImageType;
#else
  typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
#endif

  // Generate file names
  itk::RegularExpressionSeriesFileNames::Pointer names = itk::RegularExpressionSeriesFileNames::New();
  names->SetDirectory(args_info.path_arg);
  names->SetNumericSort(false);
  names->SetRegularExpression(args_info.regexp_arg);
  names->SetSubMatch(0);

  // Projections reader
  typedef rtk::ProjectionsReader< OutputImageType > ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileNames( names->GetFileNames() );

  TRY_AND_EXIT_ON_ITK_EXCEPTION( reader->Update() )

  // Ramp filter
#if CUDA_FOUND
  typedef rtk::CudaFFTRampImageFilter CudaRampFilterType;
  CudaRampFilterType::Pointer cudaRampFilter;
#endif
  typedef rtk::FFTRampImageFilter<OutputImageType, OutputImageType, double > CPURampFilterType;
  CPURampFilterType::Pointer rampFilter;
  if( !strcmp(args_info.hardware_arg, "cuda") )
    {
#if CUDA_FOUND
    cudaRampFilter = CudaRampFilterType::New();
    cudaRampFilter->SetInput( reader->GetOutput() );
    cudaRampFilter->SetTruncationCorrection(args_info.pad_arg);
    cudaRampFilter->SetHannCutFrequency(args_info.hann_arg);
    cudaRampFilter->SetHannCutFrequencyY(args_info.hannY_arg);
#else
    std::cerr << "The program has not been compiled with cuda option" << std::endl;
    return EXIT_FAILURE;
#endif
    }
  else
    {
    rampFilter = CPURampFilterType::New();
    rampFilter->SetInput( reader->GetOutput() );
    rampFilter->SetTruncationCorrection(args_info.pad_arg);
    rampFilter->SetHannCutFrequency(args_info.hann_arg);
    rampFilter->SetHannCutFrequencyY(args_info.hannY_arg);
    }

  // Streaming filter
  typedef itk::StreamingImageFilter<OutputImageType, OutputImageType> StreamerType;
  StreamerType::Pointer streamer = StreamerType::New();
  if( !strcmp(args_info.hardware_arg, "cuda") )
    streamer->SetInput( cudaRampFilter->GetOutput() );
  else
    streamer->SetInput( rampFilter->GetOutput() );<commit_msg>Added missing ifdef for compilation without cuda<commit_after>/*=========================================================================
 *
 *  Copyright RTK Consortium
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/

#include "rtkramp_ggo.h"
#include "rtkMacro.h"

#include "rtkProjectionsReader.h"
#include "rtkFFTRampImageFilter.h"
#include "rtkConfiguration.h"
#if CUDA_FOUND
#  include "rtkCudaFFTRampImageFilter.h"
#endif

#include <itkImageFileWriter.h>
#include <itkRegularExpressionSeriesFileNames.h>
#include <itkStreamingImageFilter.h>
#include <itkTimeProbe.h>

int main(int argc, char * argv[])
{
  GGO(rtkramp, args_info);

  typedef float OutputPixelType;
  const unsigned int Dimension = 3;

#if CUDA_FOUND
  typedef itk::CudaImage< OutputPixelType, Dimension > OutputImageType;
#else
  typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
#endif

  // Generate file names
  itk::RegularExpressionSeriesFileNames::Pointer names = itk::RegularExpressionSeriesFileNames::New();
  names->SetDirectory(args_info.path_arg);
  names->SetNumericSort(false);
  names->SetRegularExpression(args_info.regexp_arg);
  names->SetSubMatch(0);

  // Projections reader
  typedef rtk::ProjectionsReader< OutputImageType > ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileNames( names->GetFileNames() );

  TRY_AND_EXIT_ON_ITK_EXCEPTION( reader->Update() )

  // Ramp filter
#if CUDA_FOUND
  typedef rtk::CudaFFTRampImageFilter CudaRampFilterType;
  CudaRampFilterType::Pointer cudaRampFilter;
#endif
  typedef rtk::FFTRampImageFilter<OutputImageType, OutputImageType, double > CPURampFilterType;
  CPURampFilterType::Pointer rampFilter;
  if( !strcmp(args_info.hardware_arg, "cuda") )
    {
#if CUDA_FOUND
    cudaRampFilter = CudaRampFilterType::New();
    cudaRampFilter->SetInput( reader->GetOutput() );
    cudaRampFilter->SetTruncationCorrection(args_info.pad_arg);
    cudaRampFilter->SetHannCutFrequency(args_info.hann_arg);
    cudaRampFilter->SetHannCutFrequencyY(args_info.hannY_arg);
#else
    std::cerr << "The program has not been compiled with cuda option" << std::endl;
    return EXIT_FAILURE;
#endif
    }
  else
    {
    rampFilter = CPURampFilterType::New();
    rampFilter->SetInput( reader->GetOutput() );
    rampFilter->SetTruncationCorrection(args_info.pad_arg);
    rampFilter->SetHannCutFrequency(args_info.hann_arg);
    rampFilter->SetHannCutFrequencyY(args_info.hannY_arg);
    }

  // Streaming filter
  typedef itk::StreamingImageFilter<OutputImageType, OutputImageType> StreamerType;
  StreamerType::Pointer streamer = StreamerType::New();
#if CUDA_FOUND
  if( !strcmp(args_info.hardware_arg, "cuda") )
    streamer->SetInput( cudaRampFilter->GetOutput() );
  else
#endif
    streamer->SetInput( rampFilter->GetOutput() );
{'fraction_non_alphanumeric': 0.14478164322723908, 'fraction_numerical': 0.001776461880088823, 'mean_word_length': 5.571984435797665, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3691080', 'n_tokens_mistral': 2163, 'n_tokens_neox': 2117, 'n_words': 461}