Using getTitle()

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

Using getTitle()

mnqslbs2
Hello all,

I'm very new to programming macro and plug-ins for image J.  
I'm trying speed up the process I do by using macros linked to shortcut keys on the keyboard, this I have managed.  
I have a problem with the macro I'm writing at the moment.
I have two stacks that I am merging to give a stack with one signal in green and the other in magenta to look for colocalisation.  
The stacks are called "Series003 Red" and "Series003 Green" however the 003 sometimes changes to 004, or 005 etc.  Everything else remains the same.  

This is what I have so far:--

name = getTitle()

run("Merge Channels...", "red=[name Red] green=[name Green] blue=[name Red] gray=*None*");

saveAs("Tiff");

--So I have used getTitle to specify name = Series003 Red
My problem is how to tell the macro to drop the "Red" portion and just give me "Series003", therefore returning the correct name if the series number is not 003 but 004 etc.  I need to drop the "Red" part to use the returned name for the green channel.  

I hope this makes more sense to you than it does to me.  

I look forward to seeing if this can been done (it must be possible)..

Cheers
Reply | Threaded
Open this post in threaded view
|

Re: Using getTitle()

jmutterer
On Mon, Mar 9, 2009 at 2:29 PM, mnqslbs2 <[hidden email]> wrote:

> Hello all,


Hello,


> The stacks are called "Series003 Red" and "Series003 Green" however the 003
> sometimes changes to 004, or 005 etc.  Everything else remains the same.
>

Get the part of the title string that starts at the beginning and extends to
the last 'space', and use it to build the images names:

name = getTitle();
prefix = substring (name, 0, lastIndexOf(name," "));
run("Merge Channels...", "red=["+prefix+" Red] green=["+prefix+" Green]
blue=*None* gray=*None*");
rename (prefix+"_merged.tif");
saveAs("Tiff");

Sincerely,

Jerome
Reply | Threaded
Open this post in threaded view
|

Re: Using getTitle()

mnqslbs2
Hello Jerome,

Thank you very much, that did the trick.  

Cheers

Ben

jerome mutterer-2 wrote
On Mon, Mar 9, 2009 at 2:29 PM, mnqslbs2 <sutcliffe.ben@gmail.com> wrote:

> Hello all,


Hello,


> The stacks are called "Series003 Red" and "Series003 Green" however the 003
> sometimes changes to 004, or 005 etc.  Everything else remains the same.
>

Get the part of the title string that starts at the beginning and extends to
the last 'space', and use it to build the images names:

name = getTitle();
prefix = substring (name, 0, lastIndexOf(name," "));
run("Merge Channels...", "red=["+prefix+" Red] green=["+prefix+" Green]
blue=*None* gray=*None*");
rename (prefix+"_merged.tif");
saveAs("Tiff");

Sincerely,

Jerome
Reply | Threaded
Open this post in threaded view
|

Re: Using getTitle()

epigenetic
In reply to this post by jmutterer
Hi Jerome,

I have similar problem like jmutterer.
I have two image ;one from red channel and other is from green channel. My file name are "2 min 10x_ch00.tiff" and "2 min 10x_ch01".I dragged and dropped on Imagej window. After that, I try to merge two picture by using macro.I tried your suggestion

name = getTitle();
prefix = substring (name, 0, lastIndexOf(name," "));
run("Merge Channels...", "red=[+prefix+"ch01] green=[+prefix+"ch00] blue=*None* gray=*None* create");
rename (prefix+"_merged.tif");
saveAs("Tiff");  

however, it gave error message like following;

')' expected in line 3.
run("Merge Channels..."',"red=[+prefix+<ch01>] green=[+prefix+ch00] blue=*None* GRAY=*nONE* create');

Could you please tell me how I can merge two diiferent files by using macro?

thanks

Taylan
Reply | Threaded
Open this post in threaded view
|

Re: Using getTitle()

epigenetic
In reply to this post by jmutterer
Hi Jerome,

I have similar problem like jmutterer.
I have two image ;one from red channel and other is from green channel. My file name are "2 min 10x_ch00.tiff" and "2 min 10x_ch01".I dragged and dropped on Imagej window. After that, I try to merge two picture by using macro.I tried your suggestion

name = getTitle();
prefix = substring (name, 0, lastIndexOf(name," "));
run("Merge Channels...", "red=[+prefix+"ch01] green=[+prefix+"ch00] blue=*None* gray=*None* create");
rename (prefix+"_merged.tif");
saveAs("Tiff");  

however, it gave error message like following;

')' expected in line 3.
run("Merge Channels..."',"red=[+prefix+<ch01>] green=[+prefix+ch00] blue=*None* GRAY=*nONE* create');

Could you please tell me how I can merge two diiferent files by using macro?

thanks

Taylan