Troubleshooting Import AVI macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Troubleshooting Import AVI macro

tcovert
Hi,
I know there is a very simple solution here, but being very new to ImageJ
macros I am at a loss for a solution.

I am putting together a macro for batch folder processing a group of AVI
movies that begins by importing the AVI as a stack.  I'd like to set the
first and last frame as part of the macro.  As a template I started with the
macro BatchProcessFolders.txt.  Here's the relevant code:

function processFile(path) {
       if (endsWith(path, ".avi")) {
           open(path);

I'd like the open to include the first and last frame parameters.  I also
tried using run("AVI...") with the first and last frames included but also
ran into problems there.

Thanks in advance for the help.

Cheers,
Trevor

--
Trevor Covert
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Troubleshooting Import AVI macro

Wayne Rasband
> Hi,
> I know there is a very simple solution here, but being very new
> to ImageJ macros I am at a loss for a solution.
>
> I am putting together a macro for batch folder processing a group  
> of AVI
> movies that begins by importing the AVI as a stack.  I'd like to  
> set the
> first and last frame as part of the macro.  As a template I started
> with the macro BatchProcessFolders.txt.  Here's the relevant code:
>
> function processFile(path) {
>        if (endsWith(path, ".avi")) {
>            open(path);
>
> I'd like the open to include the first and last frame parameters.
> I also tried using run("AVI...") with the first and last frames  
> included
> but also ran into problems there.

Use the File>Import>AVI command with the command recorder  
(Plugins>Macros>Record) to generate the needed code. Here is an  
example that opens frames 5-10 of an AVI:

    run("AVI...", "select=/Users/wayne/video.avi first=5 last=10");

Use string concatenation to make the file name, first frame and last  
frame variables:

    name = "video.avi";
    path = getDirectory("home")+"video.avi";
    first=5; last=10;
    run("AVI...", "select="+path+" first="+first+" last="+last);

Note that the file path needs to be enclosed in square brackets if it  
can contain spaces:

    path = "["+getDirectory("home")+name+"]";

-wayne