[Insight-users] fMRI data

Christopher Wyatt clwyatt at vt.edu
Fri Mar 20 16:13:20 EDT 2009


Delphine,

This is a job for the NaryElevateImageFilter
http://www.insight-journal.org/browse/publication/148

You also need to restrict the series.

Here is an example function that shows the steps.

Best,

-- chris.
-------------------------------------
Christopher Wyatt, clwyatt at vt.edu
Associate Professor
Electrical and Computer Engineering
Virginia Tech

Image4DType::Pointer read_dicom(std::string directory)
{
     // create elevation filter
     itk::NaryElevateImageFilter<Image3DType, Image4DType>::Pointer  
elevateFilter
                 = itk::NaryElevateImageFilter<Image3DType,  
Image4DType>::New();


     // create name generator and attach to reader
     itk::GDCMSeriesFileNames::Pointer nameGenerator =  
itk::GDCMSeriesFileNames::New();
     nameGenerator->SetUseSeriesDetails(true);
     nameGenerator->AddSeriesRestriction("0020|0100"); // acquisition  
number
     nameGenerator->SetDirectory(directory);

     // get series IDs
     const std::vector<std::string>& seriesUID = nameGenerator- 
 >GetSeriesUIDs();

     // create reader array
     itk::ImageSeriesReader<Image3DType>::Pointer *reader =
                 new itk::ImageSeriesReader<Image3DType>::Pointer 
[seriesUID.size()];

     // declare series iterators
     std::vector<std::string>::const_iterator  
seriesItr=seriesUID.begin();
     std::vector<std::string>::const_iterator seriesEnd=seriesUID.end();

     //reorder the input based on temporal number.
     while (seriesItr!=seriesEnd)
     {
         itk::ImageSeriesReader<Image3DType>::Pointer tmp_reader =
                     itk::ImageSeriesReader<Image3DType>::New();

         itk::GDCMImageIO::Pointer dicomIO = itk::GDCMImageIO::New();
         tmp_reader->SetImageIO(dicomIO);

         std::vector<std::string> fileNames;

         fileNames = nameGenerator->GetFileNames(seriesItr->c_str());
         tmp_reader->SetFileNames(fileNames);

         tmp_reader->ReleaseDataFlagOn();

         tmp_reader->Update();
         tmp_reader->GetOutput()->SetMetaDataDictionary(dicomIO- 
 >GetMetaDataDictionary());

         std::string value;
         dicomIO->GetValueFromTag("0020|0100", value);
         printf("Temporal Number: %s\n", value.c_str());

         reader[atoi(value.c_str())-1] = tmp_reader;

         ++seriesItr;
     }

     // connect each series to elevation filter
     for(unsigned int ii=0 ; ii<seriesUID.size() ; ii++) {
         elevateFilter->SetInput(ii,reader[ii]->GetOutput());
     }

     //now elevateFilter can be used just like any other reader
     elevateFilter->Update();

     //create image readers
     Image4DType::Pointer fmri_img = elevateFilter->GetOutput();
     fmri_img->Update();
     return fmri_img;
};


On Mar 20, 2009, at 10:21 AM, insight-users-request at itk.org wrote:

> Message: 2
> Date: Fri, 20 Mar 2009 10:11:39 +0100
> From: delphine.ribes at epfl.ch
> Subject: [Insight-users] fMRI data
> To: "insight-users at itk.org" <insight-users at itk.org>
> Message-ID: <1237540299.49c35dcb2a77d at webmail.epfl.ch>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Dear all,
>
> I am working with DICOM data from fMRI study. I would like to write  
> a nifti
> format image. I know there is a way to encode the 4 dimension in  
> nifti format.
> But when I am using DICOM reader, I have the following error :
>
> Error: In d:\LibImage\Itk\InsightToolkit-3.4.0\Utilities\gdcm\src 
> \gdcmSerieHelpe
> r.cxx, line 663, function  
> gdcm::SerieHelper::ImagePositionPatientOrdering
> File: C:\4.1004.2009.03.10.20.51.18.968750.10546037.IMA Distance: -62
> .2566 position is not unique
>
> This mean that I am not able to distingish from time 1 to time 2.
>
> Do you know if there is a way in ITK to do it ?
>
> Thanks a lot for your help,
> Regards,
> Delphine



More information about the Insight-users mailing list