Re: Beginner--how to import a series of files?
- To: mathgroup at smc.vnet.net
- Subject: [mg63834] Re: [mg63833] Beginner--how to import a series of files?
- From: gardyloo <gardyloo at mail.wsu.edu>
- Date: Wed, 18 Jan 2006 02:39:04 -0500 (EST)
- References: <200601170933.EAA07456@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello, I'm not sure about the processing of .raw files, nor the difficulties of importing/processing them with Mathematica. However, I often do batch processes on other types of files. Here's my technique: 1. Form a list of the files you want to process. For example, if you're in the directory where your images are stored (you can also specify full paths in the filenames, of course), I'd try something like fileNames = FileNames[ "image*.raw" ]; 2. If 'Import' works on these files, great! Try something like filesImported = Import[ #, "RAW" ] &/@ fileNames; 3. filesImported now consists of a huge list, each element of which is a file which you imported. I find it easiest to work on these big lists, because it's easy to thread commands over each of their elements. This is as opposed to creating one list for each of the files, which you can do with some string parsing; something like: (Evaluate[ "myImage" <> ToString[#] ]) = (Import[ fileNames [[#]], "RAW" ]) &/@ Range[Length[fileNames]]; Note that I haven't actually done my importing this way in a while (so I'm not 100% sure of the syntax)! However, this should create a series of files, named "myImage1", "myImage2", etc., from each of the .raw files named in fileNames. When you're all done with your post-processing, you can then use the same technique to export files back to your directory. One can also think about importing, processing, and then exporting each file at a time, so that less memory is used during the process. I, personally, like to have all of the data in RAM for most of the time, so that I can work between datasets, but if you don't have them interact with eachother, possibly exporting each one and clearing the memory it took up might be more effective. Incidentally, I often find ReadList to be much faster and the results take up less memory than Import. I work with tab-separated lists of numbers from experimental data, and have defined a function called "ReadRealList" which is simply ReadRealList[data_?StringQ]:=ReadList[data, {"TSV", "Real"}]; I don't know if something very similar would work for your image files; I suspect that the full power of Import will be useful to you. Incidentally, I ran across a nice website by Ted Gray (the gentleman famous for the "periodic table" and, just incidentally, co-founding Wolfram Research, Inc. ) just now, in which he discusses using Mathematica for image manipulation (I've done some image stuff, too, finding edges of liquid jets from high-speed camera movies and the like, but my algorithms were much less powerful than his): http://www.theodoregray.com/PeriodicTable/Samples/003.m1/index.s9.html Hope this helps! Batch-processing of data was a thing that stymied me for far too long, but it seems easy now that things are working. Curtis O. cymed2 at yahoo.com wrote: >Hi, >Now I have a series of raw data, such as image_1.raw, image_2, ..., etc. >I plan to import all of these files and make some post-processing. >How do I do it? Is there any special command or I need to write a script to perform? >Thanks for your time. > > > >Link to the forum page for this post: >http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=Special:Forum_ViewTopic&pid=7709#p7709 >Posted through http://www.mathematica-users.org [[postId=7709]] > > > > >
- References:
- Beginner--how to import a series of files?
- From: cymed2@yahoo.com
- Beginner--how to import a series of files?