//Stack Combiner macro "Stack Combiner"{ //saveSettings(); currtit=getTitle(); nim=nImages; if (nim<2) exit("Not enough images are open"); else { imagetitles=newArray(nim); for (i=1; i<=nim; i++) { selectImage(i); imagetitles[i-1]=getTitle; } } Dialog.create("Stack Combiner"); Dialog.addChoice("Target Stack: ", imagetitles, currtit); next=imagetitles[0]; if(next==currtit) next=imagetitles[1]; Dialog.addChoice("Source Stack: ", imagetitles, next); Dialog.addChoice("Paste Mode: ",newArray("Copy","Max","Transparent-zero"),"Transparent-zero"); Dialog.addCheckbox("Prioritize first stack?",true); Dialog.addCheckbox("Manual offset?",false); Dialog.addNumber("x offset:",0); Dialog.addNumber("y offset:",0); Dialog.show(); left=Dialog.getChoice(); right=Dialog.getChoice(); pmode=Dialog.getChoice(); pfs=Dialog.getCheckbox(); manual=Dialog.getCheckbox(); x=Dialog.getNumber(); y=Dialog.getNumber(); comp=false; selectWindow(left); Stack.getPosition(ch,sl,frm); selectWindow(right); getDimensions(w,h,chs,sls,frms); Stack.setChannel(ch); run("Select All"); run("Copy"); selectWindow(left); run("Duplicate...", "title=temp"); getDimensions(wt,ht,chst,slst,frmst); if(chst>1) Stack.setChannel(ch); if(x!=0)x=wt-x; if(y!=0)y=ht-y; if(!manual){ flags=-1; leftButton=16; centerButton=8; setPasteMode("Max"); snapshot(); isok=true; rtsd=true; while(isok){ while (flags&leftButton!=0) {getCursorLoc(xc, yc, zc, flags); wait(100); } getCursorLoc(x, y, z, flags); while (flags&leftButton==0) { checkchange=false; while (flags¢erButton!=0) {getCursorLoc(xc, yc, zc, flags); wait(100); checkchange=true;} if(checkchange)rtsd=!rtsd; reset(); //snapshot(); getCursorLoc(x, y, z, flags); maxxy=maxOf(x,y); //if(maxxy==x) makeRectangle(x,0,w,h); //else makeRectangle(0,y,w,h); if(rtsd) {y-=0.5*h;} else {x+=-0.5*w; } makeRectangle(x,y,w,h); run("Paste"); wait(100); } isok=!getBoolean("x:"+x+" y:"+y+" sound ok?"); } } close(); //offset=maxxy; //if(maxxy==y) bottom=true; //else bottom=false; setPasteMode(pmode); selectWindow(left); getDimensions(widl, heil, chl, slicesl, fr); if(chl>1) comp=true; Stack.getPosition(channel, sll, frame); bits=bitDepth(); mingo=newArray(chl); maxgo=newArray(chl); getMinAndMax(mingo[0],maxgo[0]); if(comp) { colors=newArray(chl); for(k=0;k0 && nowsl<=slicesl) go=true; wid=widl; hei=heil; stx=0; sty=0; } else { selectWindow(right); nowsl=(i+(slr-starter)); if(nowsl>0 && nowsl<=slicesr) go=true; wid=widr; hei=heir; //if(bottom) {stx=0; sty=offset;} //else {stx=offset; sty=0;} stx=x; sty=y; } if(go){ Stack.setPosition((k+1), nowsl, 1); run("Select All"); run("Copy"); selectWindow(left+"-AJCombine"); Stack.setPosition((k+1), (i+1+begfac), 1); makeRectangle(stx,sty,wid,hei); run("Paste"); } } } } selectWindow(left); Stack.setSlice(sll); selectWindow(right); Stack.setSlice(slr); selectWindow(left+"-AJCombine"); run("Select None"); for(k=0;k