Image Import fail silenty with no error when path does not exist

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

Image Import fail silenty with no error when path does not exist

Stein Rørvik
When attempting to import or open some file in the macro language, the macro aborts with an error if the path does not exist.
This is at least the case for the following:

                open(pathToImage)
                run("TIFF Virtual Stack...", "open=&pathToImageStack")
                run("LUT... ", "open=&pathToLut")
                run("Text File... ", "open=&pathToText")
                run("Text Image... ", "open=&pathToText")
                run("Table... ", "open=&pathToTable")

The problem is that the following commands fail silenty with no error when the file does not exist, and the macro just continues:

                run("Image Sequence...", "open=&pathToNonExistantFolder sort")
                run("Raw...", "open=&pathToNonExistantFile image=[16-bit Unsigned] width=135 height=200 offset=123 number=18 gap=456 little-endian");

This easily breaks the macros and workflow, as the continued execution of the macro when no image appeared when expected can cause big problems.

Here is a more specific example macro that reproduces the problem:

                run("Close All");
                dir = getDirectory("temp");

                //create a sample tiff file
                run("AuPbSn 40 (56K)");
                saveAs("Tiff", dir + "AuPbSn40.tif");
                close();

                //create a sample tiff stack
                run("T1 Head (2.4M, 16-bits)");
                saveAs("Tiff", dir + "t1-head.tif");
                close();

                //create a sample tiff virtual stack
                run("T1 Head (2.4M, 16-bits)");
                File.makeDirectory(dir + "t1-head/");
                run("Image Sequence... ", "format=TIFF save="+ dir + "t1-head/");
                close();

                //try to load the sample files again using the wrong filename:
                open(dir + "xuPbSn40.tif");         //ok: throws an error
                open(dir + "x1-head.tif");            //ok: throws an error
                run("Image Sequence...", "open=" + dir + "x1-head/ sort");         //bug: fails silently
                run("Raw...", "open=" + dir + "xuPbSn40.tif image=[8-bit] width=600 height=400 number=1 offset=148");                //bug: fails silently

I am using daily build ImageJ 1.52f with Java 1.6 on Windows 7/64-bit.

Stein

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Image Import fail silenty with no error when path does not exist

Wayne Rasband-2
> On Aug 10, 2018, at 6:56 AM, Stein Rørvik <[hidden email]> wrote:
>
> When attempting to import or open some file in the macro language, the macro aborts with an error if the path does not exist.
> This is at least the case for the following:
>
>                open(pathToImage)
>                run("TIFF Virtual Stack...", "open=&pathToImageStack")
>                run("LUT... ", "open=&pathToLut")
>                run("Text File... ", "open=&pathToText")
>                run("Text Image... ", "open=&pathToText")
>                run("Table... ", "open=&pathToTable")
>
> The problem is that the following commands fail silenty with no error when the file does not exist, and the macro just continues:
>
>                run("Image Sequence...", "open=&pathToNonExistantFolder sort")
>                run("Raw...", "open=&pathToNonExistantFile image=[16-bit Unsigned] width=135 height=200 offset=123 number=18 gap=456 little-endian”);

These bugs are fixed in the latest ImageJ daily build (1.52f23).

-wayne

>
> This easily breaks the macros and workflow, as the continued execution of the macro when no image appeared when expected can cause big problems.
>
> Here is a more specific example macro that reproduces the problem:
>
>                run("Close All");
>                dir = getDirectory("temp");
>
>                //create a sample tiff file
>                run("AuPbSn 40 (56K)");
>                saveAs("Tiff", dir + "AuPbSn40.tif");
>                close();
>
>                //create a sample tiff stack
>                run("T1 Head (2.4M, 16-bits)");
>                saveAs("Tiff", dir + "t1-head.tif");
>                close();
>
>                //create a sample tiff virtual stack
>                run("T1 Head (2.4M, 16-bits)");
>                File.makeDirectory(dir + "t1-head/");
>                run("Image Sequence... ", "format=TIFF save="+ dir + "t1-head/");
>                close();
>
>                //try to load the sample files again using the wrong filename:
>                open(dir + "xuPbSn40.tif");         //ok: throws an error
>                open(dir + "x1-head.tif");            //ok: throws an error
>                run("Image Sequence...", "open=" + dir + "x1-head/ sort");         //bug: fails silently
>                run("Raw...", "open=" + dir + "xuPbSn40.tif image=[8-bit] width=600 height=400 number=1 offset=148");                //bug: fails silently
>
> I am using daily build ImageJ 1.52f with Java 1.6 on Windows 7/64-bit.
>
> Stein
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html