GDCM  2.4.5
DumpToshibaDTI.cxx
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*
* https://groups.google.com/d/msg/comp.protocols.dicom/7IaIkT0ZG5U/k7LPu81VvAMJ
*/
#include "gdcmReader.h"
#include "gdcmPrivateTag.h"
#include "gdcmPrinter.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <assert.h>
bool DumpToshibaDTI( const char * input, size_t len )
{
if( len % 2 ) return false;
std::vector<char> copy( input, input + len );
std::reverse( copy.begin(), copy.end() );
std::istringstream is;
std::string dup( &copy[0], copy.size() );
is.str( dup );
gdcm::Reader reader;
reader.SetStream( is );
if( !reader.Read() )
return false;
//std::cout << reader.GetFile().GetDataSet() << std::endl;
//gdcm::DictPrinter p;
p.SetFile( reader.GetFile() );
p.SetColor( true );
p.Print( std::cout );
return true;
}
int main(int argc, char *argv[])
{
if( argc < 2 ) return 1;
const char *filename = argv[1];
gdcm::Reader reader;
reader.SetFileName( filename );
if( !reader.Read() )
{
std::cerr << "Failed to read: " << filename << std::endl;
return 1;
}
const gdcm::DataSet& ds = reader.GetFile().GetDataSet();
// (0029,0010) ?? (LO) [PMTF INFORMATION DATA ] # 22,1 Private Creator
// (0029,1001) ?? (SQ) (Sequence with undefined length) # u/l,1 ?
const gdcm::PrivateTag tpmtf(0x0029,0x1,"PMTF INFORMATION DATA");
if( !ds.FindDataElement( tpmtf) ) return 1;
const gdcm::DataElement& pmtf = ds.GetDataElement( tpmtf );
if ( pmtf.IsEmpty() ) return 1;
if ( !seq || !seq->GetNumberOfItems() ) return 1;
size_t n = seq->GetNumberOfItems();
for( size_t i = 1; i <= n; ++i )
{
gdcm::Item &item = seq->GetItem(i);
// (0029,0010) ?? (LO) [PMTF INFORMATION DATA ] # 22,1 Private Creator
// (0029,1090) ?? (OB) 00\05\00\13\00\12\00\22\ # 202,1 ?
const gdcm::PrivateTag tseq(0x0029,0x90,"PMTF INFORMATION DATA");
if( subds.FindDataElement( tseq ) )
{
const gdcm::DataElement & de = subds.GetDataElement( tseq );
const gdcm::ByteValue * bv = de.GetByteValue();
if( !bv ) return 1;
bool b = DumpToshibaDTI( bv->GetPointer(), bv->GetLength() );
if( !b ) return 1;
}
}
return 0;
}

Generated on Fri Sep 25 2015 17:58:19 for GDCM by doxygen 1.8.9.1
SourceForge.net Logo