[Insight-developers] Reading GE files

Hans Johnson hans-johnson at uiowa.edu
Thu Oct 21 08:58:54 EDT 2010


Richard,

My guess is that very little information will end up in the dictionary (if
any at all).  The GEAdw, and GEN file readers are pretty bare bones.



If you need values like TE/TR/Flip angle out of these files, you may
consider converting them to dicom with David Clunies dicom3tools
http://www.dclunie.com/dicom3tools.html:
NOTE:  GE reports fieldstrength in Gauss not Tesla, so the dicom files will
report 1.5T as 15000T in the dicom file.
===================
Here's an ugly script I once used to do this:

#!/bin/bash
# \author Hans J Johnson, The University of Iowa
# Usage: gentodc.dat.all dirname
#
# where dirname is the directory name where images are
#
# converts files in place and adds .dcm extension
#

if [ ! -f ${DCMDICTPATH} ] ; then
  export  DCMDICTPATH=/opt/dcmtk/lib/dicom.dic
fi
if [ ! -f ${DCMDICTPATH} ] ; then
  export  DCMDICTPATH=/opt/dcmtk/share/dcmtk/dicom.dic
fi

if [ ! -f ${DCMDICTPATH} ] ; then
  echo "ERROR:  can not find ${DCMDICTPATH}"
  exit -1
fi

STAMP=`date +%Y%m%d%H%M%S`.$$

GENTODC="/opt/dicom3tools/bin/gentodc"
GAWTODC="/opt/dicom3tools/bin/gawtodc -awmr"

rm -f mylogger

check_valid() {
 width=$(cat $1|grep "width (pixels) of image (IH_img_width)" |sed
"s/.*<\([^>]*\)>/\1/g")
 height=$(cat $1|grep "height (pixels) of image (IH_img_height)" |sed
"s/.*<\([^>]*\)>/\1/g")
 depth=$(cat $1|grep "depth (1, 8, 16, or 24 bits) of (IH_img_depth)" |sed
"s/.*<\([^>]*\)>/\1/g")
 echo "------ $width $height $depth $1" >>mylogger

 depth_ok="false";
 if [ ! -z "$depth" ] && ( [ $depth == 1 ] || [ $depth == 8 ] || [ $depth ==
16 ] || [ $depth == 24 ] ); then
    depth_ok="true";
 fi
 width_ok="false"
 if [ ! -z "$width" ] && ( [ $width -lt 513 ] && [ $width -gt 31 ] ); then
    width_ok="true";
 fi
 height_ok="false"
 if [ ! -z "$height" ]  && ( [ $height -lt 513 ] && [ $height -gt 31 ] );
then
    height_ok="true";
 fi
 if [ "$height_ok" == "true" ] && [ "$width_ok" == "true" ] && [ "$depth_ok"
== "true" ]; then
 echo "++++++ $width_ok $height_ok  $depth_ok" >> mylogger
  echo "true";
  return
 fi
 echo "false";
}

get_type() {
   curr_file=$1
   file ${1}|grep "DICOM" > /dev/null 2>&1
   dicom_check_status=$?
   if [ ${dicom_check_status} -eq 0 ];then
     echo "dicom"
     return
   fi

   /opt/dicom3tools/bin/gawdump -awmr $1 > ${1}.log
   valid=$(check_valid ${1}.log)
   echo "@@@@ $valid" >> mylogger
   if [ "$valid" == "true" ]; then
      echo "gawtodc"
      rm -f ${1}.log
      return
   fi

   /opt/dicom3tools/bin/gendump $1 > ${1}.log
   valid=$(check_valid ${1}.log)
   if [ "$valid" == "true" ]; then
      echo "gentodc"
      rm -f ${1}.log
      return
   fi

  echo "NOMATCHINGTYPEFOUND"
  rm -f ${1}.log
  return
}

if [ ! $# = 1 ]
then
  echo 1>&2 "Usage: `basename $0` dirname"
  exit 1
fi

if [ ! -d $1 ]; then
  echo 1>&2 "Must be a directory"
  exit 1
fi

find $1 -size 0 -exec rm {} \;

## If even one file needs to be converted, then all files need to be
converted.
ALL_FILES_GOOD="true"
for i in `find "$1" -type f -print`; do
  echo ${i} |grep "dicom.dcm" > /dev/null 2>&1
  if [ $? -eq 0 ] || [ -f ${i}.dicom.dcm ]; then
    echo "SKIPPING: ${i}"
    continue;
  fi
  if [ -f ${i}.gentodc.dcm ] ; then
    echo "SKIPPING: ${i} because ${i}.gentodc.dcm already exists"
    continue;
  fi
  if [ -f ${i}.gawtodc.dcm ]; then
    echo "SKIPPING: ${i} because ${i}.gawtodc.dcm"
    continue;
  fi
  echo ${i} |grep "todc.dcm" > /dev/null 2>&1
  if [ $? -eq 0 ] || [ -f ${i}.gentodc.dcm ] || [ -f ${i}.gawtodc.dcm ];
then
    echo "SKIPPING: ${i}"
    continue;
  fi
  if [ -f "$i" ]; then
    curr_type=$(get_type $i)
    DCMSUFFIX="${curr_type}.dcm"
    BIN=echo
    if [ "$curr_type" == "gawtodc" ]; then
      BIN=$GAWTODC
      ALL_FILES_GOOD=false
    fi
    if [ "$curr_type" == "gentodc" ]; then
      BIN=$GENTODC
      ALL_FILES_GOOD="false"
    fi
  fi
done

## Now convert all the files
if [ "${ALL_FILES_GOOD}" == "false" ]; then
  for i in `find "$1" -type f -print`; do
    if [ -f "${i}" ]; then
      echo ${i} |grep "dicom.dcm" > /dev/null 2>&1
      if [ $? -eq 0 ]; then
        echo "SKIPPING: ${i}"
        continue;
      fi
      echo ${i} |grep "todc.dcm" > /dev/null 2>&1
      if [ $? -eq 0 ]; then
        echo "SKIPPING: ${i}"
        continue;
      fi
      curr_type=$(get_type $i)
      DCMSUFFIX="${curr_type}.dcm"
      BIN=echo
      if [ "$curr_type" == "gawtodc" ]; then
        BIN=$GAWTODC
      fi
      if [ "$curr_type" == "gentodc" ]; then
        BIN=$GENTODC
      fi
      if [ ! -f $i.$DCMSUFFIX ]; then
        echo "Converting $i to $i.$DCMSUFFIX"
        echo ${curr_type}
        ## NOTE: -stamp is needed so that all files·
        ## in this one directory end up in the same dicom series
        $BIN -stamp ${STAMP} -if $i -of $i.$DCMSUFFIX
      fi
    fi
  done
fi

find $1 -size 0 -exec rm {} \;
exit 0











On 10/21/10 1:06 AM, "Richard Beare" <richard.beare at gmail.com> wrote:

> Hi,
> I'm playing with a variety of GE files. I'm not familiar with GE
> format at all, so I'm not yet sure whether these are GE4 GE5 or GEAdw.
> It looks as these files do come in a series, like dicom, and so I
> probably to use a series reader of some sort. Does anyone have any
> experience with this at all? I'm looking at the code now to try to
> figure out how much information is ending up in the dictionary.
> 
> Thanks
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20101021/f55c038f/attachment-0001.htm>


More information about the Insight-developers mailing list