Hi, I'm fairly new to Image J so I apologise if this is a trivial question.
I'm using the plugin MicroManager to capture sequences from various positions on a multi-well tray repeatedly i.e. a looped command. Each time point is given a folder in which the images from each location are stored in subfolders (labelled with their position). Each position is imaging four wells from the multi-well trays and I'm only interested in the very centre of each well. Therefore what I want to do is find a way of cropping each set of images (stack) into four separate images. In addition to this I'd also like to be able combine the images from the same location at different time points into a single stack .. I have been doing this using the concatenate function, however is there a way of doing this as a batch? Is there an easy way of doing this? I've found the batch process folder macro http://rsb.info.nih.gov/ij/macros/BatchProcessFolders.txt which seems ideal as it will enable me to run the command at a higher level than individual sub-folders, however I don't know how to incorporate cropping into this macro and, if this is the most feasible way of achieving this, labelling the separate images in a way that enables me to identify which well each stack of images corresponds to. Many thanks, Oli Tills |
Hi Oli,
I'm trying to automate the export of ROIs in a stack to new subfolders. I've been adapting the BatchProcess Function too and have got this far: sdir = getDirectory("choose source directory "); n = roiManager("count"); for (i=0; i<n; i++) { roiManager("select", i); bee = "bee_"+i+"_"; ddir = sdir+bee; File.makeDirectory(ddir); run("Duplicate...", "title = bee duplicate range=1-3000"); run("Image Sequence... ", "format=TIFF name=["+bee+"] start=0 digits=4 save=["+ddir+"]"); close(); } If you open your stack, select a few ROIs and then run this macro it will ask you what the parent folder is then generate a folder for each ROI (they're called "bee" because I'm processing videos of bees). It will also duplicate each ROI and save it as a separate stack. Unfortunately I can't get it to save the relevant ROI stacks in the right folder so it just dumps them in the parent at the moment. If I get it working properly I'll post back. Hope this helps, Chris -- View this message in context: http://n2.nabble.com/Cropping-several-parts-of-a-set-of-images-from-multiple-folders-tp4576230p4611905.html Sent from the ImageJ mailing list archive at Nabble.com. |
In reply to this post by otills
Hi Oli,
I'm trying to automate the export of ROIs in a stack to new subfolders. I've been adapting the BatchProcess Function too and have got this far: sdir = getDirectory("choose source directory "); n = roiManager("count"); for (i=0; i<n; i++) { roiManager("select", i); bee = "bee_"+i+"_"; ddir = sdir+bee; File.makeDirectory(ddir); run("Duplicate...", "title = bee duplicate range=1-3000"); run("Image Sequence... ", "format=TIFF name=["+bee+"] start=0 digits=4 save=["+ddir+"]"); close(); } If you open your stack, select a few ROIs and then run this macro it will ask you what the parent folder is then generate a folder for each ROI (they're called "bee" because I'm processing videos of bees). It will also duplicate each ROI and save it as a separate stack. Unfortunately I can't get it to save the relevant ROI stacks in the right folder so it just dumps them in the parent at the moment. If I get it working properly I'll post back. Hope this helps, Chris |
In reply to this post by Ninja Chris
Hi Chris, thanks for this reply.
I've made some progress on this myself also. The macro below allows me to create new stacks based on specified ROIs of images in subfolders within a specified folder (the ROI doesn't change within each subfolder (e.g. C3-D4 or C5-D6 in the macro below). I can therefore just copy and paste the macro whilst changing the "myFolder" variable). I've also included a labelling function to label each frame with; the frame number, which well of the multi-well plate I'm imaging (e.g. A or B.. myWell variable below), myPosition and myFolder. I had a lot of trouble getting the images to save in the desired sub-folder, however it's all working now.. the problems were varied including slashes in the wrong direction and spaces where there shouldn't be any (first attempt at macro writing). I might try having a play with some of your macro as it seems somewhat more streamlined than mine! myFolder="140210_1" myPosition="C3-D4" myWell="A" run("Image Sequence...", "open=[/Volumes/Macintosh HD 2/140210_continued//"+ myFolder +"//"+ myPosition +"//img0000000.tif]] number=300 starting=1 increment=1 scale=100 file=[] or=[] sort"); makeRectangle(389, 221, 430, 430); run("Duplicate...", "title=C3-1 duplicate range=1-300"); run("Label...", "starting=0 interval=1 x=5 y=20 font=25 text=A_"+ myPosition +"_"+ myFolder +""); run("Image Sequence... ", "format=TIFF name="+ myFolder +"_"+ myPosition +"_A_ start=0 digits=4 save=//Users//Oli//Crop//HD2_Crop//"+ myFolder +"//"+ myPosition +"//"+ myFolder +"_"+ myPosition +"_A_ start=0 digits=4]"); run("Close"); myWell="B" makeRectangle(1364, 227, 409, 409); run("Duplicate...", "title=C3-1 duplicate range=1-300"); run("Label...", "starting=0 interval=1 x=5 y=20 font=25 text=B_"+ myPosition +"_"+ myFolder +""); run("Image Sequence... ", "format=TIFF name="+ myFolder +"_"+ myPosition +"_B_ start=0 digits=4 save=//Users//Oli//Crop//HD2_Crop//"+ myFolder +"//"+ myPosition +"//"+ myFolder +"_"+ myPosition +"_B_ start=0 digits=4]"); run("Close"); // myPosition="C5-D6" myWell="A" run("Image Sequence...", "open=[/Volumes/Macintosh HD 2/140210_continued//"+ myFolder +"//"+ myPosition +"//img0000000.tif]] number=300 starting=1 increment=1 scale=100 file=[] or=[] sort"); makeRectangle(362, 266, 403, 403); run("Duplicate...", "title=C3-1 duplicate range=1-300"); run("Label...", "starting=0 interval=1 x=5 y=20 font=25 text=A_"+ myPosition +"_"+ myFolder +""); run("Image Sequence... ", "format=TIFF name="+ myFolder +"_"+ myPosition +"_A_ start=0 digits=4 save=//Users//Oli//Crop//HD2_Crop//"+ myFolder +"//"+ myPosition +"//"+ myFolder +"_"+ myPosition +"_A_ start=0 digits=4]"); run("Close"); myWell="B" makeRectangle(1308, 240, 537, 537); run("Duplicate...", "title=C3-1 duplicate range=1-300"); run("Label...", "starting=0 interval=1 x=5 y=20 font=25 text=B_"+ myPosition +"_"+ myFolder +""); run("Image Sequence... ", "format=TIFF name="+ myFolder +"_"+ myPosition +"_B_ start=0 digits=4 save=//Users//Oli//Crop//HD2_Crop//"+ myFolder +"//"+ myPosition +"//"+ myFolder +"_"+ myPosition +"_B_ start=0 digits=4]"); run("Close"); // Cheers, Oli -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Ninja Chris Sent: 22 February 2010 13:12 To: [hidden email] Subject: Re: Cropping several parts of a set of images from multiple folders Hi Oli, I'm trying to automate the export of ROIs in a stack to new subfolders. I've been adapting the BatchProcess Function too and have got this far: sdir = getDirectory("choose source directory "); n = roiManager("count"); for (i=0; i<n; i++) { roiManager("select", i); bee = "bee_"+i+"_"; ddir = sdir+bee; File.makeDirectory(ddir); run("Duplicate...", "title = bee duplicate range=1-3000"); run("Image Sequence... ", "format=TIFF name=["+bee+"] start=0 digits=4 save=["+ddir+"]"); close(); } If you open your stack, select a few ROIs and then run this macro it will ask you what the parent folder is then generate a folder for each ROI (they're called "bee" because I'm processing videos of bees). It will also duplicate each ROI and save it as a separate stack. Unfortunately I can't get it to save the relevant ROI stacks in the right folder so it just dumps them in the parent at the moment. If I get it working properly I'll post back. Hope this helps, Chris -- View this message in context: http://n2.nabble.com/Cropping-several-parts-of-a-set-of-images-from-multiple-folders-tp4576230p4611905.html Sent from the ImageJ mailing list archive at Nabble.com. |
Oli,
Michael Schmid-3 has kindly helped me with my code and it now dumps the duplicated ROI stacks into their newly created folders. macro "ROI Export [r]" { sdir = getDirectory("choose source directory "); n = roiManager("count"); for (i=0; i<n; i++) { bee = "bee_"+i + File.separator; ddir = sdir+bee; File.makeDirectory(ddir); roiManager("select", i); run("Duplicate...", "title = bee duplicate range=1-3000"); run("Image Sequence... ", "format=TIFF name=["+bee+"] start=0 digits=4 save=["+ddir+"]"); close(); } } Glad to be of help! Chris |
In reply to this post by otills
Hello,
I am trying to determine if IMAGEJ is the right application to perform skin lesion analysis primarily comparing to database of similar images (lacerations, rashes, etc) and for trending (showing improvement as a lesion heals) Appreciate any input and interest from interested developers. Thanks Neal Sikka [hidden email] ________________________________ From: Oliver Tills <[hidden email]> To: [hidden email] Sent: Mon, February 22, 2010 11:13:41 AM Subject: Re: Cropping several parts of a set of images from multiple folders Hi Chris, thanks for this reply. I've made some progress on this myself also. The macro below allows me to create new stacks based on specified ROIs of images in subfolders within a specified folder (the ROI doesn't change within each subfolder (e.g. C3-D4 or C5-D6 in the macro below). I can therefore just copy and paste the macro whilst changing the "myFolder" variable). I've also included a labelling function to label each frame with; the frame number, which well of the multi-well plate I'm imaging (e.g. A or B.. myWell variable below), myPosition and myFolder. I had a lot of trouble getting the images to save in the desired sub-folder, however it's all working now.. the problems were varied including slashes in the wrong direction and spaces where there shouldn't be any (first attempt at macro writing). I might try having a play with some of your macro as it seems somewhat more streamlined than mine! myFolder="140210_1" myPosition="C3-D4" myWell="A" run("Image Sequence...", "open=[/Volumes/Macintosh HD 2/140210_continued//"+ myFolder +"//"+ myPosition +"//img0000000.tif]] number=300 starting=1 increment=1 scale=100 file=[] or=[] sort"); makeRectangle(389, 221, 430, 430); run("Duplicate...", "title=C3-1 duplicate range=1-300"); run("Label...", "starting=0 interval=1 x=5 y=20 font=25 text=A_"+ myPosition +"_"+ myFolder +""); run("Image Sequence... ", "format=TIFF name="+ myFolder +"_"+ myPosition +"_A_ start=0 digits=4 save=//Users//Oli//Crop//HD2_Crop//"+ myFolder +"//"+ myPosition +"//"+ myFolder +"_"+ myPosition +"_A_ start=0 digits=4]"); run("Close"); myWell="B" makeRectangle(1364, 227, 409, 409); run("Duplicate...", "title=C3-1 duplicate range=1-300"); run("Label...", "starting=0 interval=1 x=5 y=20 font=25 text=B_"+ myPosition +"_"+ myFolder +""); run("Image Sequence... ", "format=TIFF name="+ myFolder +"_"+ myPosition +"_B_ start=0 digits=4 save=//Users//Oli//Crop//HD2_Crop//"+ myFolder +"//"+ myPosition +"//"+ myFolder +"_"+ myPosition +"_B_ start=0 digits=4]"); run("Close"); // myPosition="C5-D6" myWell="A" run("Image Sequence...", "open=[/Volumes/Macintosh HD 2/140210_continued//"+ myFolder +"//"+ myPosition +"//img0000000.tif]] number=300 starting=1 increment=1 scale=100 file=[] or=[] sort"); makeRectangle(362, 266, 403, 403); run("Duplicate...", "title=C3-1 duplicate range=1-300"); run("Label...", "starting=0 interval=1 x=5 y=20 font=25 text=A_"+ myPosition +"_"+ myFolder +""); run("Image Sequence... ", "format=TIFF name="+ myFolder +"_"+ myPosition +"_A_ start=0 digits=4 save=//Users//Oli//Crop//HD2_Crop//"+ myFolder +"//"+ myPosition +"//"+ myFolder +"_"+ myPosition +"_A_ start=0 digits=4]"); run("Close"); myWell="B" makeRectangle(1308, 240, 537, 537); run("Duplicate...", "title=C3-1 duplicate range=1-300"); run("Label...", "starting=0 interval=1 x=5 y=20 font=25 text=B_"+ myPosition +"_"+ myFolder +""); run("Image Sequence... ", "format=TIFF name="+ myFolder +"_"+ myPosition +"_B_ start=0 digits=4 save=//Users//Oli//Crop//HD2_Crop//"+ myFolder +"//"+ myPosition +"//"+ myFolder +"_"+ myPosition +"_B_ start=0 digits=4]"); run("Close"); // Cheers, Oli -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Ninja Chris Sent: 22 February 2010 13:12 To: [hidden email] Subject: Re: Cropping several parts of a set of images from multiple folders Hi Oli, I'm trying to automate the export of ROIs in a stack to new subfolders. I've been adapting the BatchProcess Function too and have got this far: sdir = getDirectory("choose source directory "); n = roiManager("count"); for (i=0; i<n; i++) { roiManager("select", i); bee = "bee_"+i+"_"; ddir = sdir+bee; File.makeDirectory(ddir); run("Duplicate...", "title = bee duplicate range=1-3000"); run("Image Sequence... ", "format=TIFF name=["+bee+"] start=0 digits=4 save=["+ddir+"]"); close(); } If you open your stack, select a few ROIs and then run this macro it will ask you what the parent folder is then generate a folder for each ROI (they're called "bee" because I'm processing videos of bees). It will also duplicate each ROI and save it as a separate stack. Unfortunately I can't get it to save the relevant ROI stacks in the right folder so it just dumps them in the parent at the moment. If I get it working properly I'll post back. Hope this helps, Chris -- View this message in context: http://n2.nabble.com/Cropping-several-parts-of-a-set-of-images-from-multiple-folders-tp4576230p4611905.html Sent from the ImageJ mailing list archive at Nabble.com. |
Free forum by Nabble | Edit this page |