Hello everyone, I have a problem that I am hoping someone can help me work out. I am trying to figure out how to use a set Image Calculator function across multiple sets of images without manually doing it each time. Each image set contains a picture of DAPI stained nuclei and an image of cytoplasm stained cells. I am subtracting the images of the DAPI stain from the images of the cells create objects with the total area of the cell minus the nuclei. Right now I am going through and performing this function with each individual set and was wondering if there is a way to set up a Macro to automate this to be done with multiple sets all at once. Any help would be greatly appreciated. Thanks!
|
Hi,
You could write a macro to do what you want. The actual macro function to do the image subtraction is imageCalculator("Subtract create", "image1", "image2"); Below is a section of a macro that I used for some similar purposes. It basically checks for any open images, decides whether an image is of a certain type depending on whether the image name contains a certain identifier string (I have set them to "cyto" and "DAPI"), then displays a dialog box that allows you to select the images and finally does the subtraction. This is probably not quite what you want as you still have to do some manual selection, but it could easily be altered to automatically read filenames from a directory and does what you want to do. If you want to try the code below, just open a new macro window, copy the text below and run the macro (ctrl+R). Hope this is of any use. Volko //Define arrays to hold image names titlesCyto=newArray(100); titlesDAPI=newArray(100); titlesOther=newArray(100); //Define counting variables for different image types cyto=-1;dapi=-1;other=-1; //Some code to identify types of open images based on their names if (nImages==0) //Check if any images are open print("No images are open"); else { setBatchMode(true); for (i=1; i<=nImages; i++) { //Add open images to arrays depending on identifier contained in image name selectImage(i); //Alternatively you could write some code to automatically read file names from a directory and open appropriate files name=getTitle(); if(indexOf(name,"cyto",0)>0){ //Indentifier for cytoplasm images is "cyto" - change "cyto" to appropriate indentifier cyto=cyto+1; titlesCyto[cyto]=name; }else{ if(indexOf(name,"DAPI",0)>0){ //Indentifier for DAPI images is "cyto" - change "DAPI" to appropriate indentifier dapi=dapi+1; titlesDAPI[dapi]=name; }else{ other=other+1; titlesOther[other]=name; }; }; }; setBatchMode(false); }; //Reduce size of image arrays to actual number of images in each array //If there are no image names in either the DAPI or cytoplasm array, these arrays are replaced with the array containing image //names that could not be assigned titlesOther=Array.trim(titlesOther,other+1); if(cyto==-1){titlesCyto=Array.copy(titlesOther);}else{titlesCyto=Array.trim(titlesCyto,cyto+1);}; if(dapi==-1){titlesDAPI=Array.copy(titlesOther);}else{titlesDAPI=Array.trim(titlesDAPI,dapi+1);}; //Create a dialog to select the images that you want to use in your calculation Dialog.create("Select Images"); Dialog.addChoice("Cytoplasm", titlesCyto); //Create choice lists filled with image titles Dialog.addChoice("DAPI", titlesDAPI); //in titlesCyto and titlesDAPI arrays Dialog.show; imageCyto=Dialog.getChoice(); //Get names of selected images imageDAPI=Dialog.getChoice(); //Do the actual image subtraction imageCalculator("Subtract create", imageCyto,imageDAPI); On 31/03/2014 21:18, mfloyd78 wrote: > Hello everyone, I have a problem that I am hoping someone can help me work > out. I am trying to figure out how to use a set Image Calculator function > across multiple sets of images without manually doing it each time. Each > image set contains a picture of DAPI stained nuclei and an image of > cytoplasm stained cells. I am subtracting the images of the DAPI stain from > the images of the cells create objects with the total area of the cell minus > the nuclei. Right now I am going through and performing this function with > each individual set and was wondering if there is a way to set up a Macro to > automate this to be done with multiple sets all at once. Any help would be > greatly appreciated. Thanks! > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/Image-Calculator-across-many-image-sets-tp5007157.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dr. Straub,
Thank you for your response. This sounds like what I am wanting to do, however when I copy and paste that macro I get the error "undefined variable in line 15 <depending> on identifier contained in image name. I have changed all my image names to either "DAPI#" or "cyto#" to correlate with you identifiers but still can not get it to work. Any suggestions? |
Free forum by Nabble | Edit this page |