Last active
December 30, 2015 05:39
-
-
Save mutterer/7784441 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CZI batch project macro | |
// parses the file metadata to work around a bioformat bug | |
// that assigns wrong channel colors. | |
// edit the first two lines to use DIC in the projection or not | |
// and what projection mode is needed (see Image>stacks>Z project...) | |
useDic = true; | |
projectionMode = "Max Intensity"; | |
var r,g,b; | |
title = getTitle(); | |
id=getImageID; | |
Stack.getDimensions(width, height, channels, slices, frames); | |
activeChannels = ""; | |
for (ch=1;ch<= channels;ch++) { | |
dic = getRealChannelColor(ch); | |
if ((useDic==0)&(dic==1)) activeChannels= activeChannels+"0"; | |
else activeChannels= activeChannels+"1"; | |
applyLUT(ch); | |
} | |
Stack.setDisplayMode("composite"); | |
Stack.setActiveChannels(activeChannels); | |
run("Z Project...", "projection=["+projectionMode+"]"); | |
Stack.setDisplayMode("composite"); | |
Stack.setActiveChannels(activeChannels); | |
run("RGB Color"); | |
rename (title); | |
function applyLUT(c){ | |
reds=newArray(256); | |
greens=newArray(256); | |
blues=newArray(256); | |
for (index=0;index<256;index++){ | |
reds[index]=index*r/255; | |
greens[index]=index*g/255; | |
blues[index]=index*b/255; | |
} | |
Stack.setChannel(c); | |
setLut(reds,greens,blues); | |
} | |
function getRealChannelColor(channel){ | |
info=replace(getMetadata('info'),' ',''); | |
List.setList(info); | |
tag="Experiment|AcquisitionBlock|MultiTrackSetup|Track|Channel|Color|#"; | |
rgb = parseInt(substring(List.get(tag+ channel),3),16); | |
r = (rgb&0xff0000)>>16; | |
g =(rgb&0x00ff00)>>8; | |
b =(rgb&0x0000ff); | |
if ((r==g)&&(g==b)) return true; | |
else return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment