Open an image sequence using a macro

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

Open an image sequence using a macro

Ben
Dear All,

I'm trying to automatically open an image sequence using a macro WITHOUT to have the Image sequence dialog pop up...

Here is my macro code:

filepath=File.openDialog("Select a dm3 File");
imageDir=File.directory;
fileList = getFileList(imageDir); 
numberSlice=fileList.length;
run("Image Sequence...", 
  "open=[&filepath]"+
  " number="+numberSlice+
  " starting=1"+
  " increment=1"+
  " scale=100 "+
  "file=[.dm3] "+
  "sort");

Unfortunately, each time I run the macro the Sequence Option dialog popup...

Is there a way to NOT display it since I already pass all the required parameters in the macro?

Thanks,

Benjamin
Reply | Threaded
Open this post in threaded view
|

Re: Open an image sequence using a macro

Michael Schmid
Hi Ben,

there was not macro code in your mail, but I do not have this problem.
The following macro works without showing a dialog (ImageJ 1.48h16, Mac OS
X):

run("Image Sequence...", "open=/mydata/someFolder number=14 starting=1
increment=1 scale=100 file=JPG");

If your folder name may include spaces, put it in square brackets.

Michael
__________________________________________________________________

On Mon, December 23, 2013 12:15, Ben wrote:

> Dear All,
>
> I'm trying to automatically open an image sequence using a macro WITHOUT
> to
> have the Image sequence dialog pop up...
>
> Here is my macro code:
>
>
>
> Unfortunately, each time I run the macro the Sequence Option dialog
> popup...
> <http://imagej.1557.x6.nabble.com/file/n5005969/sequence_option.png>
> Is there a way to NOT display it since I already pass all the required
> parameters in the macro?
>
> Thanks,
>
> Benjamin

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

Re: Open an image sequence using a macro

Ben
Thanks for your answer,

However, it doesn't solve my problem.
Running the following:
run("Image Sequence...", "open=[C:\\Images\\tiff\\] number=3starting=1 increment=1 scale=100 file=tif");

will popup the dialog...
I am using Fiji (how could I see the version?) which is based on ImageJ v 1.48 on Windows 7...

If anybody has any idea on what's going on (did the plugin change recently?)

Benjamin
Reply | Threaded
Open this post in threaded view
|

Re: Open an image sequence using a macro

Herbie-3
Benjamin,

your file path looks strange and there is a blank missing following
"number=3".

In general, Fiji is automatically up-dated but why don't you try with
plain ImageJ first if you suspect the problem with Fiji?

In any case, the macro call proposed by Michael should work.

Best

Herbie

:::::::::::::::::::::::::::::
On 23.12.13 13:23, Ben wrote:

> Thanks for your answer,
>
> However, it doesn't solve my problem.
> Running the following:
> run("Image Sequence...", "open=[C:\\Images\\tiff\\] number=3starting=1
> increment=1 scale=100 file=tif");
>
> will popup the dialog...
> I am using Fiji (how could I see the version?) which is based on ImageJ v
> 1.48 on Windows 7...
>
> If anybody has any idea on what's going on (did the plugin change recently?)
>
> Benjamin
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Open-an-image-sequence-using-a-macro-tp5005969p5005971.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

Re: Open an image sequence using a macro

Ben
This is actually working, I realize that on Fiji, using the Fiji script editor, it sometimes show me the dialog, especially when the macro record is launched.
If it happens, you have to restart Fiji and reopen the macro, then when you run it, you won't see the dialog as expected... So definitely a Fiji issue, sorry about that.

Benjamin
Reply | Threaded
Open this post in threaded view
|

Re: Open an image sequence using a macro

Martin Höhne
Dear all,
I also have problems with the use of Import Image Sequence in a macro.

I have a directory with two subdirectories (named dir1 and dir2) containinig image series  and I would like to open both series within a macro:

When I start Fiji and run the macro give below for the first time, stack1 is opened fine without the Image Sequence dialog popping up. But stack2 does´t. Instead the Image sequence dialog pops up. The options given in the macro, e.g. scale=50) are not automatically taken in this dialog.

When I run the macro for a second time, also the first stack is not opened automatically.

It seems the the Import Image Sequence function has to be resetted after every imported stack. But how?

Martin

macro code:

source_dir = getDirectory("Source Directory");
stack1=source_dir+"dir1"+File.separator;
        list = getFileList(stack1);
        fileone=stack1 + list[0];
        nummer=list.length;
        run("Image Sequence...", "open=fileone number=nummer starting=1 increment=1 scale=50 file=[] or=[] convert sort");
       
stack2=source_dir+"dir2"+File.separator;
        list = getFileList(stack2);
        fileone=stack2 + list[0];
        nummer=list.length;
        run("Image Sequence...", "open=fileone number=nummer starting=1 increment=1 scale=50 file=[] or=[] convert sort");
       
         
Reply | Threaded
Open this post in threaded view
|

Re: Open an image sequence using a macro

Rasband, Wayne (NIH/NIMH) [E]
On Feb 27, 2014, at 5:44 AM, Martin Höhne wrote:

> Dear all,
> I also have problems with the use of Import Image Sequence in a macro.
>
> I have a directory with two subdirectories (named dir1 and dir2) containinig
> image series  and I would like to open both series within a macro:
>
> When I start Fiji and run the macro give below for the first time, stack1 is
> opened fine without the Image Sequence dialog popping up. But stack2 does´t.
> Instead the Image sequence dialog pops up. The options given in the macro,
> e.g. scale=50) are not automatically taken in this dialog.
>
> When I run the macro for a second time, also the first stack is not opened
> automatically.
>
> It seems the the Import Image Sequence function has to be resetted after
> every imported stack. But how?

Here is a simplified version of the macro that should work better:

  source_dir = getDirectory("Source Directory");
  stack1=source_dir+"dir1"+File.separator;
  run("Image Sequence...", "open=&stack1 scale=50 convert sort");
  stack2=source_dir+"dir2"+File.separator;
  run("Image Sequence...", "open=&stack2 scale=50 convert sort");

The original macro was missing the "&" notation needed for passing variables, it used a file path as the 'open=' parameter instead of a directory path, and it used parameters with default values ('number=', 'starting=', 'increment=', 'file=' and 'or=') that are not needed.

-wayne

> macro code:
>
> source_dir = getDirectory("Source Directory");
> stack1=source_dir+"dir1"+File.separator;
> list = getFileList(stack1);
> fileone=stack1 + list[0];
> nummer=list.length;
> run("Image Sequence...", "open=fileone number=nummer starting=1 increment=1
> scale=50 file=[] or=[] convert sort");
>
> stack2=source_dir+"dir2"+File.separator;
> list = getFileList(stack2);
> fileone=stack2 + list[0];
> nummer=list.length;
> run("Image Sequence...", "open=fileone number=nummer starting=1 increment=1
> scale=50 file=[] or=[] convert sort");
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Open-an-image-sequence-using-a-macro-tp5005969p5006696.html
> Sent from the ImageJ mailing list archive at Nabble.com.

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

Re: Open an image sequence using a macro

Martin Höhne
Dear Wayne and All,


>> When I start Fiji and run the macro give below for the first time, stack1 is
>> opened fine without the Image Sequence dialog popping up. But stack2 does´t.
>> Instead the Image sequence dialog pops up. The options given in the macro,
>> e.g. scale=50) are not automatically taken in this dialog.
>>
>> When I run the macro for a second time, also the first stack is not opened
>> automatically.
 

> Here is a simplified version of the macro that should work better:
>
>  source_dir = getDirectory("Source Directory");
>  stack1=source_dir+"dir1"+File.separator;
>  run("Image Sequence...", "open=&stack1 scale=50 convert sort");
>  stack2=source_dir+"dir2"+File.separator;
>  run("Image Sequence...", "open=&stack2 scale=50 convert sort");
>
> The original macro was missing the "&" notation needed for passing variables, it used a file path as the
> 'open=' parameter instead of a directory path, and it used parameters with default values ('number=',
> 'starting=', 'increment=', 'file=' and 'or=') that are not needed.
>
> -wayne

the above mentioned behaviour does not change with the simplified macro version. I am using
Fiji/ImageJ 1.48r; Java 1.6.0_24 on Win7 64 bit.

Martin


Reply | Threaded
Open this post in threaded view
|

Re: Open an image sequence using a macro

Rasband, Wayne (NIH/NIMH) [E]
On Feb 28, 2014, at 3:11 AM, Martin Höhne wrote:

> Dear Wayne and All,
>
>>> When I start Fiji and run the macro give below for the first time, stack1
>>> is
>>> opened fine without the Image Sequence dialog popping up. But stack2
>>> does´t.
>>> Instead the Image sequence dialog pops up. The options given in the
>>> macro,
>>> e.g. scale=50) are not automatically taken in this dialog.
>>>
>>> When I run the macro for a second time, also the first stack is not
>>> opened
>>> automatically.
>
>> Here is a simplified version of the macro that should work better:
>>
>> source_dir = getDirectory("Source Directory");
>> stack1=source_dir+"dir1"+File.separator;
>> run("Image Sequence...", "open=&stack1 scale=50 convert sort");
>> stack2=source_dir+"dir2"+File.separator;
>> run("Image Sequence...", "open=&stack2 scale=50 convert sort");
>>
>> The original macro was missing the "&" notation needed for passing
>> variables, it used a file path as the
>> 'open=' parameter instead of a directory path, and it used parameters with
>> default values ('number=',
>> 'starting=', 'increment=', 'file=' and 'or=') that are not needed.
>>
>> -wayne
>
> the above mentioned behaviour does not change with the simplified macro
> version. I am using
> Fiji/ImageJ 1.48r; Java 1.6.0_24 on Win7 64 bit.

This appears to be a Fiji-specific bug so you should report it using Fiji's Help>Report a Bug command. The report should include the simplified macro and it should note that the macro works with ImageJ but not with Fiji.

-wayne

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

Re: Open an image sequence using a macro

Martin Höhne
Thank you Wayne.
The is reported as Bug 707 now.
Reply | Threaded
Open this post in threaded view
|

Re: Open an image sequence using a macro

dscho
Hi,

On Fri, 28 Feb 2014, Martin Höhne wrote:

> The is reported as Bug 707 now.

The bug was in the code putting back the "Convert to 8-bit Grayscale"
checkbox that was removed from ImageJ 1.x but still needed by some Fiji
users.

The bug report waits for feedback... *hint, hint* ;-)

Ciao,
Johannes

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

Re: Open an image sequence using a macro

Obitruc
In reply to this post by Ben
Hi all.

First, I'm french and not that used to write in english, so don't mind my mistakes.

I'm trying to write a very dumb macro on Fiji, in order to import folders containing only .tif files.

So far I wrote few simples macros which worked, but I'm stuck here.

Here is my code :

run("Close All");
dir1 = getDirectory("Choose Root Image Folder");

dirSaveMovies = dir1 + "Movies";
if (File.exists(dirSaveMovies)){} else {File.makeDirectory(dirSaveMovies);}

dir2 = dir1 + "RawData" + File.separator;
list2 = getFileList(dir2);


//for (i=0; i<=(list2.length - 1); i++) {
for (i=0; i<=0; i++) {
        print(dir2);
        print(list2[i]);
        run("Image Sequence...", "open=list2[i] convert use");
}


My major problem is that the Image Sequence import never occured...

If someone has an idea, I'll be thankful.

Cheers for France