I am very new to ImageJ so I am really sorry if this is common knowledge that
I am not aware of but basically I have a hyperstack that I unstack to images. I want to close certain images because I only need 4 out of 12 images from the hyperstack. I run this macro (below) and it works fine for one image but if I try to run it on another, it doesn't let me. run ("Stack to Images"); run ("Tile"); selectWindow("c:1/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:2/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:3/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:5/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:5/6 t:2/2 - TS2_546_1 #1"); close(); selectWindow("c:3/6 t:2/2 - TS2_546_1 #1"); close(); selectWindow("c:2/6 t:2/2 - TS2_546_1 #1"); close(); selectWindow("c:1/6 t:2/2 - TS2_546_1 #1"); close(); From what I understand is that the hyperstack ''TS2_546_1'' needs to be changed to ''TS2_546_2'' and so on but I am not sure how to go about with that. I am not looking to save these images because I have to run a plugin to evaluate FRET. -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Assuming that the name of your image is TS2_546_1 #1 you can try:
title = getTitle(); run ("Stack to Images"); run ("Tile"); selectWindow("c:1/6 t:1/2 - "+title); close(); selectWindow("c:2/6 t:1/2 - "+title); close(); etc Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester www.le.ac.uk/advanced-imaging-facility -----Original Message----- From: scoopwarr <[hidden email]> Sent: 16 January 2019 12:08 To: [hidden email] Subject: Need help with running a macro with hyperstacks in a folder. I am very new to ImageJ so I am really sorry if this is common knowledge that I am not aware of but basically I have a hyperstack that I unstack to images. I want to close certain images because I only need 4 out of 12 images from the hyperstack. I run this macro (below) and it works fine for one image but if I try to run it on another, it doesn't let me. run ("Stack to Images"); run ("Tile"); selectWindow("c:1/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:2/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:3/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:5/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:5/6 t:2/2 - TS2_546_1 #1"); close(); selectWindow("c:3/6 t:2/2 - TS2_546_1 #1"); close(); selectWindow("c:2/6 t:2/2 - TS2_546_1 #1"); close(); selectWindow("c:1/6 t:2/2 - TS2_546_1 #1"); close(); From what I understand is that the hyperstack ''TS2_546_1'' needs to be changed to ''TS2_546_2'' and so on but I am not sure how to go about with that. I am not looking to save these images because I have to run a plugin to evaluate FRET. -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hello,
Thank you for replying to my post. I have tried what you suggested. The Stack to Image worked fine but I am getting this error that I have attached a picture of. <http://imagej.1557.x6.nabble.com/file/t382210/Error.jpg> -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear Faizul,
I'm not really sure whether I understand exactly what you are trying to do. Nevertheless, your error: means that there is no window with the title "c:1/6 t...." open and thus the instruction selectWindow on this window throws in an error. Also are you aware that you can apply the method close with different patterns? Thus maybe can you use something like: close("\\Others"); My best regards, Philippe Philippe CARL Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie 74 route du Rhin 67401 ILLKIRCH Tel : +33(0)3 68 85 41 84 -----Message d'origine----- De : ImageJ Interest Group [mailto:[hidden email]] De la part de Faizul Envoyé : mercredi 16 janvier 2019 14:05 À : [hidden email] Objet : Re: Need help with running a macro with hyperstacks in a folder. Hello, Thank you for replying to my post. I have tried what you suggested. The Stack to Image worked fine but I am getting this error that I have attached a picture of. <http://imagej.1557.x6.nabble.com/file/t382210/Error.jpg> -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Faizul
What are the names of your images after you have created the images?
Kees -----Original Message----- From: Faizul <[hidden email]> Sent: 16 January 2019 13:05 To: [hidden email] Subject: Re: Need help with running a macro with hyperstacks in a folder. Hello, Thank you for replying to my post. I have tried what you suggested. The Stack to Image worked fine but I am getting this error that I have attached a picture of. <http://imagej.1557.x6.nabble.com/file/t382210/Error.jpg> -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Krs5
Which four images do you need? If they are sequential slices-channels-frames, then duplicating the range and closing the original stack or Image > Stacks > Tools > Make Substack... might be a lot faster.
If you are pulling out arbitrary frames, here is something that one of our lightsheet users finds effective: /* ver100 20160316 for ImageJ 1.50i This macro works on any stack but was designed for hyperstacks with T, Z, C. It is for extracting individual Z positions from one channel at each timepoint manually because of unpredictable shifts in Z. It could be modified to extract multiple channels. Also, if there were shifts in XY, after running the macro, before cropping, user may want to execute one of the automatic registration routines. Step 1. Open a hyperstack. Step 2. Run "Setup new extraction" Step 3. For each frame to be added to the new stack/movie, select it (make sure on correct channel) and press "q". If you added an incorrect frame, simply delete it using Image > Stacks > Delete Slice. Step 4. When done, run macro "Delete the last slice when done" Step 5. Save. Optional Step 6. Image > Stacks > Label... to put times on movie. */ var newStackID = 0; //============================================== macro "Setup new extraction" { b = bitDepth(); width = getWidth(); height = getHeight(); newImage("newStack", "" + b +" -bit ramp", width, height, 1); newStackID = getImageID(); setPasteMode("Copy"); } //============================================== // At the end, manually delete the last slice macro "Pop Current Frame Onto Stack [q]" { run("Select All"); run("Copy"); selectImage(newStackID); run("Add Slice"); setSlice(nSlices()-1); run("Paste"); } //============================================== macro "Delete the last slice when done" { setSlice(nSlices()); run("Delete Slice"); } -----Original Message----- From: Straatman, Kees (Dr.) <[hidden email]> Sent: Wednesday, January 16, 2019 7:34 AM To: [hidden email] Subject: Re: Need help with running a macro with hyperstacks in a folder. Assuming that the name of your image is TS2_546_1 #1 you can try: title = getTitle(); run ("Stack to Images"); run ("Tile"); selectWindow("c:1/6 t:1/2 - "+title); close(); selectWindow("c:2/6 t:1/2 - "+title); close(); etc Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester www.le.ac.uk/advanced-imaging-facility -----Original Message----- From: scoopwarr <[hidden email]> Sent: 16 January 2019 12:08 To: [hidden email] Subject: Need help with running a macro with hyperstacks in a folder. I am very new to ImageJ so I am really sorry if this is common knowledge that I am not aware of but basically I have a hyperstack that I unstack to images. I want to close certain images because I only need 4 out of 12 images from the hyperstack. I run this macro (below) and it works fine for one image but if I try to run it on another, it doesn't let me. run ("Stack to Images"); run ("Tile"); selectWindow("c:1/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:2/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:3/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:5/6 t:1/2 - TS2_546_1 #1"); close(); selectWindow("c:5/6 t:2/2 - TS2_546_1 #1"); close(); selectWindow("c:3/6 t:2/2 - TS2_546_1 #1"); close(); selectWindow("c:2/6 t:2/2 - TS2_546_1 #1"); close(); selectWindow("c:1/6 t:2/2 - TS2_546_1 #1"); close(); From what I understand is that the hyperstack ''TS2_546_1'' needs to be changed to ''TS2_546_2'' and so on but I am not sure how to go about with that. I am not looking to save these images because I have to run a plugin to evaluate FRET. -- Sent from: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.1557.x6.nabble.com_&d=DwIFAg&c=j5oPpO0eBH1iio48DtsedeElZfc04rx3ExJHeIIZuCs&r=hUBj2D5n6oKThx2L01qn8IORZb5f-ruLVXPmQ1zQNnM&m=0sAk0025upirCGdyAsloNEieneYijTcABKK8gm7UB5E&s=cAFP1V0HY7hYc--NycJ6qTOwKwhjhbqlwFZQNK2P84o&e= -- ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DwIFAg&c=j5oPpO0eBH1iio48DtsedeElZfc04rx3ExJHeIIZuCs&r=hUBj2D5n6oKThx2L01qn8IORZb5f-ruLVXPmQ1zQNnM&m=0sAk0025upirCGdyAsloNEieneYijTcABKK8gm7UB5E&s=zJt-IKCI4WH9WjfsAjdiOmVr4O1Zqkn-dCXqofnfUAQ&e= -- ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DwIFAg&c=j5oPpO0eBH1iio48DtsedeElZfc04rx3ExJHeIIZuCs&r=hUBj2D5n6oKThx2L01qn8IORZb5f-ruLVXPmQ1zQNnM&m=0sAk0025upirCGdyAsloNEieneYijTcABKK8gm7UB5E&s=zJt-IKCI4WH9WjfsAjdiOmVr4O1Zqkn-dCXqofnfUAQ&e= ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Krs5
When I do Stack to Images for the hyperstack file ''TS2_546_1,'' I get images
''c:1/6 t:1/2 - TS2_546_1 #1'...to image ''c:6/6 t:2/2 - TS2_546_1 #1.'' What I basically wanna do is leave the images c:4/6 t:1/2 - TS2_546_1 #1, c:6/6 t:1/2 - TS2_546_1 #1, c:4/6 t:2/2 - TS2_546_1 #1, and c:6/6 t:2/2 - TS2_546_1 #1 open and close the rest of the images but for all my hyperstacks; TS2_546_2, TS2_546_3, TS2_546_4, and TS2_546_5. I hope this makes sense. -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Cammer, Michael-2
Thank you so much! This is exactly what I needed. The macro works now!
-- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |