Save XY coordinates batch filenames

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

Save XY coordinates batch filenames

Justin Walker-3
I have a short macro that I want to convert to batch mode, but I'm having a bit of trouble with the "Save XY Coordinates" command - I would like to have it save the results of this command as the same filename and path as the image itself, but replace the image's extension (.tif) with .txt (so that after I run I will have 1 text file for each image containing the XY data for that image.)

Does anyone know how I'd go about doing that?  I've attached my macro if it helps you to look at what I'm doing - I've attempted to simply use the getinfo("title") command to get the image's filename and append .txt to it (so you'd get myimage.tif.txt, which is fine as well), but I'm clearly not implementing it correctly.

Your help is greatly appreciated;

Justin Walker, Ph. D. Student
University of Maryland

macro "Pendant Drop Analysis" {
    dir = getDirectory("Choose a Directory ");
    list = getFileList(dir);
    setBatchMode(true);
        for (i=0; i<list.length; i++) {
        path = dir+list[i];
            showProgress(i, list.length);
            if (!endsWith(path,"/")) open(path);
            if (nImages>=1) {
              run("8-bit");
         setAutoThreshold();
              //run("Threshold...");
              setAutoThreshold();
              setThreshold(0, 121);
              run("Convert to Mask");
              run("Fill Holes");
              name = getInfo("title");
              run("Save XY Coordinates...", "save=dir[name.txt]");
            close();
        }
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Save XY coordinates batch filenames

Michael Schmid
Hi Justin,

probably you want something like

     name = getInfo("title");
     txtPath = dir+name+".txt";
     run("Save XY Coordinates...", "save=["+txtPath+"]");

Note that everything inside quotes is a fixed string; strings
are concatenated with the '+' operator.
The square brackets delimit a string argument within a string
enclosed by quotes.

Michael
________________________________________________________________


On 19 Feb 2008, at 22:23, Justin Walker wrote:

> I have a short macro that I want to convert to batch mode, but I'm  
> having a bit of trouble with the "Save XY Coordinates" command - I  
> would like to have it save the results of this command as the same  
> filename and path as the image itself, but replace the image's  
> extension (.tif) with .txt (so
> that after I run I will have 1 text file for each image containing  
> the XY data for that image.)
>
> Does anyone know how I'd go about doing that?  I've attached my  
> macro if it helps you to look at what I'm doing - I've attempted to  
> simply use the getinfo("title") command to get the image's filename  
> and append .txt to it (so you'd get myimage.tif.txt, which is fine  
> as well), but I'm clearly no
> t implementing it correctly.
>
> Your help is greatly appreciated;
>
> Justin Walker, Ph. D. Student
> University of Maryland
> macro "Pendant Drop Analysis" {
>     dir = getDirectory("Choose a Directory ");
>     list = getFileList(dir);
>     setBatchMode(true);
> for (i=0; i<list.length; i++) {
> path = dir+list[i];
>             showProgress(i, list.length);
>             if (!endsWith(path,"/")) open(path);
>             if (nImages>=1) {
>      run("8-bit");
>          setAutoThreshold();
>      //run("Threshold...");
>      setAutoThreshold();
>      setThreshold(0, 121);
>      run("Convert to Mask");
>      run("Fill Holes");
>      name = getInfo("title");
>      run("Save XY Coordinates...", "save=dir[name.txt]");
>    close();
>         }
>     }
> }