<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Batch processing</title>
	<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/</link>
	<description>Steve Eddins manages the Image &#38; Geospatial development team at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62; and coauthored &#60;a href="http://www.mathworks.com/support/books/book5291.html?category=-1&#38;language=-1"&#62;Digital Image Processing Using MATLAB&#60;/a&#62;. He writes here about image processing concepts, algorithm implementations, and MATLAB.&#60;br&#62;&#60;br&#62;&#60;img&#62;</description>
	<pubDate>Sun, 22 Nov 2009 23:18:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Sana</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22367</link>
		<dc:creator>Sana</dc:creator>
		<pubDate>Wed, 18 Nov 2009 17:59:16 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22367</guid>
		<description>hi steve,

could you explain to me how i would be able to use the dir function, to do a loop through a directory and all of the subfolders in the directory for files that have the following format.

i have several subfolders in my directory. specifically ones that correspond to a date (ie. 20091011), and in each of those folders, there are several subfolders corresponding to a specific image set. In each of those folders are about 47 files, and I need to process the most recent/the last file in those folders

I00000XX (XX = is a series of numbers corresponding to the file name).... there is no file extension. (its a DICOM file).

The subfolders are as follows:

ImageData (contains 1 folder) &#62; MDX1 (contains one folder) &#62; image (contains several folders, each corresponding to a date) &#62; 20091002 (contains several folders, each corresponding to a image set) &#62; E0000012 &#62; all of the files, of which the last file is the file I need.

I want to create a list of sorts of all of these files (ie, path).

Then I want to run an executable on all of these files, to get an output that i can save in matrix form

thanks much!</description>
		<content:encoded><![CDATA[<p>hi steve,</p>
<p>could you explain to me how i would be able to use the dir function, to do a loop through a directory and all of the subfolders in the directory for files that have the following format.</p>
<p>i have several subfolders in my directory. specifically ones that correspond to a date (ie. 20091011), and in each of those folders, there are several subfolders corresponding to a specific image set. In each of those folders are about 47 files, and I need to process the most recent/the last file in those folders</p>
<p>I00000XX (XX = is a series of numbers corresponding to the file name)&#8230;. there is no file extension. (its a DICOM file).</p>
<p>The subfolders are as follows:</p>
<p>ImageData (contains 1 folder) &gt; MDX1 (contains one folder) &gt; image (contains several folders, each corresponding to a date) &gt; 20091002 (contains several folders, each corresponding to a image set) &gt; E0000012 &gt; all of the files, of which the last file is the file I need.</p>
<p>I want to create a list of sorts of all of these files (ie, path).</p>
<p>Then I want to run an executable on all of these files, to get an output that i can save in matrix form</p>
<p>thanks much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22100</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Wed, 09 Sep 2009 11:42:47 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22100</guid>
		<description>Kaniska&#8212;Can you be more specific?  Why are you unable to process the files in batch?</description>
		<content:encoded><![CDATA[<p>Kaniska&mdash;Can you be more specific?  Why are you unable to process the files in batch?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kaniska Mallick</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22099</link>
		<dc:creator>Kaniska Mallick</dc:creator>
		<pubDate>Wed, 09 Sep 2009 08:37:34 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22099</guid>
		<description>Hi Steve

I am trying for batch processing using some satellite data whose names are as follows for example

ID2r1-AMSRE-D.252004150A.v03.10V
ID2r1-AMSRE-D.252004150A.v03.89V
ID2r1-AMSRE-D.252004150D.v03.10V
ID2r1-AMSRE-D.252004150D.v03.89V
ID2r1-AMSRE-D.252004151A.v03.89V

etc.

these are the examples of files. I am unable to process them in batch. Although I could read them individually and then save them in mat format. But it takes time and I want to do batch processing and the necessary computations. May I ask your help?</description>
		<content:encoded><![CDATA[<p>Hi Steve</p>
<p>I am trying for batch processing using some satellite data whose names are as follows for example</p>
<p>ID2r1-AMSRE-D.252004150A.v03.10V<br />
ID2r1-AMSRE-D.252004150A.v03.89V<br />
ID2r1-AMSRE-D.252004150D.v03.10V<br />
ID2r1-AMSRE-D.252004150D.v03.89V<br />
ID2r1-AMSRE-D.252004151A.v03.89V</p>
<p>etc.</p>
<p>these are the examples of files. I am unable to process them in batch. Although I could read them individually and then save them in mat format. But it takes time and I want to do batch processing and the necessary computations. May I ask your help?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22055</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Mon, 17 Aug 2009 17:27:51 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22055</guid>
		<description>Sree&#8212;The &lt;tt&gt;dir&lt;/tt&gt; function returns a structure array containing the filenames and other information about the file.

&lt;pre&gt;
s = dir('*.jpg');
&lt;/pre&gt;

You can combine the filenames into a single cell array using the comma-separated list syntax for structures:

&lt;pre&gt;
names = {s.name};
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Sree&mdash;The <tt>dir</tt> function returns a structure array containing the filenames and other information about the file.</p>
<pre>
s = dir('*.jpg');
</pre>
<p>You can combine the filenames into a single cell array using the comma-separated list syntax for structures:</p>
<pre>
names = {s.name};
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sree</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22040</link>
		<dc:creator>Sree</dc:creator>
		<pubDate>Mon, 10 Aug 2009 08:24:51 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-22040</guid>
		<description>I am a beginner and I am trying to read some file names in a directory and save it in an array variable.
Can anyone help me?</description>
		<content:encoded><![CDATA[<p>I am a beginner and I am trying to read some file names in a directory and save it in an array variable.<br />
Can anyone help me?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21945</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Mon, 06 Jul 2009 15:23:44 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21945</guid>
		<description>Camilo&#8212;The function &lt;tt&gt;imwrite&lt;/tt&gt; takes a matrix of pixel values.  In your first attempt, you were passing it the handle of a MATLAB graphics object, and &lt;tt&gt;imwrite&lt;/tt&gt; interpreted that as a single-pixel image.</description>
		<content:encoded><![CDATA[<p>Camilo&mdash;The function <tt>imwrite</tt> takes a matrix of pixel values.  In your first attempt, you were passing it the handle of a MATLAB graphics object, and <tt>imwrite</tt> interpreted that as a single-pixel image.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Camilo</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21940</link>
		<dc:creator>Camilo</dc:creator>
		<pubDate>Sat, 04 Jul 2009 19:39:20 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21940</guid>
		<description>Steve !!!

I changed imwrite for saveas and it worked !!!

Thanks for showing us your code. It was very helpful.

Camilo</description>
		<content:encoded><![CDATA[<p>Steve !!!</p>
<p>I changed imwrite for saveas and it worked !!!</p>
<p>Thanks for showing us your code. It was very helpful.</p>
<p>Camilo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Camilo</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21939</link>
		<dc:creator>Camilo</dc:creator>
		<pubDate>Sat, 04 Jul 2009 19:33:20 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21939</guid>
		<description>Steve,

Your code is working almost perfectly, but, whenever I go to the folder where I am storing the images I cannot see them. The files are there, but the images are blank. I am using Windows Picture and Fax viewer to open them. I can't figure out if there is something with the code or there is something wrong with the Windows Picture and Fax viewer. This is the code I am using:

close all
files = dir ('D:\Users\Camilo\Matlab Programs\*.bmp');

for k = 1:numel(files)
    
A = imread(files(k).name);
% A = im2double(A);

A2 = imcrop(A,[30 25 1152 928]);
A3 = imcrop (A2,[539 165 1152 928]);

[ypix,xpix] = size (A3);

xdim = 1.98; 
ydim =(ypix/xpix)*xdim;
xstart = -1;
ystart =(892-904)*(xdim/xpix);
x = 1.006;

A3 = imagesc([xstart x],[ydim ystart], A3);

grid on;
axis image;
axis xy;
xlabel('Axial Distance, in')
ylabel('Vertical Distance, in')
colormap(gray); 

imwrite(A3, ['D:\Users\Camilo\Matlab Programs\Cropped\'files(k).name],'bmp' )

end

Let me know what you think when you can. Thanks in advance. 

Camilo</description>
		<content:encoded><![CDATA[<p>Steve,</p>
<p>Your code is working almost perfectly, but, whenever I go to the folder where I am storing the images I cannot see them. The files are there, but the images are blank. I am using Windows Picture and Fax viewer to open them. I can&#8217;t figure out if there is something with the code or there is something wrong with the Windows Picture and Fax viewer. This is the code I am using:</p>
<p>close all<br />
files = dir (&#8217;D:\Users\Camilo\Matlab Programs\*.bmp&#8217;);</p>
<p>for k = 1:numel(files)</p>
<p>A = imread(files(k).name);<br />
% A = im2double(A);</p>
<p>A2 = imcrop(A,[30 25 1152 928]);<br />
A3 = imcrop (A2,[539 165 1152 928]);</p>
<p>[ypix,xpix] = size (A3);</p>
<p>xdim = 1.98;<br />
ydim =(ypix/xpix)*xdim;<br />
xstart = -1;<br />
ystart =(892-904)*(xdim/xpix);<br />
x = 1.006;</p>
<p>A3 = imagesc([xstart x],[ydim ystart], A3);</p>
<p>grid on;<br />
axis image;<br />
axis xy;<br />
xlabel(&#8217;Axial Distance, in&#8217;)<br />
ylabel(&#8217;Vertical Distance, in&#8217;)<br />
colormap(gray); </p>
<p>imwrite(A3, [&#8217;D:\Users\Camilo\Matlab Programs\Cropped\&#8217;files(k).name],&#8217;bmp&#8217; )</p>
<p>end</p>
<p>Let me know what you think when you can. Thanks in advance. </p>
<p>Camilo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21742</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Fri, 08 May 2009 15:32:53 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21742</guid>
		<description>Ian&#8212;When you use &lt;tt&gt;save&lt;/tt&gt; with just the output filename and the -ascii option, it tries to save ALL the variables in the current workspace to the file.  That's almost certainly not what you intended.  Also, the code that you included in your comment shows no call to &lt;tt&gt;load&lt;/tt&gt;, so I have no where your script is getting the data you are trying to save.  But generally, you'll need to call &lt;/tt&gt;load&lt;/tt&gt; to read into a variable, and then supply the variable name in the call to &lt;tt&gt;save&lt;/tt&gt;.  Check the documentation for both &lt;tt&gt;load&lt;/tt&gt; and &lt;tt&gt;save&lt;/tt&gt;.</description>
		<content:encoded><![CDATA[<p>Ian&mdash;When you use <tt>save</tt> with just the output filename and the -ascii option, it tries to save ALL the variables in the current workspace to the file.  That&#8217;s almost certainly not what you intended.  Also, the code that you included in your comment shows no call to <tt>load</tt>, so I have no where your script is getting the data you are trying to save.  But generally, you&#8217;ll need to call load to read into a variable, and then supply the variable name in the call to <tt>save</tt>.  Check the documentation for both <tt>load</tt> and <tt>save</tt>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian</title>
		<link>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21712</link>
		<dc:creator>Ian</dc:creator>
		<pubDate>Mon, 27 Apr 2009 17:09:21 +0000</pubDate>
		<guid>http://blogs.mathworks.com/steve/2006/06/06/batch-processing/#comment-21712</guid>
		<description>HI Steve,

I am new to MATLAB, and am trying to process some matrices, using the batch commands, roughly as you have outlined above.  I have a number of .MAT files that were generated by a different program and I am trying to export the matrices (480x640 double) to individual ascii files.  I am able to export a single file using 
&#62;save('NEW0470','-ASCII).  But have been unsuccessful to run this in a batch command format.  I am also trying to change the file extension to .txt,  Below are 2 examples of the scripts I have been trying to run, it seems that the  renaming process is working well, but every time I try to run it, I get a warning message telling me 

"Warning: Attempt to write an unsupported data type to an ASCII file.
	Variable 'files' not written to file. 

Entire scrip:

&lt;pre&gt;
files = dir('NEW*');
for k = 1:numel(files)
    input_name = files(k).name
    [path, name, extension] = fileparts(input_name)
    output_name = fullfile(path, [name '.txt'])
    save(files(k).name,'-ASCII')
end
&lt;/pre&gt;

Subset that I tried as well, just to run the export function:

&lt;pre&gt;
files = dir('NEW*');
for k = 1:numel(files)
    save(files(k).name,'-ASCII')
end
&lt;/pre&gt;

Not sure if this makes any sens to you, but if you have a chance to take a look and let me know what you think, would be fantastic.

Best regards,
Ian</description>
		<content:encoded><![CDATA[<p>HI Steve,</p>
<p>I am new to MATLAB, and am trying to process some matrices, using the batch commands, roughly as you have outlined above.  I have a number of .MAT files that were generated by a different program and I am trying to export the matrices (480&#215;640 double) to individual ascii files.  I am able to export a single file using<br />
&gt;save(&#8217;NEW0470&#8242;,&#8217;-ASCII).  But have been unsuccessful to run this in a batch command format.  I am also trying to change the file extension to .txt,  Below are 2 examples of the scripts I have been trying to run, it seems that the  renaming process is working well, but every time I try to run it, I get a warning message telling me </p>
<p>&#8220;Warning: Attempt to write an unsupported data type to an ASCII file.<br />
	Variable &#8216;files&#8217; not written to file. </p>
<p>Entire scrip:</p>
<pre>
files = dir('NEW*');
for k = 1:numel(files)
    input_name = files(k).name
    [path, name, extension] = fileparts(input_name)
    output_name = fullfile(path, [name '.txt'])
    save(files(k).name,'-ASCII')
end
</pre>
<p>Subset that I tried as well, just to run the export function:</p>
<pre>
files = dir('NEW*');
for k = 1:numel(files)
    save(files(k).name,'-ASCII')
end
</pre>
<p>Not sure if this makes any sens to you, but if you have a chance to take a look and let me know what you think, would be fantastic.</p>
<p>Best regards,<br />
Ian</p>
]]></content:encoded>
	</item>
</channel>
</rss>
