+
+
+int main(int argc, char * argv[])
+{
+ GGO(clitkDicomWave2Text, args_info);
+
+ std::ofstream os(args_info.OutputFile_arg, std::ios::out | std::ios::trunc);
+
+ #if GDCM_MAJOR_VERSION < 2
+
+ gdcm::File * mDCMFile = new gdcm::File();
+ mDCMFile->SetFileName(args_info.InputFile_arg);
+ mDCMFile->AddForceLoadElement(0x01e1,0x1018); //Load wave data no matter its size
+ if ( !mDCMFile->OpenFile() )
+ {
+ std::cerr << "Failed to read: " << args_info.InputFile_arg << std::endl;
+ return 1;
+ }
+ mDCMFile->Load();
+ gdcm::DocEntrySet* item = mDCMFile;
+ #define T short
+ gdcm::BinEntry * entry = item->GetBinEntry(0x01e1,0x1018);
+ T* buffer = reinterpret_cast<T*>(entry->GetBinArea());
+ int length=item->GetEntryLength(0x01e1,0x1018)/sizeof(T);
+
+ #else
+
+ gdcm::Reader reader;
+ reader.SetFileName(args_info.InputFile_arg);
+ if( !reader.Read() )
+ {
+ std::cerr << "Failed to read: " << args_info.InputFile_arg << std::endl;
+ return 1;
+ }
+ const gdcm::DataSet& ds = reader.GetFile().GetDataSet();
+ const gdcm::PrivateTag twave(0x01e1,0x18,"ELSCINT1");
+ if( !ds.FindDataElement( twave ) ) return 1;
+ const gdcm::DataElement& wave = ds.GetDataElement( twave );
+ if ( wave.IsEmpty() ) return 1;
+ const gdcm::ByteValue * bv = wave.GetByteValue();
+ short * buffer = (short*)bv->GetPointer();
+ int length = bv->GetLength() / sizeof( short );
+
+ #endif
+
+ // Dump that to a CSV file:
+ wave2stream( os, buffer, length );
+ os.close();
+ return 0;