http://imagej.273.s1.nabble.com/zvi-to-RGB-more-code-tp3691804p3691806.html
> Dear Senger, Your channel assignments are hard coded into the macro,
> which assumes that it will only be used with 3 channel files
> containing blue, green and red fluorophores. Will this always be the
> case? I'm including this macro I just finished to open a dataset
> using a dialog window for users to assign channels to desired LUT.
> I'm sure it needs improvement too.
>
> Glen MacDonald
> Core for Communication Research
> Virginia Merrill Bloedel Hearing Research Center
> Box 357923
> University of Washington
> Seattle, WA 98195-7923
> (206) 616-4156
>
> -------------------------------------
> //Written by Glen MacDonald, Core for Communication Research
> //Virginia Merrill Bloedel Hearing Research Center
> //Box 357923
> //University of Washington
> //Seattle, WA 98195-7923
> //
[hidden email]
> //Requires the LOCI_tools plugin. On running the first macro, select
> a file, the dialog window will
> // display number of channels and bit depth. Select merge options of
> "RGB", "Composite Hyperstack"
> // or "No Merge" Select a channels (0-n) for each color channel.
> Error trapping: If you choose a //channel not present, the macro goes
> through the motions of opening the file then exits with a //message
> that the channel is not present. Placing any channel into 2 colors
> will create an RGB merge.
>
> var name,pType;
> macro "Import Channel Order [1]"{
> requires("1.41c");
> run("Bio-Formats Macro Extensions");
> path=File.openDialog("Select a file");
> id=path;
> name=File.getName(path);//gets the filename in this path
> Ext.setId(id);
> Ext.getSizeC(sizeC);//delivers the number of channels
> Ext.getPixelType(pixelType);
> pelType=pixelType;
> matchPixelType(pType);
> Dialog.create("Channel Merge Options");
> Dialog.addChoice("Merge Type:", newArray("RGB", "Hyperstack", "No
> merge"),"RGB"); Dialog.addMessage("Assign "+sizeC+" stacks to merged
> color channels.\nBit depth is "+pType+" per pixel.");
> Dialog.addMessage("Red merged channel:");
> Dialog.addChoice("Channels:", newArray("None","0", "1", "2",
> "3","4"),"2"); Dialog.addMessage("Green merged channel:");
> Dialog.addChoice("Channels:", newArray("None","0", "1", "2",
> "3","4"),"1");
> Dialog.addMessage("Blue merged channel:");
> Dialog.addChoice("Channels:", newArray("None","0", "1", "2",
> "3","4"),"0");
> Dialog.addMessage("Gray merged channel:");
> Dialog.addChoice("Channels:", newArray("None","0", "1", "2",
> "3","4"),"None");
> Dialog.show();
> merge=Dialog.getChoice();
> if (merge=="RGB")
> create = " ";
> if (merge=="Hyperstack")
> create = "create"; if (merge!="No merge"){
> setBatchMode(true);
> options="open=["+path+"] view=[Standard ImageJ]
> stack_order=Default split_channels autoscale"; //set options for
> bio-formats
> showStatus("opening file");
> run("Bio-Formats Importer",options);
> nameCh=name+" - C=";
> red= Dialog.getChoice();
> grn= Dialog.getChoice();
> blu= Dialog.getChoice();
> gry= Dialog.getChoice();
> chno=0;
> if (red!= "None"){
> redc =nameCh+red;
> chno=red;
> }else
> redc = "*None*";
> if (grn != "None"){
> grnc =nameCh+grn;
> if (chno<grn)
> chno=grn;
> }else
> grnc = "*None*";
> if (blu != "None"){
> bluc =nameCh+blu;
> if (chno<blu)
> chno=blu;
> }else
> bluc = "*None*";
> if (gry != "None"){
> gryc =nameCh+gry;
> if (chno<gry)
> chno=gry;
> }else
> gryc = "*None*";
> chno=chno+1;
> if (chno>sizeC)
> exit("You selected too many channels, only "+sizeC+" channels are
> present.");
> createtype="red=["+redc+"] green=["+grnc+"] blue=["+bluc+"]
> gray=["+gryc+"] "+create;
> run("Merge Channels...", createtype);
> //example: run("Merge Channels...", "red=[Image0007.oif - C=0]
> green=[Image0007.oif - C=1] blue=[Image0007.oif - C=2] gray=*None*
> create keep");
> prefix=substring(name,0,indexOf(name,"."));
> rename(prefix+"_merge");
> setBatchMode(false);
> }
> else{
> options="open=["+path+"] view=[Standard ImageJ]
> stack_order=Default split_channels autoscale";
> showStatus("opening file");
> run("Bio-Formats Importer",options);
> }
> }
>
> function matchPixelType(pelType){
> if (matches(pixelType,"uint8"))
> pType = "unsigned 8-bits";
> if (matches(pixelType,"uint16"))
> pType = "unsigned 16-bits";
> if (matches(pixelType,"uint32"))
> pType = "unsigned 32-bits";
> if (matches(pixelType,"int8"))
> pType = "signed 8-bits";
> if (matches(pixelType,"int16"))
> pType = "signed 16-bits";
> if (matches(pixelType,"int32"))
> pType = "signed 32-bits";
> if (matches(pixelType,"float"))
> pType = "floating point 32-bits";
> if (matches(pixelType,"double"))
> pType = "64-bits double precision";
> }
>
> macro "Composite Hyperstack to RGB [2]"{
> run("Channels Tool...");
> run("Stack to RGB");
> }
>
> -----------------------------------------
> On Fri, 10 Jul 2009, Senger Fabrice wrote:
>
>> Hi again,
>>
>> i'm still working on a macro to open zvi files as RGB stacks, the
>> code has evolved but still I would appreciate feed-back.
>> In this case, what I do not like , is that the "Channels" window is
>> still open...but it is faster then my prvious code.
>>
>>
>> Here the code :
>>
>> setBatchMode(true);
>>
>>
>> run("Data Browser", "open= autoscale custom_colorize view=[Standard
>> ImageJ] stack_order=Default series_0_channel_0_red=0
>> series_0_channel_0_green=0 series_0_channel_0_blue=255
>> series_0_channel_1_red=0 series_0_channel_1_green=255
>> series_0_channel_1_blue=0 series_0_channel_2_red=255
>> series_0_channel_2_green=0 series_0_channel_2_blue=0");
>> run("Channels Tool...");
>> Stack.setDisplayMode("composite");
>> run("Stack to RGB", "slices keep");
>>
>> setBatchMode(false)
>>
>> --
>> Senger Fabrice
easily as with axiovision, therefore your code will be very helpfull to me.
Fabrice.