Posted by
Christine Labno-2 on
Feb 20, 2014; 8:29pm
URL: http://imagej.273.s1.nabble.com/Merge-Channels-Macro-tp3684311p5006609.html
Hello,
Michael is right, you need to set up a dialog to ask the user for information. Here is some example code that I created a long time ago -- it's not elegant, but it does the job you want -- you can use this as a guide to create your own dialog.
------------snip---------------
//begin with three separate images, one for red, one for green and one for blue.
//open the images and then run the macro
run("Images to Stack", "name=Stack title=[] use");
t1=getInfo("slice.label");
setSlice(2);
t2=getInfo("slice.label");
setSlice(3);
t3=getInfo("slice.label");
Dialog.create("Color Choices");
Dialog.addChoice("Red:", newArray(t1, t2, t3));
Dialog.addChoice("Green:", newArray(t1, t2, t3));
Dialog.addChoice("Blue:", newArray(t1, t2, t3));
Dialog.show();
R = Dialog.getChoice();
G = Dialog.getChoice();;
B = Dialog.getChoice();;;
run("Stack to Images");
selectWindow(R);
rename("red");
selectWindow(G);
rename("green");
selectWindow(B);
rename("blue");
run("Merge Channels...", "c1=[red] c2=[green] c3=[blue]");
--------------snip----------------------------------------
Best,
Christine
--------------------------------------------
Christine Labno, Ph.D.
Asst. Technical Director
Light Microscopy Core
University of Chicago
Office of Shared Research Facilities
KCBD 1250 900 E. 57th St.
(773) 834-9040 (phone)
________________________________________
From: ImageJ Interest Group [
[hidden email]] on behalf of Cammer, Michael [
[hidden email]]
Sent: Thursday, February 20, 2014 10:28 AM
To:
[hidden email]
Subject: Re: Merge Channels Macro
First set up a dialog that prompts the user for the information.
http://rsbweb.nih.gov/ij/developer/macro/functions.html#DThen use the answers the user inputs to do the merge.
===========================================================================
Michael Cammer, Microscopy Core & Dustin Lab , Skirball Institute, NYU Langone Medical Center
Cell: 914-309-3270 Lab: 212-263-3208
http://ocs.med.nyu.edu/microscopy &
http://www.med.nyu.edu/skirball-lab/dustinlab/-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of mmettlen
Sent: Thursday, February 20, 2014 9:39 AM
To:
[hidden email]
Subject: Re: Merge Channels Macro
I'm trying to write a macro in which the user chooses which open images to merge. Thus, my macro includes: /run("Merge Channels..."};/. Now, I'd like to activate by default "keep" and "create". However, if I include in my macro /run("Merge Channels...", "keep, create");/, the merging runs through without giving the user the possibility to choose what channels to merge.
Any way around that?
--
View this message in context:
http://imagej.1557.x6.nabble.com/Merge-Channels-Macro-tp3684311p5006600.htmlSent from the ImageJ mailing list archive at Nabble.com.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html