<commit_before>/** This little program takes a directory and searches for dicom files,
 * from which patient and study information is extracted.
 */

#include "itkCommandLineArgumentParser.h"

#include <itksys/SystemTools.hxx>

#include "itkImageSeriesReader.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"

int main( int argc, char **argv )
{
  /** Create a command line argument parser. */
	itk::CommandLineArgumentParser::Pointer parser = itk::CommandLineArgumentParser::New();
	parser->SetCommandLineArguments( argc, argv );

	/** Get arguments. */
	std::string	inputDirectoryName = "";
	bool retin = parser->GetCommandLineArgument( "-in", inputDirectoryName );

  std::string	seriesNumber = "";
	bool rets = parser->GetCommandLineArgument( "-s", seriesNumber );

  /** Check arguments. */
	if ( !retin )
	{
		std::cerr << "ERROR: You should specify \"-in\"." << std::endl;
		return 1;
	}
	
	if ( argc < 3 || argc > 5 )
	{
    std::cout << "Usage:" << std::endl << "pxgetdicominformation" << std::endl;
    std::cout << "\t-in\tinputDirectoryName" << std::endl;
    std::cout << "\t[-s]\tseriesUID" << std::endl;
    std::cout << "By default the first series encountered is used." << std::endl;
		return 1;
	}

	/** Make sure last character of inputDirectoryName != "/".
	 * Otherwise FileIsDirectory() won't work.
	 */
  if ( inputDirectoryName.rfind( "/" ) == inputDirectoryName.size() - 1 )
  {
    inputDirectoryName.erase( inputDirectoryName.size() - 1, 1 );
  }

  /** Check if inputDirectoryName is a directory. */
  bool exists = itksys::SystemTools::FileExists( inputDirectoryName.c_str() );
  bool isDir = itksys::SystemTools::FileIsDirectory( inputDirectoryName.c_str() );
	isDir &= exists;
  if ( !isDir )
  {
		std::cerr << "ERROR: " << inputDirectoryName
			<< " does not exist or is no directory." << std::endl;
    return 1;
  }

  /** Some typedefs. */
  typedef itk::Image< short, 3>               ImageType;
  typedef itk::ImageSeriesReader< ImageType > SeriesReaderType;
  typedef itk::GDCMImageIO                    GDCMImageIOType;
	typedef itk::GDCMSeriesFileNames            GDCMNamesGeneratorType;
  typedef std::vector< std::string >          FileNamesContainerType;

	/** Get the seriesUIDs from the DICOM directory.<commit_msg>MS:<commit_after>/** This little program takes a directory and searches for dicom files,
 * from which patient and study information is extracted.
 */

#include "itkCommandLineArgumentParser.h"

#include <itksys/SystemTools.hxx>

#include "itkImageSeriesReader.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"

int main( int argc, char **argv )
{
  /** Create a command line argument parser. */
	itk::CommandLineArgumentParser::Pointer parser = itk::CommandLineArgumentParser::New();
	parser->SetCommandLineArguments( argc, argv );

	/** Get arguments. */
	std::string	inputDirectoryName = "";
	bool retin = parser->GetCommandLineArgument( "-in", inputDirectoryName );

  std::string	seriesNumber = "";
	bool rets = parser->GetCommandLineArgument( "-s", seriesNumber );

  /** Check arguments. */
	if ( argc < 3 || argc > 5 )
	{
    std::cout << "Usage:" << std::endl << "pxgetdicominformation" << std::endl;
    std::cout << "\t-in\tinputDirectoryName" << std::endl;
    std::cout << "\t[-s]\tseriesUID" << std::endl;
    std::cout << "By default the first series encountered is used." << std::endl;
		return 1;
	}

  if ( !retin )
	{
		std::cerr << "ERROR: You should specify \"-in\"." << std::endl;
		return 1;
	}

	/** Make sure last character of inputDirectoryName != "/".
	 * Otherwise FileIsDirectory() won't work.
	 */
  if ( inputDirectoryName.rfind( "/" ) == inputDirectoryName.size() - 1 )
  {
    inputDirectoryName.erase( inputDirectoryName.size() - 1, 1 );
  }

  /** Check if inputDirectoryName is a directory. */
  bool exists = itksys::SystemTools::FileExists( inputDirectoryName.c_str() );
  bool isDir = itksys::SystemTools::FileIsDirectory( inputDirectoryName.c_str() );
	isDir &= exists;
  if ( !isDir )
  {
		std::cerr << "ERROR: " << inputDirectoryName
			<< " does not exist or is no directory." << std::endl;
    return 1;
  }

  /** Some typedefs. */
  typedef itk::Image< short, 3>               ImageType;
  typedef itk::ImageSeriesReader< ImageType > SeriesReaderType;
  typedef itk::GDCMImageIO                    GDCMImageIOType;
	typedef itk::GDCMSeriesFileNames            GDCMNamesGeneratorType;
  typedef std::vector< std::string >          FileNamesContainerType;

	/** Get the seriesUIDs from the DICOM directory.
{'fraction_non_alphanumeric': 0.14628244610646723, 'fraction_numerical': 0.003959524857017158, 'mean_word_length': 3.7812828601472135, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 19, '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': '6073584', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1402, 'n_words': 363}