[ITK] How to get a vector of DICOM Series description strings in ITKv4 (GDCM 2.x)?
Sebastian Ordas
sebastian.ordas at gmail.com
Wed Dec 3 11:43:26 EST 2014
Hi Matt,
several issues: the GDCM API has changed in 2.x
For instance, gdcm::DirList does not exist anymore, same for
m_GDCMHelper->AddFileName(), etc
I would also like to know whether to put the efforts on GDCM or DCMTK (I
have seen a gdcm::SerieHelper2 class in plastimach that is worthy to
explore)
... but there should be some basic functionality / approach already
available for such a simple and general action (i.e. explore available
DICOM Series and/or Studies in a folder with DICOM files)
let me know if you have some useful links (I don´'t want to link against
CTK in my app)
thanks
sebastian
On 03/12/2014 01:30 p.m., Matt McCormick wrote:
> 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