/*========================================================================= 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. =========================================================================*/ /* * Usage: * $ bin/DumpCSA.exe input.dcm */ using System; using gdcm; public class DumpCSA { public static int Main(string[] args) { string filename = args[0]; gdcm.Reader reader = new gdcm.Reader(); reader.SetFileName( filename ); if (!reader.Read()) return 1; gdcm.File f = reader.GetFile(); gdcm.DataSet ds = f.GetDataSet(); string[] expectedSiemensTags = new string[] { "B_value" , "AcquisitionMatrixText" }; using (PrivateTag gtag = CSAHeader.GetCSAImageHeaderInfoTag()) { if (ds.FindDataElement(gtag)) { using (DataElement de = ds.GetDataElement(gtag)) { if (de != null && !de.IsEmpty()) { using (CSAHeader csa = new CSAHeader()) { if (csa.LoadFromDataElement(de)) { foreach (string str in expectedSiemensTags) { if (csa.FindCSAElementByName(str)) { using (CSAElement elem = csa.GetCSAElementByName(str)) { if (elem != null) { System.Console.WriteLine( elem.toString() ); } } } } } } } } } } return 0; } }