<commit_before>/* perform a pixel-wise intensity transformation using a Sigmoid function */

#include "vvITKFilterModule.h"

#include "itkSigmoidImageFilter.h"

static int ProcessData(void *inf, vtkVVProcessDataStruct *pds)
{

  vtkVVPluginInfo *info = (vtkVVPluginInfo *)inf;

  const unsigned int Dimension = 3;

  try 
  {
  switch( info->InputVolumeScalarType )
    {
    case VTK_UNSIGNED_CHAR:
      {
      typedef  unsigned char                        PixelType;
      typedef  itk::Image< PixelType, Dimension >   ImageType; 
      typedef  itk::SigmoidImageFilter< ImageType,  ImageType >   FilterType;
      VolView::PlugIn::FilterModule< FilterType > module;
      module.SetPluginInfo( info );
      module.SetUpdateMessage("Transforming intensities with a Sigmoid function...");
      // Set the parameters on it
      module.GetFilter()->SetAlpha(          atof( info->GetGUIProperty(info, 0, VVP_GUI_VALUE )) );
      module.GetFilter()->SetBeta(           atof( info->GetGUIProperty(info, 1, VVP_GUI_VALUE )) );
      module.GetFilter()->SetOutputMinimum(  atoi( info->GetGUIProperty(info, 2, VVP_GUI_VALUE )) );
      module.GetFilter()->SetOutputMaximum(  atoi( info->GetGUIProperty(info, 3, VVP_GUI_VALUE )) );
      // Execute the filter
      module.ProcessData( pds  );
      break; 
      }
    case VTK_UNSIGNED_SHORT:
      {
      typedef  unsigned short                       PixelType;
      typedef  itk::Image< PixelType, Dimension >   ImageType; 
      typedef  itk::SigmoidImageFilter< ImageType,  ImageType >   FilterType;
      VolView::PlugIn::FilterModule< FilterType > module;
      module.SetPluginInfo( info );
      module.SetUpdateMessage("Transforming intensities with a Sigmoid function...");
      // Set the parameters on it
      module.GetFilter()->SetAlpha(          atof( info->GetGUIProperty(info, 0, VVP_GUI_VALUE )) );
      module.GetFilter()->SetBeta(           atof( info->GetGUIProperty(info, 1, VVP_GUI_VALUE )) );
      module.GetFilter()->SetOutputMinimum(  atoi( info->GetGUIProperty(info, 2, VVP_GUI_VALUE )) );
      module.GetFilter()->SetOutputMaximum(  atoi( info->GetGUIProperty(info, 3, VVP_GUI_VALUE )) );
      // Execute the filter
      module.ProcessData( pds );
      break; 
      }
    }
  }
  catch( itk::ExceptionObject & except )
  {
    info->SetProperty( info, VVP_ERROR, except.what() ); 
    return -1;
  }
  return 0;
}


static int UpdateGUI(void *inf)
{
  char tmp[1024];
  vtkVVPluginInfo *info = (vtkVVPluginInfo *)inf;

  info->SetGUIProperty(info, 0, VVP_GUI_LABEL, "Alpha");
  info->SetGUIProperty(info, 0, VVP_GUI_TYPE, VVP_GUI_SCALE);
  info->SetGUIProperty(info, 0, VVP_GUI_DEFAULT, "5");
  info->SetGUIProperty(info, 0, VVP_GUI_HELP, "Factor that defines the width of the Sigmoid in the range scale. Setting a small alpha results in a step transion on the Sigmoid function. A large alpha value produces a very smooth and low slanted Sigmoid.");
  info->SetGUIProperty(info, 0, VVP_GUI_HINTS , "-100 100 0.1");

  info->SetGUIProperty(info, 1, VVP_GUI_LABEL, "Beta");
  info->SetGUIProperty(info, 1, VVP_GUI_TYPE, VVP_GUI_SCALE);
  const float meanValue = (info->InputVolumeScalarRange[1] - 
                           info->InputVolumeScalarRange[0]) / 2.0;
  sprintf(tmp,"%f",meanValue);
  info->SetGUIProperty(info, 1, VVP_GUI_DEFAULT, tmp );
  info->SetGUIProperty(info, 1, VVP_GUI_HELP, "Origin of the Sigmoid function in the range scale. It cooresponds to the intensity of the imput image that will be mapped almost linearly to the output image. Intensities far from this value will be transformed non-linearly.");
  sprintf(tmp,"%f %f %f",info->InputVolumeScalarTypeRange[0], 1.0,
                         info->InputVolumeScalarTypeRange[1] );
  info->SetGUIProperty(info, 1, VVP_GUI_HINTS , tmp );

  // The output image type is equal to the input image type. 
  // We can use then the ranges returned by the GetInput... methods.
  //
  info->SetGUIProperty(info, 2, VVP_GUI_LABEL, "Output Minimum");
  info->SetGUIProperty(info, 2, VVP_GUI_TYPE, VVP_GUI_SCALE);<commit_msg>ENH: Hints for Beta parameter are now taken from the FilterModuleBase functions.<commit_after>/* perform a pixel-wise intensity transformation using a Sigmoid function */

#include "vvITKFilterModule.h"

#include "itkSigmoidImageFilter.h"

static int ProcessData(void *inf, vtkVVProcessDataStruct *pds)
{

  vtkVVPluginInfo *info = (vtkVVPluginInfo *)inf;

  const unsigned int Dimension = 3;

  try 
  {
  switch( info->InputVolumeScalarType )
    {
    case VTK_UNSIGNED_CHAR:
      {
      typedef  unsigned char                        PixelType;
      typedef  itk::Image< PixelType, Dimension >   ImageType; 
      typedef  itk::SigmoidImageFilter< ImageType,  ImageType >   FilterType;
      VolView::PlugIn::FilterModule< FilterType > module;
      module.SetPluginInfo( info );
      module.SetUpdateMessage("Transforming intensities with a Sigmoid function...");
      // Set the parameters on it
      module.GetFilter()->SetAlpha(          atof( info->GetGUIProperty(info, 0, VVP_GUI_VALUE )) );
      module.GetFilter()->SetBeta(           atof( info->GetGUIProperty(info, 1, VVP_GUI_VALUE )) );
      module.GetFilter()->SetOutputMinimum(  atoi( info->GetGUIProperty(info, 2, VVP_GUI_VALUE )) );
      module.GetFilter()->SetOutputMaximum(  atoi( info->GetGUIProperty(info, 3, VVP_GUI_VALUE )) );
      // Execute the filter
      module.ProcessData( pds  );
      break; 
      }
    case VTK_UNSIGNED_SHORT:
      {
      typedef  unsigned short                       PixelType;
      typedef  itk::Image< PixelType, Dimension >   ImageType; 
      typedef  itk::SigmoidImageFilter< ImageType,  ImageType >   FilterType;
      VolView::PlugIn::FilterModule< FilterType > module;
      module.SetPluginInfo( info );
      module.SetUpdateMessage("Transforming intensities with a Sigmoid function...");
      // Set the parameters on it
      module.GetFilter()->SetAlpha(          atof( info->GetGUIProperty(info, 0, VVP_GUI_VALUE )) );
      module.GetFilter()->SetBeta(           atof( info->GetGUIProperty(info, 1, VVP_GUI_VALUE )) );
      module.GetFilter()->SetOutputMinimum(  atoi( info->GetGUIProperty(info, 2, VVP_GUI_VALUE )) );
      module.GetFilter()->SetOutputMaximum(  atoi( info->GetGUIProperty(info, 3, VVP_GUI_VALUE )) );
      // Execute the filter
      module.ProcessData( pds );
      break; 
      }
    }
  }
  catch( itk::ExceptionObject & except )
  {
    info->SetProperty( info, VVP_ERROR, except.what() ); 
    return -1;
  }
  return 0;
}


static int UpdateGUI(void *inf)
{
  char tmp[1024];
  vtkVVPluginInfo *info = (vtkVVPluginInfo *)inf;

  info->SetGUIProperty(info, 0, VVP_GUI_LABEL, "Alpha");
  info->SetGUIProperty(info, 0, VVP_GUI_TYPE, VVP_GUI_SCALE);
  info->SetGUIProperty(info, 0, VVP_GUI_DEFAULT, "5");
  info->SetGUIProperty(info, 0, VVP_GUI_HELP, "Factor that defines the width of the Sigmoid in the range scale. Setting a small alpha results in a step transion on the Sigmoid function. A large alpha value produces a very smooth and low slanted Sigmoid.");
  info->SetGUIProperty(info, 0, VVP_GUI_HINTS , "-100 100 0.1");

  info->SetGUIProperty(info, 1, VVP_GUI_LABEL, "Beta");
  info->SetGUIProperty(info, 1, VVP_GUI_TYPE, VVP_GUI_SCALE);
  const float meanValue = (info->InputVolumeScalarTypeRange[1] - 
                           info->InputVolumeScalarTypeRange[0]) / 2.0;
  sprintf(tmp,"%f",meanValue);
  info->SetGUIProperty(info, 1, VVP_GUI_DEFAULT, tmp );
  info->SetGUIProperty(info, 1, VVP_GUI_HELP, "Origin of the Sigmoid function in the range scale. It cooresponds to the intensity of the imput image that will be mapped almost linearly to the output image. Intensities far from this value will be transformed non-linearly.");
  info->SetGUIProperty(info, 1, VVP_GUI_HINTS , VolView::PlugIn::FilterModuleBase::GetInputVolumeScalarTypeRange( info ) );

  // The output image type is equal to the input image type. 
  // We can use then the ranges returned by the GetInput... methods.
  //
  info->SetGUIProperty(info, 2, VVP_GUI_LABEL, "Output Minimum");
  info->SetGUIProperty(info, 2, VVP_GUI_TYPE, VVP_GUI_SCALE);
{'fraction_non_alphanumeric': 0.11228113138239255, 'fraction_numerical': 0.010285294477776418, 'mean_word_length': 3.4367191743617598, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5192767', 'n_tokens_mistral': 2694, 'n_tokens_neox': 2559, 'n_words': 658}