[ITK] How to get a vector of DICOM Series description strings in ITKv4 (GDCM 2.x)?

Matt McCormick matt.mccormick at kitware.com
Wed Dec 3 11:30:57 EST 2014


Hi Sebastian,

What specifically is the issue using this code with ITKv4?

Thanks,
Matt

On Wed, Dec 3, 2014 at 11:21 AM, Sebastian Ordas
<sebastian.ordas at gmail.com> wrote:
> Dear All,
>
> I used to be able with ITK 3.12 (GDCM 1.x) to populate a vector with series
> description strings, recursively, given the path to a folder with DICOM
> files.
> The goal is to fill in an "Open DICOM" dialog with such information, in
> order to let the user load a single DICOM Series.
> How can I do that with ITKv4 (GDCM 2.x)?
>
> thank you,
> sebastian
>
> Here´s my original code:
>
> typedef gdcm::FileList DICOMFileListType;
>
> m_GDCMScanner = itk::GDCMSeriesFileNames::New();
> m_GDCMScanner->SetUseSeriesDetails(true);
> m_GDCMScanner->LoadPrivateTagsOff();
> m_GDCMHelper = m_GDCMScanner->GetSeriesHelper();
>
> m_GDCMScanner->SetInputDirectory( m_ImageDirectoryName );
>
> if (!itksys::SystemTools::FileExists (ImageDirectoryName ))
>     {
>         return;
>     }
>
> // we now scan from scratch all dicom file headers
> try
> {
>     this->m_GDCMHelper->Clear();
>
>     unsigned long counter_im = 0;
>     gdcm::DirList dirlist(dirname, m_UseRecursiveScan);
>
>     gdcm::DirListType filenames_list = dirlist.GetFilenames();
>
>     unsigned long totalImages = filenames_list.size();
>     if (totalImages<10)
>         return;
>
>     for( gdcm::DirListType::const_iterator it = filenames_list.begin();
>         it != filenames_list.end(); ++it)
>     {
>       if (itksys::SystemTools::FileExists ((*it).c_str(), true))
>           m_GDCMHelper->AddFileName ((*it));
>       counter_im++;
>     }
> }
> catch (itk::ExceptionObject & excp)
> {
>   return;
> }
>
> std::vector<std::string> UIDs;
> UIDs = m_GDCMScanner->GetSeriesUIDs();
>
> if (!UIDs.size())
> return;
>
>     try
>     {
>         m_SeriesNames.clear();
>
>         int nSeries = 0;
>
>         for (unsigned int uid=0; uid<UIDs.size(); uid++)
>         {
>             std::string uidname = UIDs[uid];
>             DICOMFileListType* t_filelist =
> m_GDCMHelper->GetSingleSerieUIDFileSet(uidname);
>             this->m_GDCMHelper->OrderFileList (t_filelist);
>
>             DICOMFileListType::iterator it;
>             it = t_filelist.begin();
>
>             for (; it != t_filelist.end(); it++)
>             {
>                 DICOMFileListType* filelist = (*it);
>                 if ( !filelist->size() )
>                 {
>                 continue;
>                 }
>                 std::stringstream stream;
>                 stream << "series# " << nSeries << ": " <<
> this->GenerateName(filelist) << " (" << filelist->size() << " slices)";
>                 m_SeriesNames.push_back( stream.str() );
>                 nSeries++;
>             }
>         }
>     }
>     catch (itk::ExceptionObject & excp)
>     {
>         return;
>     }
>
> template <class TPixelType>
> std::string DICOMImageReader<TPixelType>::GenerateName (DICOMFileListType*
> filelist)
> {
>   std::string description = (*filelist)[0]->GetEntryValue(0x0008, 0x103E);
>   if (description == gdcm::GDCM_UNFOUND)
>   {
>     (*filelist)[0]->Load();
>     description = (*filelist)[0]->GetEntryValue(0x0008, 0x103E);
>   }
>   return description;
> }
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community


More information about the Community mailing list