+2003-03-26 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
+ * src/gdcmHeader[h, cxx] gdcmHeader now has an IsReadable predicate.
+ * gdcmPython/demo/test.py changed accordingly.
+
2003-03-25 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
* gdcmPython/Makefile.am fixed linking against libstdc++
* gdcmPython/_gdcm.so symbolic link to gdcmPython/.libs/pygdcm.so added.
from gdcmPython import *
+import sys
### Get filename from command line or default it
try:
### Build the header element list
toRead = gdcmHeader(FileName)
+if not toRead.IsReadable():
+ print "The ", FileName, " file is not "
+ print " readable with gdcm. Sorry."
+ sys.exit()
print "##############################################################"
print "### Display all the elements and their respective values"
fseek(fp, (long)ElVal->GetOffset(), SEEK_SET);
- // Sequences not treated yet !
+ // FIXME Sequences not treated yet !
//
// Ne faudrait-il pas au contraire trouver immediatement
// une maniere 'propre' de traiter les sequences (vr = SQ)
// car commencer par les ignorer risque de conduire a qq chose
// qui pourrait ne pas etre generalisable
- //
+ // Well, I'm expecting your code !!!
+
if( vr == "SQ" )
SkipLoad = true;
NewElVal->SetValue("0");
}
+/**
+ * \ingroup gdcmHeader
+ * \brief This predicate, based on hopefully reasonnable heuristics,
+ * decides whether or not the current gdcmHeader was properly parsed
+ * and contains the mandatory information for being considered as
+ * a well formed and usable image.
+ * @return true when gdcmHeader is the one of a reasonable Dicom file,
+ * false otherwise.
+ */
+bool gdcmHeader::IsReadable(void) {
+ if ( GetElValByName("Image Dimensions") != "gdcm::Unfound"
+ && atoi(GetElValByName("Image Dimensions").c_str()) > 4 ) {
+ return false;
+ }
+ if ( GetElValByName("Bits Allocated") == "gdcm::Unfound" )
+ return false;
+ if ( GetElValByName("Bits Stored") == "gdcm::Unfound" )
+ return false;
+ if ( GetElValByName("High Bit") == "gdcm::Unfound" )
+ return false;
+ if ( GetElValByName("Pixel Representation") == "gdcm::Unfound" )
+ return false;
+ return true;
+}
+
+
/**
* \ingroup gdcmHeader
* \brief Small utility function that creates a new manually crafted