<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=Dicom_dir_to_analyze</id>
	<title>Dicom dir to analyze - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.scott5.org/index.php?action=history&amp;feed=atom&amp;title=Dicom_dir_to_analyze"/>
	<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=Dicom_dir_to_analyze&amp;action=history"/>
	<updated>2026-05-10T00:39:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://wiki.scott5.org/index.php?title=Dicom_dir_to_analyze&amp;diff=95&amp;oldid=prev</id>
		<title>Scott: Created page with &#039;&lt;source lang=&quot;bash&quot;&gt; #!/bin/bash  usage () { 	echo 	echo &quot;Usage:&quot; 	echo &quot;	`basename $0` &lt;dicom dir&gt;&quot; 	echo &quot;	This script searches through &lt;dicom dir&gt; for DICOM files&quot; 	echo &quot;	(e.…&#039;</title>
		<link rel="alternate" type="text/html" href="https://wiki.scott5.org/index.php?title=Dicom_dir_to_analyze&amp;diff=95&amp;oldid=prev"/>
		<updated>2011-01-31T17:40:09Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; #!/bin/bash  usage () { 	echo 	echo &amp;quot;Usage:&amp;quot; 	echo &amp;quot;	`basename $0` &amp;lt;dicom dir&amp;gt;&amp;quot; 	echo &amp;quot;	This script searches through &amp;lt;dicom dir&amp;gt; for DICOM files&amp;quot; 	echo &amp;quot;	(e.…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
usage () {&lt;br /&gt;
	echo&lt;br /&gt;
	echo &amp;quot;Usage:&amp;quot;&lt;br /&gt;
	echo &amp;quot;	`basename $0` &amp;lt;dicom dir&amp;gt;&amp;quot;&lt;br /&gt;
	echo &amp;quot;	This script searches through &amp;lt;dicom dir&amp;gt; for DICOM files&amp;quot;&lt;br /&gt;
	echo &amp;quot;	(e.g. 00001.dcm).  It creates a new directory called&amp;quot;&lt;br /&gt;
	echo &amp;quot;	&amp;lt;dicom dir&amp;gt;-analyze and places converted Analyze files in&amp;quot;&lt;br /&gt;
	echo &amp;quot;	corresponding locations there.&amp;quot;&lt;br /&gt;
	echo&lt;br /&gt;
	exit 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if [[ ! -x `which dicom2analyze` ]]; then&lt;br /&gt;
	echo &amp;quot;ERROR: can&amp;#039;t find dicom2analyze binary.&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# check number of arguments&lt;br /&gt;
if (( $# != 1)); then&lt;br /&gt;
	usage&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# check dicom_dir&lt;br /&gt;
dicom_dir_input=$1&lt;br /&gt;
if [[ ! -d $dicom_dir_input ]]; then&lt;br /&gt;
	echo&lt;br /&gt;
	echo &amp;quot;	ERROR: $dicom_dir_input is not a valid directory&amp;quot;&lt;br /&gt;
	usage&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# move to parent directory&lt;br /&gt;
cd $dicom_dir_input/..&lt;br /&gt;
dicom_dir=`basename $dicom_dir_input`&lt;br /&gt;
analyze_dir=&amp;quot;${dicom_dir}-analyze&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# create parallel directory structure&lt;br /&gt;
for dicom_subdir in `find $dicom_dir -name *.dcm -exec dirname {} \; | sort -u`&lt;br /&gt;
do&lt;br /&gt;
	newdir=${analyze_dir}${dicom_subdir#&amp;quot;$dicom_dir&amp;quot;}&lt;br /&gt;
	mkdir -p $newdir&lt;br /&gt;
	if (( $? != 0 )); then&lt;br /&gt;
		echo&lt;br /&gt;
		echo &amp;quot;ERROR: failed to create $newdir.&amp;quot;&lt;br /&gt;
		echo &amp;quot;Do you have write permissions here?&amp;quot;&lt;br /&gt;
		usage&lt;br /&gt;
	fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# create analyze files&lt;br /&gt;
for dicom_file in `find $dicom_dir -name *.dcm -print`&lt;br /&gt;
do&lt;br /&gt;
	analyze_prefix=${analyze_dir}${dicom_file#&amp;quot;$dicom_dir&amp;quot;}&lt;br /&gt;
	`dicom2analyze $dicom_file $analyze_prefix`&lt;br /&gt;
	if (( $? != 0 )); then&lt;br /&gt;
		echo&lt;br /&gt;
		echo &amp;quot;ERROR: failed to convert $dicom_file&amp;quot;&lt;br /&gt;
		echo &amp;quot;Please contact the system administrator.&amp;quot;&lt;br /&gt;
		echo&lt;br /&gt;
		exit 1&lt;br /&gt;
	fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Scott</name></author>
	</entry>
</feed>