FIJI 2D stitching in a macro - solution!

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

FIJI 2D stitching in a macro - solution!

Jacqueline Ross
Hi Everyone,


Christophe Leterrier has very kindly written a macro for me, which
solved my problem. This macro tiles the 3 images together perfectly
(even though they are a zigzag) and saves each tiled image as a separate
TIFF file. I was then able to open the sequence of tiled images as a
virtual stack and save out as AVI.

 

I have forwarded (below) the email that Christophe sent me as
explanation of the macro. I have also included  one where I have
described the data that I sent him, so that you will know how the
folders work. It has taught me some useful information about how to
write these kinds of macros.

 

The macro is called Stitch BMT. I have copied it below. I hope the
formatting is preserved since it wasn't last time. The macro file itself
was rejected by the listserver.

 

 

macro "Stitch BMT" {

 

                PARENT_PATH=getDirectory("Select a directory");

               

                File.makeDirectory(PARENT_PATH+"tiled");

                POSITION=newArray("bottom", "middle", "top");

 
ALL_NAMES=getFileList(PARENT_PATH+POSITION[0]+File.separator);

               

                for (i=1; i<=ALL_NAMES.length; i++) {

 

 
BOTTOM_IMAGE=POSITION[0]+pad(i,3,0)+".tif";

 
MIDDLE_IMAGE=POSITION[1]+pad(i,3,0)+".tif";

                                TOP_IMAGE=POSITION[2]+pad(i,3,0)+".tif";

                                FUSED_IMAGE="fused"+pad(i,3,0)+".tif";

                               

 
BOTTOM_PATH=PARENT_PATH+POSITION[0]+File.separator+BOTTOM_IMAGE;

 
MIDDLE_PATH=PARENT_PATH+POSITION[1]+File.separator+MIDDLE_IMAGE;

 
TOP_PATH=PARENT_PATH+POSITION[2]+File.separator+TOP_IMAGE;

 
FUSED_PATH=PARENT_PATH+File.separator+"tiled"+File.separator+FUSED_IMAGE
;

                               

                                print("\n");

                                print("bottom: "+BOTTOM_IMAGE);

                                print("middle: "+MIDDLE_IMAGE);

                                print("top: "+TOP_IMAGE);

                                print("fused: "+FUSED_IMAGE);

 

                                open(BOTTOM_PATH);

                                open(MIDDLE_PATH);

                                open(TOP_PATH);

               

                                run("2D Stitching", "first_image="+
BOTTOM_IMAGE +" use_channel_for_first=[Red, Green and Blue]
second_image="+ MIDDLE_IMAGE +" use_channel_for_second=[Red, Green and
Blue] use_windowing how_many_peaks=5 create_merged_image
fusion_method=[Linear Blending] fusion=1.50 fused_image=temp.tif
compute_overlap x=0 y=0");

                                run("2D Stitching",
"first_image=temp.tif use_channel_for_first=[Red, Green and Blue]
second_image="+ TOP_IMAGE +" use_channel_for_second=[Red, Green and
Blue] use_windowing how_many_peaks=5 create_merged_image
fusion_method=[Linear Blending] fusion=1.50 fused_image="+ FUSED_IMAGE
+" compute_overlap x=0 y=0");

 

                                selectWindow(BOTTOM_IMAGE);

                                close();

                                selectWindow(MIDDLE_IMAGE);

                                close();

                                selectWindow(TOP_IMAGE);

                                close();

                                selectWindow("temp.tif");

                                close();

                                selectWindow(FUSED_IMAGE);

                                save(FUSED_PATH);

                                close();

               

                }

}

 

function pad(number, width, character) {

       number = toString(number); // force string

       character = toString(character);

       for (len = lengthOf(number); len < width; len++)

               number = character + number;

       return number;

}

 

I hope it will also be of use to others.

 

Thanks Christophe for your efforts!

 

Kind regards,

 

Jacqui

 

Jacqueline Ross

Biomedical Imaging Microscopist
Biomedical Imaging Research Unit
School of Medical Sciences
Faculty of Medical & Health Sciences
The University of Auckland
Private Bag 92019
Auckland, NEW ZEALAND

Tel: 64 9 373 7599 Ext 87438
Fax: 64 9 373 7484

http://www.fmhs.auckland.ac.nz/sms/biru/

From: Christophe Leterrier [mailto:[hidden email]]
Sent: Wednesday, 17 November 2010 10:27 p.m.
To: Jacqui Ross
Subject: Re: FIJI 2D stitching in a macro

 

Hi Jaqui,

 

The attached macro (Stitch_BTM.ijm) should run fine with the latest
Stitching plugin from Fiji (the one with the updated fields).

It runs OK on my setup for the attached folder (the same you sent me but
I removed the "Tiled" folder). Just run the macro, choose the
"Christophe" folder in the dialog (you have to choose the parent folder
that contains the "bottom", "middle" and "top" folders), it will create
an additional "tiled" folder where it will store the resulting images
with "fused00X.tif" names.

 

One caution : the folders inside the parent folder must be named exaclty
"bottom", "middle" and "top", these folders must only contain images
that are used for stitiching and no other files or images, and the
images must be named "bottom00X.tif", "middle00X.tif", "top00X.tif"
(with three digits).

 

Hope this helps,

 

Christophe

 

On Wed, Nov 17, 2010 at 06:31, Jacqui Ross <[hidden email]>
wrote:

Hi Christophe,


Thanks very much for your kind offer to assist me.

 

As you suggested,  I have attached a .zip file containing 4 folders,  3
of which contain the raw data to be tiled. The other folder (Tiled)
contains one merged image, which will give you an idea of the overlap,
which is around 30%. As you will see, it's not ideal because it doesn't
comprise a square/rectangle, which would be better.

However, the 2D Stitch plugin seemed to do this tiling effortlessly with
a nice result as you will see.

 

I will look forward to hearing how you get on with this. It's not super
urgent so whenever you have time to take a look will be fine.

 

Thanks!


Kind regards,

 

Jacqui

Jacqueline Ross

Biomedical Imaging Microscopist
Biomedical Imaging Research Unit
School of Medical Sciences
Faculty of Medical & Health Sciences
The University of Auckland
Private Bag 92019
Auckland, NEW ZEALAND

Tel: 64 9 373 7599 Ext 87438
Fax: 64 9 373 7484

http://www.fmhs.auckland.ac.nz/sms/biru/
Reply | Threaded
Open this post in threaded view
|

Re: FIJI 2D stitching in a macro - solution!

Stephan Preibisch
Hi,

I am happy this works out, and also that the major problem were the updated
field names...I will try to import the zig-zag macro into the stitching
plugin collection, thanks a lot Christophe!

Nice greetings,
Stephan

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Jacqui
Ross
Sent: Monday, November 22, 2010 5:53 AM
To: [hidden email]
Subject: FIJI 2D stitching in a macro - solution!

Hi Everyone,


Christophe Leterrier has very kindly written a macro for me, which
solved my problem. This macro tiles the 3 images together perfectly
(even though they are a zigzag) and saves each tiled image as a separate
TIFF file. I was then able to open the sequence of tiled images as a
virtual stack and save out as AVI.

 

I have forwarded (below) the email that Christophe sent me as
explanation of the macro. I have also included  one where I have
described the data that I sent him, so that you will know how the
folders work. It has taught me some useful information about how to
write these kinds of macros.

 

The macro is called Stitch BMT. I have copied it below. I hope the
formatting is preserved since it wasn't last time. The macro file itself
was rejected by the listserver.

 

 

macro "Stitch BMT" {

 

                PARENT_PATH=getDirectory("Select a directory");

               

                File.makeDirectory(PARENT_PATH+"tiled");

                POSITION=newArray("bottom", "middle", "top");

 
ALL_NAMES=getFileList(PARENT_PATH+POSITION[0]+File.separator);

               

                for (i=1; i<=ALL_NAMES.length; i++) {

 

 
BOTTOM_IMAGE=POSITION[0]+pad(i,3,0)+".tif";

 
MIDDLE_IMAGE=POSITION[1]+pad(i,3,0)+".tif";

                                TOP_IMAGE=POSITION[2]+pad(i,3,0)+".tif";

                                FUSED_IMAGE="fused"+pad(i,3,0)+".tif";

                               

 
BOTTOM_PATH=PARENT_PATH+POSITION[0]+File.separator+BOTTOM_IMAGE;

 
MIDDLE_PATH=PARENT_PATH+POSITION[1]+File.separator+MIDDLE_IMAGE;

 
TOP_PATH=PARENT_PATH+POSITION[2]+File.separator+TOP_IMAGE;

 
FUSED_PATH=PARENT_PATH+File.separator+"tiled"+File.separator+FUSED_IMAGE
;

                               

                                print("\n");

                                print("bottom: "+BOTTOM_IMAGE);

                                print("middle: "+MIDDLE_IMAGE);

                                print("top: "+TOP_IMAGE);

                                print("fused: "+FUSED_IMAGE);

 

                                open(BOTTOM_PATH);

                                open(MIDDLE_PATH);

                                open(TOP_PATH);

               

                                run("2D Stitching", "first_image="+
BOTTOM_IMAGE +" use_channel_for_first=[Red, Green and Blue]
second_image="+ MIDDLE_IMAGE +" use_channel_for_second=[Red, Green and
Blue] use_windowing how_many_peaks=5 create_merged_image
fusion_method=[Linear Blending] fusion=1.50 fused_image=temp.tif
compute_overlap x=0 y=0");

                                run("2D Stitching",
"first_image=temp.tif use_channel_for_first=[Red, Green and Blue]
second_image="+ TOP_IMAGE +" use_channel_for_second=[Red, Green and
Blue] use_windowing how_many_peaks=5 create_merged_image
fusion_method=[Linear Blending] fusion=1.50 fused_image="+ FUSED_IMAGE
+" compute_overlap x=0 y=0");

 

                                selectWindow(BOTTOM_IMAGE);

                                close();

                                selectWindow(MIDDLE_IMAGE);

                                close();

                                selectWindow(TOP_IMAGE);

                                close();

                                selectWindow("temp.tif");

                                close();

                                selectWindow(FUSED_IMAGE);

                                save(FUSED_PATH);

                                close();

               

                }

}

 

function pad(number, width, character) {

       number = toString(number); // force string

       character = toString(character);

       for (len = lengthOf(number); len < width; len++)

               number = character + number;

       return number;

}

 

I hope it will also be of use to others.

 

Thanks Christophe for your efforts!

 

Kind regards,

 

Jacqui

 

Jacqueline Ross

Biomedical Imaging Microscopist
Biomedical Imaging Research Unit
School of Medical Sciences
Faculty of Medical & Health Sciences
The University of Auckland
Private Bag 92019
Auckland, NEW ZEALAND

Tel: 64 9 373 7599 Ext 87438
Fax: 64 9 373 7484

http://www.fmhs.auckland.ac.nz/sms/biru/

From: Christophe Leterrier [mailto:[hidden email]]
Sent: Wednesday, 17 November 2010 10:27 p.m.
To: Jacqui Ross
Subject: Re: FIJI 2D stitching in a macro

 

Hi Jaqui,

 

The attached macro (Stitch_BTM.ijm) should run fine with the latest
Stitching plugin from Fiji (the one with the updated fields).

It runs OK on my setup for the attached folder (the same you sent me but
I removed the "Tiled" folder). Just run the macro, choose the
"Christophe" folder in the dialog (you have to choose the parent folder
that contains the "bottom", "middle" and "top" folders), it will create
an additional "tiled" folder where it will store the resulting images
with "fused00X.tif" names.

 

One caution : the folders inside the parent folder must be named exaclty
"bottom", "middle" and "top", these folders must only contain images
that are used for stitiching and no other files or images, and the
images must be named "bottom00X.tif", "middle00X.tif", "top00X.tif"
(with three digits).

 

Hope this helps,

 

Christophe

 

On Wed, Nov 17, 2010 at 06:31, Jacqui Ross <[hidden email]>
wrote:

Hi Christophe,


Thanks very much for your kind offer to assist me.

 

As you suggested,  I have attached a .zip file containing 4 folders,  3
of which contain the raw data to be tiled. The other folder (Tiled)
contains one merged image, which will give you an idea of the overlap,
which is around 30%. As you will see, it's not ideal because it doesn't
comprise a square/rectangle, which would be better.

However, the 2D Stitch plugin seemed to do this tiling effortlessly with
a nice result as you will see.

 

I will look forward to hearing how you get on with this. It's not super
urgent so whenever you have time to take a look will be fine.

 

Thanks!


Kind regards,

 

Jacqui

Jacqueline Ross

Biomedical Imaging Microscopist
Biomedical Imaging Research Unit
School of Medical Sciences
Faculty of Medical & Health Sciences
The University of Auckland
Private Bag 92019
Auckland, NEW ZEALAND

Tel: 64 9 373 7599 Ext 87438
Fax: 64 9 373 7484

http://www.fmhs.auckland.ac.nz/sms/biru/
Reply | Threaded
Open this post in threaded view
|

Re: FIJI 2D stitching in a macro - solution!

lechristophe
In reply to this post by Jacqueline Ross
Hi Jacqui,

I'm glad the macro is helpful. If someone on the list wants to re-use it, or
for Stephan to include it, I've uploaded a fully commented version here :

http://www.cleterrier.net/macros/Stitch_BMT.ijm

Best Regards,

Christophe

On Mon, Nov 22, 2010 at 05:52, Jacqui Ross <[hidden email]>wrote:

> Hi Everyone,
>
>
> Christophe Leterrier has very kindly written a macro for me, which
> solved my problem. This macro tiles the 3 images together perfectly
> (even though they are a zigzag) and saves each tiled image as a separate
> TIFF file. I was then able to open the sequence of tiled images as a
> virtual stack and save out as AVI.
>
>
>
> I have forwarded (below) the email that Christophe sent me as
> explanation of the macro. I have also included  one where I have
> described the data that I sent him, so that you will know how the
> folders work. It has taught me some useful information about how to
> write these kinds of macros.
>
>
>
> The macro is called Stitch BMT. I have copied it below. I hope the
> formatting is preserved since it wasn't last time. The macro file itself
> was rejected by the listserver.
>
>
>
>
>
> macro "Stitch BMT" {
>
>
>
>                PARENT_PATH=getDirectory("Select a directory");
>
>
>
>                File.makeDirectory(PARENT_PATH+"tiled");
>
>                POSITION=newArray("bottom", "middle", "top");
>
>
> ALL_NAMES=getFileList(PARENT_PATH+POSITION[0]+File.separator);
>
>
>
>                for (i=1; i<=ALL_NAMES.length; i++) {
>
>
>
>
> BOTTOM_IMAGE=POSITION[0]+pad(i,3,0)+".tif";
>
>
> MIDDLE_IMAGE=POSITION[1]+pad(i,3,0)+".tif";
>
>                                TOP_IMAGE=POSITION[2]+pad(i,3,0)+".tif";
>
>                                FUSED_IMAGE="fused"+pad(i,3,0)+".tif";
>
>
>
>
> BOTTOM_PATH=PARENT_PATH+POSITION[0]+File.separator+BOTTOM_IMAGE;
>
>
> MIDDLE_PATH=PARENT_PATH+POSITION[1]+File.separator+MIDDLE_IMAGE;
>
>
> TOP_PATH=PARENT_PATH+POSITION[2]+File.separator+TOP_IMAGE;
>
>
> FUSED_PATH=PARENT_PATH+File.separator+"tiled"+File.separator+FUSED_IMAGE
> ;
>
>
>
>                                print("\n");
>
>                                print("bottom: "+BOTTOM_IMAGE);
>
>                                print("middle: "+MIDDLE_IMAGE);
>
>                                print("top: "+TOP_IMAGE);
>
>                                print("fused: "+FUSED_IMAGE);
>
>
>
>                                open(BOTTOM_PATH);
>
>                                open(MIDDLE_PATH);
>
>                                open(TOP_PATH);
>
>
>
>                                run("2D Stitching", "first_image="+
> BOTTOM_IMAGE +" use_channel_for_first=[Red, Green and Blue]
> second_image="+ MIDDLE_IMAGE +" use_channel_for_second=[Red, Green and
> Blue] use_windowing how_many_peaks=5 create_merged_image
> fusion_method=[Linear Blending] fusion=1.50 fused_image=temp.tif
> compute_overlap x=0 y=0");
>
>                                run("2D Stitching",
> "first_image=temp.tif use_channel_for_first=[Red, Green and Blue]
> second_image="+ TOP_IMAGE +" use_channel_for_second=[Red, Green and
> Blue] use_windowing how_many_peaks=5 create_merged_image
> fusion_method=[Linear Blending] fusion=1.50 fused_image="+ FUSED_IMAGE
> +" compute_overlap x=0 y=0");
>
>
>
>                                selectWindow(BOTTOM_IMAGE);
>
>                                close();
>
>                                selectWindow(MIDDLE_IMAGE);
>
>                                close();
>
>                                selectWindow(TOP_IMAGE);
>
>                                close();
>
>                                selectWindow("temp.tif");
>
>                                close();
>
>                                selectWindow(FUSED_IMAGE);
>
>                                save(FUSED_PATH);
>
>                                close();
>
>
>
>                }
>
> }
>
>
>
> function pad(number, width, character) {
>
>       number = toString(number); // force string
>
>       character = toString(character);
>
>       for (len = lengthOf(number); len < width; len++)
>
>               number = character + number;
>
>       return number;
>
> }
>
>
>
> I hope it will also be of use to others.
>
>
>
> Thanks Christophe for your efforts!
>
>
>
> Kind regards,
>
>
>
> Jacqui
>
>
>
> Jacqueline Ross
>
> Biomedical Imaging Microscopist
> Biomedical Imaging Research Unit
> School of Medical Sciences
> Faculty of Medical & Health Sciences
> The University of Auckland
> Private Bag 92019
> Auckland, NEW ZEALAND
>
> Tel: 64 9 373 7599 Ext 87438
> Fax: 64 9 373 7484
>
> http://www.fmhs.auckland.ac.nz/sms/biru/
>
> From: Christophe Leterrier [mailto:[hidden email]]
> Sent: Wednesday, 17 November 2010 10:27 p.m.
> To: Jacqui Ross
> Subject: Re: FIJI 2D stitching in a macro
>
>
>
> Hi Jaqui,
>
>
>
> The attached macro (Stitch_BTM.ijm) should run fine with the latest
> Stitching plugin from Fiji (the one with the updated fields).
>
> It runs OK on my setup for the attached folder (the same you sent me but
> I removed the "Tiled" folder). Just run the macro, choose the
> "Christophe" folder in the dialog (you have to choose the parent folder
> that contains the "bottom", "middle" and "top" folders), it will create
> an additional "tiled" folder where it will store the resulting images
> with "fused00X.tif" names.
>
>
>
> One caution : the folders inside the parent folder must be named exaclty
> "bottom", "middle" and "top", these folders must only contain images
> that are used for stitiching and no other files or images, and the
> images must be named "bottom00X.tif", "middle00X.tif", "top00X.tif"
> (with three digits).
>
>
>
> Hope this helps,
>
>
>
> Christophe
>
>
>
> On Wed, Nov 17, 2010 at 06:31, Jacqui Ross <[hidden email]>
> wrote:
>
> Hi Christophe,
>
>
> Thanks very much for your kind offer to assist me.
>
>
>
> As you suggested,  I have attached a .zip file containing 4 folders,  3
> of which contain the raw data to be tiled. The other folder (Tiled)
> contains one merged image, which will give you an idea of the overlap,
> which is around 30%. As you will see, it's not ideal because it doesn't
> comprise a square/rectangle, which would be better.
>
> However, the 2D Stitch plugin seemed to do this tiling effortlessly with
> a nice result as you will see.
>
>
>
> I will look forward to hearing how you get on with this. It's not super
> urgent so whenever you have time to take a look will be fine.
>
>
>
> Thanks!
>
>
> Kind regards,
>
>
>
> Jacqui
>
> Jacqueline Ross
>
> Biomedical Imaging Microscopist
> Biomedical Imaging Research Unit
> School of Medical Sciences
> Faculty of Medical & Health Sciences
> The University of Auckland
> Private Bag 92019
> Auckland, NEW ZEALAND
>
> Tel: 64 9 373 7599 Ext 87438
> Fax: 64 9 373 7484
>
> http://www.fmhs.auckland.ac.nz/sms/biru/
>
Reply | Threaded
Open this post in threaded view
|

Re: FIJI 2D stitching in a macro - solution!

dksamuel
Thank you so much Dr.Christophe Leterrier for your help, regards,
Samuel, Bangalore, India
PS, hope others would follow this fine example

On Mon, Nov 22, 2010 at 2:31 PM, Christophe Leterrier
<[hidden email]> wrote:

> Hi Jacqui,
>
> I'm glad the macro is helpful. If someone on the list wants to re-use it, or
> for Stephan to include it, I've uploaded a fully commented version here :
>
> http://www.cleterrier.net/macros/Stitch_BMT.ijm
>
> Best Regards,
>
> Christophe
>
> On Mon, Nov 22, 2010 at 05:52, Jacqui Ross <[hidden email]>wrote:
>
>> Hi Everyone,
>>
>>
>> Christophe Leterrier has very kindly written a macro for me, which
>> solved my problem. This macro tiles the 3 images together perfectly
>> (even though they are a zigzag) and saves each tiled image as a separate
>> TIFF file. I was then able to open the sequence of tiled images as a
>> virtual stack and save out as AVI.
>>
>>
>>
>> I have forwarded (below) the email that Christophe sent me as
>> explanation of the macro. I have also included  one where I have
>> described the data that I sent him, so that you will know how the
>> folders work. It has taught me some useful information about how to
>> write these kinds of macros.
>>
>>
>>
>> The macro is called Stitch BMT. I have copied it below. I hope the
>> formatting is preserved since it wasn't last time. The macro file itself
>> was rejected by the listserver.
>>
>>
>>
>>
>>
>> macro "Stitch BMT" {
>>
>>
>>
>>                PARENT_PATH=getDirectory("Select a directory");
>>
>>
>>
>>                File.makeDirectory(PARENT_PATH+"tiled");
>>
>>                POSITION=newArray("bottom", "middle", "top");
>>
>>
>> ALL_NAMES=getFileList(PARENT_PATH+POSITION[0]+File.separator);
>>
>>
>>
>>                for (i=1; i<=ALL_NAMES.length; i++) {
>>
>>
>>
>>
>> BOTTOM_IMAGE=POSITION[0]+pad(i,3,0)+".tif";
>>
>>
>> MIDDLE_IMAGE=POSITION[1]+pad(i,3,0)+".tif";
>>
>>                                TOP_IMAGE=POSITION[2]+pad(i,3,0)+".tif";
>>
>>                                FUSED_IMAGE="fused"+pad(i,3,0)+".tif";
>>
>>
>>
>>
>> BOTTOM_PATH=PARENT_PATH+POSITION[0]+File.separator+BOTTOM_IMAGE;
>>
>>
>> MIDDLE_PATH=PARENT_PATH+POSITION[1]+File.separator+MIDDLE_IMAGE;
>>
>>
>> TOP_PATH=PARENT_PATH+POSITION[2]+File.separator+TOP_IMAGE;
>>
>>
>> FUSED_PATH=PARENT_PATH+File.separator+"tiled"+File.separator+FUSED_IMAGE
>> ;
>>
>>
>>
>>                                print("\n");
>>
>>                                print("bottom: "+BOTTOM_IMAGE);
>>
>>                                print("middle: "+MIDDLE_IMAGE);
>>
>>                                print("top: "+TOP_IMAGE);
>>
>>                                print("fused: "+FUSED_IMAGE);
>>
>>
>>
>>                                open(BOTTOM_PATH);
>>
>>                                open(MIDDLE_PATH);
>>
>>                                open(TOP_PATH);
>>
>>
>>
>>                                run("2D Stitching", "first_image="+
>> BOTTOM_IMAGE +" use_channel_for_first=[Red, Green and Blue]
>> second_image="+ MIDDLE_IMAGE +" use_channel_for_second=[Red, Green and
>> Blue] use_windowing how_many_peaks=5 create_merged_image
>> fusion_method=[Linear Blending] fusion=1.50 fused_image=temp.tif
>> compute_overlap x=0 y=0");
>>
>>                                run("2D Stitching",
>> "first_image=temp.tif use_channel_for_first=[Red, Green and Blue]
>> second_image="+ TOP_IMAGE +" use_channel_for_second=[Red, Green and
>> Blue] use_windowing how_many_peaks=5 create_merged_image
>> fusion_method=[Linear Blending] fusion=1.50 fused_image="+ FUSED_IMAGE
>> +" compute_overlap x=0 y=0");
>>
>>
>>
>>                                selectWindow(BOTTOM_IMAGE);
>>
>>                                close();
>>
>>                                selectWindow(MIDDLE_IMAGE);
>>
>>                                close();
>>
>>                                selectWindow(TOP_IMAGE);
>>
>>                                close();
>>
>>                                selectWindow("temp.tif");
>>
>>                                close();
>>
>>                                selectWindow(FUSED_IMAGE);
>>
>>                                save(FUSED_PATH);
>>
>>                                close();
>>
>>
>>
>>                }
>>
>> }
>>
>>
>>
>> function pad(number, width, character) {
>>
>>       number = toString(number); // force string
>>
>>       character = toString(character);
>>
>>       for (len = lengthOf(number); len < width; len++)
>>
>>               number = character + number;
>>
>>       return number;
>>
>> }
>>
>>
>>
>> I hope it will also be of use to others.
>>
>>
>>
>> Thanks Christophe for your efforts!
>>
>>
>>
>> Kind regards,
>>
>>
>>
>> Jacqui
>>
>>
>>
>> Jacqueline Ross
>>
>> Biomedical Imaging Microscopist
>> Biomedical Imaging Research Unit
>> School of Medical Sciences
>> Faculty of Medical & Health Sciences
>> The University of Auckland
>> Private Bag 92019
>> Auckland, NEW ZEALAND
>>
>> Tel: 64 9 373 7599 Ext 87438
>> Fax: 64 9 373 7484
>>
>> http://www.fmhs.auckland.ac.nz/sms/biru/
>>
>> From: Christophe Leterrier [mailto:[hidden email]]
>> Sent: Wednesday, 17 November 2010 10:27 p.m.
>> To: Jacqui Ross
>> Subject: Re: FIJI 2D stitching in a macro
>>
>>
>>
>> Hi Jaqui,
>>
>>
>>
>> The attached macro (Stitch_BTM.ijm) should run fine with the latest
>> Stitching plugin from Fiji (the one with the updated fields).
>>
>> It runs OK on my setup for the attached folder (the same you sent me but
>> I removed the "Tiled" folder). Just run the macro, choose the
>> "Christophe" folder in the dialog (you have to choose the parent folder
>> that contains the "bottom", "middle" and "top" folders), it will create
>> an additional "tiled" folder where it will store the resulting images
>> with "fused00X.tif" names.
>>
>>
>>
>> One caution : the folders inside the parent folder must be named exaclty
>> "bottom", "middle" and "top", these folders must only contain images
>> that are used for stitiching and no other files or images, and the
>> images must be named "bottom00X.tif", "middle00X.tif", "top00X.tif"
>> (with three digits).
>>
>>
>>
>> Hope this helps,
>>
>>
>>
>> Christophe
>>
>>
>>
>> On Wed, Nov 17, 2010 at 06:31, Jacqui Ross <[hidden email]>
>> wrote:
>>
>> Hi Christophe,
>>
>>
>> Thanks very much for your kind offer to assist me.
>>
>>
>>
>> As you suggested,  I have attached a .zip file containing 4 folders,  3
>> of which contain the raw data to be tiled. The other folder (Tiled)
>> contains one merged image, which will give you an idea of the overlap,
>> which is around 30%. As you will see, it's not ideal because it doesn't
>> comprise a square/rectangle, which would be better.
>>
>> However, the 2D Stitch plugin seemed to do this tiling effortlessly with
>> a nice result as you will see.
>>
>>
>>
>> I will look forward to hearing how you get on with this. It's not super
>> urgent so whenever you have time to take a look will be fine.
>>
>>
>>
>> Thanks!
>>
>>
>> Kind regards,
>>
>>
>>
>> Jacqui
>>
>> Jacqueline Ross
>>
>> Biomedical Imaging Microscopist
>> Biomedical Imaging Research Unit
>> School of Medical Sciences
>> Faculty of Medical & Health Sciences
>> The University of Auckland
>> Private Bag 92019
>> Auckland, NEW ZEALAND
>>
>> Tel: 64 9 373 7599 Ext 87438
>> Fax: 64 9 373 7484
>>
>> http://www.fmhs.auckland.ac.nz/sms/biru/
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: FIJI 2D stitching in a macro - solution!

Jacqueline Ross
In reply to this post by lechristophe
Hi Christophe,

Thanks very much for making that macro easily accessible and including
the instructions as well. I'm sure it will benefit others.

Kind regards,

Jacqui

Jacqueline Ross

Biomedical Imaging Microscopist
Biomedical Imaging Research Unit
School of Medical Sciences
Faculty of Medical & Health Sciences
The University of Auckland
Private Bag 92019
Auckland, NEW ZEALAND

Tel: 64 9 373 7599 Ext 87438
Fax: 64 9 373 7484

http://www.fmhs.auckland.ac.nz/sms/biru/


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Christophe Leterrier
Sent: Monday, 22 November 2010 10:01 p.m.
To: [hidden email]
Subject: Re: FIJI 2D stitching in a macro - solution!

Hi Jacqui,

I'm glad the macro is helpful. If someone on the list wants to re-use
it, or
for Stephan to include it, I've uploaded a fully commented version here
:

http://www.cleterrier.net/macros/Stitch_BMT.ijm

Best Regards,

Christophe

On Mon, Nov 22, 2010 at 05:52, Jacqui Ross
<[hidden email]>wrote:

> Hi Everyone,
>
>
> Christophe Leterrier has very kindly written a macro for me, which
> solved my problem. This macro tiles the 3 images together perfectly
> (even though they are a zigzag) and saves each tiled image as a
separate

> TIFF file. I was then able to open the sequence of tiled images as a
> virtual stack and save out as AVI.
>
>
>
> I have forwarded (below) the email that Christophe sent me as
> explanation of the macro. I have also included  one where I have
> described the data that I sent him, so that you will know how the
> folders work. It has taught me some useful information about how to
> write these kinds of macros.
>
>
>
> The macro is called Stitch BMT. I have copied it below. I hope the
> formatting is preserved since it wasn't last time. The macro file
itself

> was rejected by the listserver.
>
>
>
>
>
> macro "Stitch BMT" {
>
>
>
>                PARENT_PATH=getDirectory("Select a directory");
>
>
>
>                File.makeDirectory(PARENT_PATH+"tiled");
>
>                POSITION=newArray("bottom", "middle", "top");
>
>
> ALL_NAMES=getFileList(PARENT_PATH+POSITION[0]+File.separator);
>
>
>
>                for (i=1; i<=ALL_NAMES.length; i++) {
>
>
>
>
> BOTTOM_IMAGE=POSITION[0]+pad(i,3,0)+".tif";
>
>
> MIDDLE_IMAGE=POSITION[1]+pad(i,3,0)+".tif";
>
>
TOP_IMAGE=POSITION[2]+pad(i,3,0)+".tif";

>
>                                FUSED_IMAGE="fused"+pad(i,3,0)+".tif";
>
>
>
>
> BOTTOM_PATH=PARENT_PATH+POSITION[0]+File.separator+BOTTOM_IMAGE;
>
>
> MIDDLE_PATH=PARENT_PATH+POSITION[1]+File.separator+MIDDLE_IMAGE;
>
>
> TOP_PATH=PARENT_PATH+POSITION[2]+File.separator+TOP_IMAGE;
>
>
>
FUSED_PATH=PARENT_PATH+File.separator+"tiled"+File.separator+FUSED_IMAGE

> ;
>
>
>
>                                print("\n");
>
>                                print("bottom: "+BOTTOM_IMAGE);
>
>                                print("middle: "+MIDDLE_IMAGE);
>
>                                print("top: "+TOP_IMAGE);
>
>                                print("fused: "+FUSED_IMAGE);
>
>
>
>                                open(BOTTOM_PATH);
>
>                                open(MIDDLE_PATH);
>
>                                open(TOP_PATH);
>
>
>
>                                run("2D Stitching", "first_image="+
> BOTTOM_IMAGE +" use_channel_for_first=[Red, Green and Blue]
> second_image="+ MIDDLE_IMAGE +" use_channel_for_second=[Red, Green and
> Blue] use_windowing how_many_peaks=5 create_merged_image
> fusion_method=[Linear Blending] fusion=1.50 fused_image=temp.tif
> compute_overlap x=0 y=0");
>
>                                run("2D Stitching",
> "first_image=temp.tif use_channel_for_first=[Red, Green and Blue]
> second_image="+ TOP_IMAGE +" use_channel_for_second=[Red, Green and
> Blue] use_windowing how_many_peaks=5 create_merged_image
> fusion_method=[Linear Blending] fusion=1.50 fused_image="+ FUSED_IMAGE
> +" compute_overlap x=0 y=0");
>
>
>
>                                selectWindow(BOTTOM_IMAGE);
>
>                                close();
>
>                                selectWindow(MIDDLE_IMAGE);
>
>                                close();
>
>                                selectWindow(TOP_IMAGE);
>
>                                close();
>
>                                selectWindow("temp.tif");
>
>                                close();
>
>                                selectWindow(FUSED_IMAGE);
>
>                                save(FUSED_PATH);
>
>                                close();
>
>
>
>                }
>
> }
>
>
>
> function pad(number, width, character) {
>
>       number = toString(number); // force string
>
>       character = toString(character);
>
>       for (len = lengthOf(number); len < width; len++)
>
>               number = character + number;
>
>       return number;
>
> }
>
>
>
> I hope it will also be of use to others.
>
>
>
> Thanks Christophe for your efforts!
>
>
>
> Kind regards,
>
>
>
> Jacqui
>
>
>
> Jacqueline Ross
>
> Biomedical Imaging Microscopist
> Biomedical Imaging Research Unit
> School of Medical Sciences
> Faculty of Medical & Health Sciences
> The University of Auckland
> Private Bag 92019
> Auckland, NEW ZEALAND
>
> Tel: 64 9 373 7599 Ext 87438
> Fax: 64 9 373 7484
>
> http://www.fmhs.auckland.ac.nz/sms/biru/
>
> From: Christophe Leterrier [mailto:[hidden email]]
> Sent: Wednesday, 17 November 2010 10:27 p.m.
> To: Jacqui Ross
> Subject: Re: FIJI 2D stitching in a macro
>
>
>
> Hi Jaqui,
>
>
>
> The attached macro (Stitch_BTM.ijm) should run fine with the latest
> Stitching plugin from Fiji (the one with the updated fields).
>
> It runs OK on my setup for the attached folder (the same you sent me
but
> I removed the "Tiled" folder). Just run the macro, choose the
> "Christophe" folder in the dialog (you have to choose the parent
folder
> that contains the "bottom", "middle" and "top" folders), it will
create
> an additional "tiled" folder where it will store the resulting images
> with "fused00X.tif" names.
>
>
>
> One caution : the folders inside the parent folder must be named
exaclty

> "bottom", "middle" and "top", these folders must only contain images
> that are used for stitiching and no other files or images, and the
> images must be named "bottom00X.tif", "middle00X.tif", "top00X.tif"
> (with three digits).
>
>
>
> Hope this helps,
>
>
>
> Christophe
>
>
>
> On Wed, Nov 17, 2010 at 06:31, Jacqui Ross
<[hidden email]>

> wrote:
>
> Hi Christophe,
>
>
> Thanks very much for your kind offer to assist me.
>
>
>
> As you suggested,  I have attached a .zip file containing 4 folders,
3
> of which contain the raw data to be tiled. The other folder (Tiled)
> contains one merged image, which will give you an idea of the overlap,
> which is around 30%. As you will see, it's not ideal because it
doesn't
> comprise a square/rectangle, which would be better.
>
> However, the 2D Stitch plugin seemed to do this tiling effortlessly
with
> a nice result as you will see.
>
>
>
> I will look forward to hearing how you get on with this. It's not
super

> urgent so whenever you have time to take a look will be fine.
>
>
>
> Thanks!
>
>
> Kind regards,
>
>
>
> Jacqui
>
> Jacqueline Ross
>
> Biomedical Imaging Microscopist
> Biomedical Imaging Research Unit
> School of Medical Sciences
> Faculty of Medical & Health Sciences
> The University of Auckland
> Private Bag 92019
> Auckland, NEW ZEALAND
>
> Tel: 64 9 373 7599 Ext 87438
> Fax: 64 9 373 7484
>
> http://www.fmhs.auckland.ac.nz/sms/biru/
>