Hi,
We also addressed the image order problem by writing a UNIX shell script to rename the DICOM files, before using to3d to load images into AFNI. I can't speak for all DICOM formats out there, but it has worked successfully with our DICOM images, which are from a Siemens magnet running a recent upgrade of the Numaris OS. Basically, there is a UID in the text header portion of each DICOM file which contains a sequential number which represents file order. I'll post the script below, although it will probably need tweaks here and there. We are using SGi machines running IRIX 6.5. Some of the command flags may be slightly different in other UNIX/Linux OSes. Not only does the script list images sequentially, but it also adds a two letter suffix to the end of each filename (MP for mprage, EP for echo-planar, and LO for localizer images). These are the 3 main types of sequences we run in a typical scan session. Obviously, our sequence names (also in the dicom header) have this information in them, which is read by the script. Your sequence names will probably differ.
I think we may have posted this some time ago as well. It is slow and simple, but it does work well.
-Tim Souza
#!/bin/sh
echo "_____________________________________________________"
echo " "
echo " dicom_rename"
echo ""
echo " a simple ordered rename of dicom files"
echo " using study instance UID and sequence type."
echo " Tim 4/28/01"
echo "_____________________________________________________"
echo "Enter path where Dicom images are located: \c:"
read path
cd $path
echo "path is `pwd`"
echo ""
echo "reading headers and renaming Dicom images accordingly"
echo ""
sleep 1
for file in `ls`
do
# is the file a dicom image? check for DICM tag
dicom=`strings -ao $file | sed -n '1p' | cut -d " " -f2`
if test "$dicom" != DICM
then
echo $file "is not a dicom image!"
else
idnum=`strings -ao $file | grep 0000200 | cut -d" " -f2 | cut -d. -f12 | cut -c1-11`
strings -ao $file | grep tProtocolName | cut -d= -f2 | grep mpr > /dev/null
if [ "$?" -eq 0 ]
then
echo $file "MPRAGE renamed "$idnum"_MP"
mv $file "$idnum"_MP
else
strings -ao $file | grep tProtocolName | cut -d= -f2 | grep ep > /dev/null
if [ "$?" -eq 0 ]
then
echo $file "echo-planar BOLD renamed "$idnum"_EP"
mv $file "$idnum"_EP
else
strings -ao $file | grep tProtocolName | cut -d= -f2 | grep localizer > /dev/null
if [ "$?" -eq 0 ]
then
echo $file "LOCALIZER renamed "$idnum"_LO"
mv $file "$idnum"_LO
else
echo $file "UNKNOWN DICOM TYPE"
fi
fi
fi
fi
done