Hello,
I tried to use a macro (that worked if the image was open- a multi tiff Z-stack) in BatchMode and could not prevent coming in trouble. I wish to extract the two channels out of a Z-stack for doing some procedures with them (just for testing if it works I tried to save them separatly; and this doesn´t work). Actually I would like to have two distinct images (in this code called A_zproject_name and B_zproject_name): dir1 = getDirectory("Choose Source Directory "); dir2 = getDirectory("Choose Destination Directory "); list = getFileList(dir1); setBatchMode(true); for (i=0; i<list.length; i++) { showProgress(i+1, list.length); open(dir1+list[i]); Aid = getImageID(); run("Z Project...", "start=1 stop=6 projection=[Max Intensity]"); setAutoThreshold(); //run("Threshold..."); run("Convert to Mask"); A_zproject_name = getTitle(); saveAs("tiff", dir2+A_zproject_name); //This is the image of channel 1 //restore selection to the first image selectImage(Aid); //make second projection run("Z Project...", "start=7 stop=12 projection=[Max Intensity]"); run("Subtract...", "value=500"); setAutoThreshold(); //run("Threshold..."); run("Convert to Mask"); B_zproject_name = getTitle(); saveAs("tiff", dir2+B_zproject_name); //This is the image of channel 2 close(); } So I would like to have two distinct images which I wish to address for further processing. How does this work? Thanks Johannes |
Hello Johannes,
Your current macro is not giving each z-projection an individual name, therefore the first z-projection is being overwritten by the second. I modified your code below to assign the names A_zproject_name and B_zproject_name to variables t1 and t2. I'm not clear on exactly how your stack files are saved, or if there are multiple stacks in a folder, but this should do the trick if there is only one stack per folder: dir1 = getDirectory("Choose Source Directory "); dir2 = getDirectory("Choose Destination Directory "); list = getFileList(dir1); setBatchMode(true); for (i=0; i<list.length; i++) { showProgress(i+1, list.length); open(dir1+list[i]); Aid = getImageID(); run("Z Project...", "start=1 stop=6 projection=[Max Intensity]"); setAutoThreshold(); //run("Threshold..."); run("Convert to Mask"); t1=dir2+"A_zproject_name"; saveAs("tiff", t1); //This is the image of channel 1 //restore selection to the first image selectImage(Aid); //make second projection run("Z Project...", "start=7 stop=12 projection=[Max Intensity]"); run("Subtract...", "value=500"); setAutoThreshold(); //run("Threshold..."); run("Convert to Mask"); t2=dir2+"B_zproject_name"; saveAs("tiff", t2); //This is the image of channel 2 close(); } Best, Christine ---- Original message ---- >Date: Mon, 28 Jul 2008 19:33:57 +0200 >From: Johannes Breu <[hidden email]> >Subject: Image is overwritten in batchmode >To: [hidden email] > >Hello, > >I tried to use a macro (that worked if the image was open- a multi tiff >Z-stack) in BatchMode and could not prevent coming in trouble. >I wish to extract the two channels out of a Z-stack for doing some >procedures with them (just for testing if it works I tried to save them >separatly; and this doesn´t work). >Actually I would like to have two distinct images (in this code called >A_zproject_name and B_zproject_name): > > > dir1 = getDirectory("Choose Source Directory "); > dir2 = getDirectory("Choose Destination Directory "); > list = getFileList(dir1); > setBatchMode(true); > for (i=0; i<list.length; i++) { > showProgress(i+1, list.length); > open(dir1+list[i]); > > Aid = getImageID(); > run("Z Project...", "start=1 stop=6 projection=[Max > setAutoThreshold(); > //run("Threshold..."); > run("Convert to Mask"); > A_zproject_name = getTitle(); > saveAs("tiff", dir2+A_zproject_name); > > > //This is the image of channel 1 > > //restore selection to the first image > selectImage(Aid); > > //make second projection > run("Z Project...", "start=7 stop=12 > run("Subtract...", "value=500"); > setAutoThreshold(); > //run("Threshold..."); > run("Convert to Mask"); > B_zproject_name = getTitle(); > saveAs("tiff", dir2+B_zproject_name); > //This is the image of channel 2 > > > close(); > } > >So I would like to have two distinct images which I wish to >further processing. How does this work? >Thanks >Johannes Christine Labno, Ph.D. Asst. Technical Director Light Microscopy Core University of Chicago Office of Shared Research Facilities Abbott 129 (773) 834-9040 (phone) |
Free forum by Nabble | Edit this page |