Merge Macro Question (resent)

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

Merge Macro Question (resent)

David
Apologies if this somehow appears twice,

 

I am trying to write a macro that merges two channels (recently split
with the "Split Channels" command) and have a problem.  The images are
.nd2 files and are being imported with default settings and open as a
two-channel composite image.  The images, after being split, are named
"C1-001.nd2" and "C2-001.nd2" where "C1-" and "C2-" are added by the
"Split Channels" command and the 'number'.nd2 varies with the number of
the image.  

 

My issue lies in the fact that I am unable to create a macro to Merge
Channels using the "C1" and "C2" designation - I just can't figure out
how to make a wildcard so that any image named "C1 - 'whatever'" is
green and "C2-'whatever'" is blue.  Could someone please point out how
to properly use wildcards in ImageJ macros OR tell me how to solve this
conundrum?

 

Thanks very much,

 

David

 
Reply | Threaded
Open this post in threaded view
|

Re: Merge Macro Question (resent)

ctrueden
Hi David,

I am trying to write a macro that merges two channels (recently split
> with the "Split Channels" command) and have a problem.  The images are
> .nd2 files and are being imported with default settings and open as a
> two-channel composite image.
>

First of all, is there some reason you must split the channels and then
remerge them, rather than just operating on the composite image itself? If
you need an RGB result, you can convert using Image > Type > RGB Color
directly from the composite image.

My issue lies in the fact that I am unable to create a macro to Merge
> Channels using the "C1" and "C2" designation - I just can't figure out
> how to make a wildcard so that any image named "C1 - 'whatever'" is
> green and "C2-'whatever'" is blue.
>

Use the getTitle() function to access the original image's title before
splitting. Then you can use it when building the names. Here is an example
macro:

title = getTitle();
getDimensions(width, height, channels, slices, frames);
if (channels != 2) {
  exit("2-channel image required");
}
run("Split Channels");
c1Title = "C1-" + title;
c2Title = "C2-" + title;
run("Merge Channels...", "red=*None* green=[" + c1Title + "] blue=[" +
c2Title + "] gray=*None* create");

I noticed with 1.45s there may be a bug in Merge Channels with "Create
composite" enabled in that the channels are not green & blue as requested.
If you leave off the "create" flag it will make an RGB image that looks
correct.

HTH,
Curtis


On Wed, Nov 9, 2011 at 12:47 PM, David Burk <[hidden email]> wrote:

> Apologies if this somehow appears twice,
>
>
>
> I am trying to write a macro that merges two channels (recently split
> with the "Split Channels" command) and have a problem.  The images are
> .nd2 files and are being imported with default settings and open as a
> two-channel composite image.  The images, after being split, are named
> "C1-001.nd2" and "C2-001.nd2" where "C1-" and "C2-" are added by the
> "Split Channels" command and the 'number'.nd2 varies with the number of
> the image.
>
>
>
> My issue lies in the fact that I am unable to create a macro to Merge
> Channels using the "C1" and "C2" designation - I just can't figure out
> how to make a wildcard so that any image named "C1 - 'whatever'" is
> green and "C2-'whatever'" is blue.  Could someone please point out how
> to properly use wildcards in ImageJ macros OR tell me how to solve this
> conundrum?
>
>
>
> Thanks very much,
>
>
>
> David
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Merge Macro Question (resent)

David
Curtis,

Thanks very much; that worked like a charm.

David

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Curtis Rueden
Sent: Wednesday, November 09, 2011 1:28 PM
To: [hidden email]
Subject: Re: Merge Macro Question (resent)

Hi David,

I am trying to write a macro that merges two channels (recently split
> with the "Split Channels" command) and have a problem.  The images are
> .nd2 files and are being imported with default settings and open as a
> two-channel composite image.
>

First of all, is there some reason you must split the channels and then
remerge them, rather than just operating on the composite image itself?
If you need an RGB result, you can convert using Image > Type > RGB
Color directly from the composite image.

My issue lies in the fact that I am unable to create a macro to Merge
> Channels using the "C1" and "C2" designation - I just can't figure out

> how to make a wildcard so that any image named "C1 - 'whatever'" is
> green and "C2-'whatever'" is blue.
>

Use the getTitle() function to access the original image's title before
splitting. Then you can use it when building the names. Here is an
example
macro:

title = getTitle();
getDimensions(width, height, channels, slices, frames); if (channels !=
2) {
  exit("2-channel image required");
}
run("Split Channels");
c1Title = "C1-" + title;
c2Title = "C2-" + title;
run("Merge Channels...", "red=*None* green=[" + c1Title + "] blue=[" +
c2Title + "] gray=*None* create");

I noticed with 1.45s there may be a bug in Merge Channels with "Create
composite" enabled in that the channels are not green & blue as
requested.
If you leave off the "create" flag it will make an RGB image that looks
correct.

HTH,
Curtis


On Wed, Nov 9, 2011 at 12:47 PM, David Burk <[hidden email]> wrote:

> Apologies if this somehow appears twice,
>
>
>
> I am trying to write a macro that merges two channels (recently split
> with the "Split Channels" command) and have a problem.  The images are
> .nd2 files and are being imported with default settings and open as a
> two-channel composite image.  The images, after being split, are named

> "C1-001.nd2" and "C2-001.nd2" where "C1-" and "C2-" are added by the
> "Split Channels" command and the 'number'.nd2 varies with the number
> of the image.
>
>
>
> My issue lies in the fact that I am unable to create a macro to Merge
> Channels using the "C1" and "C2" designation - I just can't figure out

> how to make a wildcard so that any image named "C1 - 'whatever'" is
> green and "C2-'whatever'" is blue.  Could someone please point out how

> to properly use wildcards in ImageJ macros OR tell me how to solve
> this conundrum?
>
>
>
> Thanks very much,
>
>
>
> David
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Merge Macro Question (resent)

ctrueden
Hi David & all,

Thanks very much; that worked like a charm.
>

Great, glad to hear it.

On Wed, Nov 9, 2011 at 6:44 PM, Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]> wrote:

>  > I noticed with 1.45s there may be a bug in Merge Channels with "Create
> > composite" enabled in that the channels are not green & blue as
> requested.
> > If you leave off the "create" flag it will make an RGB image that looks
> > correct.
>
> Did you try enabling the "Ignore source LUTs" option? Merge Channels uses
> the source image LUTs, if any, when this option is not enabled.
>

As Wayne points out, there is no bug. You just have to check "Ignore source
LUTs" when merging back to a composite image. Otherwise ImageJ is too smart
and preserves them. :-)

Cheers,
Curtis


On Fri, Nov 11, 2011 at 10:49 AM, David Burk <[hidden email]> wrote:

> Curtis,
>
> Thanks very much; that worked like a charm.
>
> David
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Curtis Rueden
> Sent: Wednesday, November 09, 2011 1:28 PM
> To: [hidden email]
> Subject: Re: Merge Macro Question (resent)
>
> Hi David,
>
> I am trying to write a macro that merges two channels (recently split
> > with the "Split Channels" command) and have a problem.  The images are
> > .nd2 files and are being imported with default settings and open as a
> > two-channel composite image.
> >
>
> First of all, is there some reason you must split the channels and then
> remerge them, rather than just operating on the composite image itself?
> If you need an RGB result, you can convert using Image > Type > RGB
> Color directly from the composite image.
>
> My issue lies in the fact that I am unable to create a macro to Merge
> > Channels using the "C1" and "C2" designation - I just can't figure out
>
> > how to make a wildcard so that any image named "C1 - 'whatever'" is
> > green and "C2-'whatever'" is blue.
> >
>
> Use the getTitle() function to access the original image's title before
> splitting. Then you can use it when building the names. Here is an
> example
> macro:
>
> title = getTitle();
> getDimensions(width, height, channels, slices, frames); if (channels !=
> 2) {
>  exit("2-channel image required");
> }
> run("Split Channels");
> c1Title = "C1-" + title;
> c2Title = "C2-" + title;
> run("Merge Channels...", "red=*None* green=[" + c1Title + "] blue=[" +
> c2Title + "] gray=*None* create");
>
> I noticed with 1.45s there may be a bug in Merge Channels with "Create
> composite" enabled in that the channels are not green & blue as
> requested.
> If you leave off the "create" flag it will make an RGB image that looks
> correct.
>
> HTH,
> Curtis
>
>
> On Wed, Nov 9, 2011 at 12:47 PM, David Burk <[hidden email]> wrote:
>
> > Apologies if this somehow appears twice,
> >
> >
> >
> > I am trying to write a macro that merges two channels (recently split
> > with the "Split Channels" command) and have a problem.  The images are
> > .nd2 files and are being imported with default settings and open as a
> > two-channel composite image.  The images, after being split, are named
>
> > "C1-001.nd2" and "C2-001.nd2" where "C1-" and "C2-" are added by the
> > "Split Channels" command and the 'number'.nd2 varies with the number
> > of the image.
> >
> >
> >
> > My issue lies in the fact that I am unable to create a macro to Merge
> > Channels using the "C1" and "C2" designation - I just can't figure out
>
> > how to make a wildcard so that any image named "C1 - 'whatever'" is
> > green and "C2-'whatever'" is blue.  Could someone please point out how
>
> > to properly use wildcards in ImageJ macros OR tell me how to solve
> > this conundrum?
> >
> >
> >
> > Thanks very much,
> >
> >
> >
> > David
> >
> >
> >
>