Hi,
Am a newbie to IJ macros, so do apologize (but did not find this on IJ forum or through google). Anyway, am using IJ to convert HDF5 files to VTK (for downstream processing via ParaView). When I use recorder to do it for 1 file (say "test.h5"), I get the following output: run("Load HDF5 File", "open=C:\\Data\\test.h5 2d"); //since the 2d part of the data is being loaded by HDF. run("VTK Writer...","save=[C:\\Data\\test.h5 data.vtk] save=[C:\\Data\\test.h5 data.vtk] save=[C:\\Data\\test.h5. data.vtk] save=[C:\\Data\\test.h5 data.vtk]"); However, when I construct a macro so that it can do bunch of files using: head=getDirectory("Choose directory"); setBatchMode(true); children=getFileList(head); <start for loop> curChild=head+children[loopcounter]; nuCur = curChild + " 2d"; run("Load HDF5 File", "open=nuChild"); <end for loop> the process does not work; there is no error, but nothing happens. When I run debug, the curChild value is: C:\Data\test.h5 instead of C:\\Data\\test.h5 Just to check, I went back to the command that ran under recorder and when I run it with single slash rather than double slash it does not work. I tried using replace to switch the \ to \\ but I get the error "Number or numeric function expected". I had typed it in as replace(curChild,"\","\\"); Any suggestions/guidance would be really helpful... |
Try this command instead:
run("Load HDF5 File", "open=" + nuChild + ")"; Also, just to let you know, when you write \\ in the code, the computer will interpret those characters as just \. The slash is called an "escape character". You can read about escape characters online if you are interested: http://en.wikipedia.org/wiki/Escape_character
|
I made a slight change to your command: run("Load HDF5 File", "open=" + nuChild + ")"); since it was complaining of missing the ending round bracket. The command then does not return an error and I get a message saying loading HDF5 File:..... and no image loads :(. I also do not quite understand how only one bracket can exist (does it not need closure?)? Could this possibly be a PC v Linux issues for hdf5 reader, maybe? I can use / instead of \\ and that also works. Vinay P.S. In my earlier message, I had a slip-up: note that nuChild and nuCur are the same (slip-up not obviously in the code but when typing it up for the msgboard) |
Oh! So sorry! It's a very silly mistake on my part!
You are absolutely right! There needs to be 2 brackets or no brackets :-). run("Load HDF5 File", "open=" + nuChild);
|
In reply to this post by vinaympai
Hi Vinay,
run("Load HDF5 File", "open=" + nuChild + ")"); This does not look correct to me. I don't know why you would add an extra ")" to the end of the filename. Have you tried: run("Load HDF5 File", "open=" + nuChild); Or if the filename contains spaces, use: run("Load HDF5 File", "open=[" + nuChild + "]"); As for the backslashes, it is the macro language's escape character. For a detailed explanation, see: http://en.wikipedia.org/wiki/Escape_character In short, rest assured that it is normal to write two backslashes to indicate a single one, and that when printing out the string value, you will only see a single backslash between each path component. HTH, Curtis On Tue, Jun 14, 2011 at 12:04 AM, vinaympai <[hidden email]> wrote: > Nathaniel Ryckman wrote: > > > > Try this command instead: > > > > run("Load HDF5 File", "open=" + nuChild + ")"; > > > > > I made a slight change to your command: > run("Load HDF5 File", "open=" + nuChild + ")"); since it was complaining of > missing the ending round bracket. The command then does not return an > error > and I get a message saying loading HDF5 File:..... > and no image loads :(. > > I also do not quite understand how only one bracket can exist (does it not > need closure?)? > > Could this possibly be a PC v Linux issues for hdf5 reader, maybe? I can > use / instead of \\ and that also works. > > Vinay > P.S. In my earlier message, I had a slip-up: note that nuChild and nuCur > are > the same (slip-up not obviously in the code but when typing it up for the > msgboard) > > > -- > View this message in context: > http://imagej.588099.n2.nabble.com/vs-for-macro-converting-h5-to-vtk-tp6471541p6471985.html > Sent from the ImageJ mailing list archive at Nabble.com. > |
Actually that does work (the one without an extra bracket). I also realized the mistake that I was making was setting batchmode to true. After going over the manuals, I realize that for my particular case it is not correct since the vtk converter looks for the window where the image is displayed and setting batch mode to true defeats that. So now everything is working.... Thanks for all the help.
|
Free forum by Nabble | Edit this page |