[Insight-users] how check if dicom exist
Andinet Enquobahrie
andinet.enqu at kitware.com
Fri Oct 7 09:55:30 EDT 2005
Hello Poland,
>How check if i have DICOM series in dir?
>
>(...)
>typedef itk::Image< PixelType, Dimension > ImageType;
>typedef itk::ImageSeriesReader< ImageType > ReaderType;
>typedef itk::GDCMImageIO ImageIOType;
>typedef itk::GDCMSeriesFileNames NamesGeneratorType;
>ImageIOType::Pointer gdcmIO = ImageIOType::New();
>NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
>namesGenerator->SetInputDirectory( argv1 );
>const ReaderType::FileNamesContainer & filenames = namesGenerator->GetInputFileNames(); <- in this place program crash -if I provide dir wher is not series.
>(...)
>
>
>
>
Before invoking the GetInputFileNames() function, it is a good practice
to determine whether dicom series exist in your input directory. To do
that, first generate the series information by invoking
nameGenerator -> SetUserSeriesDetails( true );
and then get seriesUID info...
const std::vector< std::string > & seriesUID = nameGenerator ->
GetSeriesUIDs();
Then check if the container is empty or not
if ( seriesUID.empty() )
{
std::cout << "The directory is empty\n" << std::endl;
return EXIT_FAILURE;
}
By the way, you will also get a warning message if no series were found.
hope that helps..
-Andinet
More information about the Insight-users
mailing list