Hello all,
I kindly request any help. I have a video that consists of 36438 frames. I would like to take the Z-projection median between frame 1 and frame 11, frame 2 and frame 12, frame 3 and frame 13, etc...so it is for every 10th frame. Then make a stack out of those images. I wrote the following macro: n=nSlices(); n=36438; for (i=1; i<=n; i++) { showProgress(i, n); setSlice(i); run("8-bit"); selectWindow("3t3-008.nd2 - C=0"); #file name is 3t3-008.nd2 - C=0 run("Z Project...", "start=i stop=i+10; projection=Median"); run("Images to Stack", "name=Stack title=[] use"); } waitForUser("Click OK to continue"); run("Close"); Now when I run this, all is well but it crashes at the Z-projection line and the error I get is Numeric value expected in run() function Dialog box title 'ZProjection" Key: "stop slice" Value or variable name "i+10" Why do I get this as an error? I created a loop and I need to take the Z-projection (median) for frames 1 to 11 the, 2 to 12, then 3 to 13 etc.., which is start=i and stop=i+10. Can anyone help me please? Thank you in advance |
On Tuesday 22 May 2012 20:17:47 you wrote:
> run("Z Project...", "start=i stop=i+10; projection=Median"); Maybe you need: run("Z Project...", "start="+i+" stop="+(i+10)+" projection=Median"); I haven't tested, so it might not be right. |
Thank you very much, it was that!
|
In reply to this post by octavius
Hi,
I think what you need is: run("Z Project...", "start=i stop=i + 10; projection=Median"); instead of: run("Z Project...", "start=i stop=i+10; projection=Median"); Note the spaces around the "+" Once I fixed that issue I got a couple of other errors, so . . . This modified version of your code works for me, except it closes the new stack once the user clicks OK. Try it with \\ in front of the last line if you don't want the new stack of projected images to close. ----begin--- n=nSlices(); n=36438; t=getTitle; run("8-bit"); for (i=1; i<=n; i++) { showProgress(i, n); selectWindow(t); setSlice(i); run("Z Project...", "start=i stop=i + 10; projection=Median"); print(i); } selectWindow(t); close(); run("Images to Stack", "name=Stack title=[] use"); waitForUser("Click OK to continue"); run("Close"); ---end--- Best of luck! Christine Labno, Ph.D. Asst. Technical Director Light Microscopy Core University of Chicago Office of Shared Research Facilities KCBD 1250 900 E. 57th St. (773) 834-9040 (phone) Please consider the environment before printing this email. ---- Original message ---- >Date: Tue, 22 May 2012 12:17:47 -0700 >From: ImageJ Interest Group <[hidden email]> (on behalf of octavius <[hidden email]>) >Subject: Z-projection (median) Macro help >To: <[hidden email]> > >Hello all, > >I kindly request any help. >I have a video that consists of 36438 frames. >I would like to take the Z-projection median between frame 1 and frame 11, >frame 2 and frame 12, frame 3 and frame 13, etc...so it is for every 10th >frame. Then make a stack out of those images. > >I wrote the following macro: > >n=nSlices(); >n=36438; > >for (i=1; i<=n; i++) >{ > showProgress(i, n); > setSlice(i); > run("8-bit"); > selectWindow("3t3-008.nd2 - C=0"); #file name is 3t3-008.nd2 - >C=0 > run("Z Project...", "start=i stop=i+10; projection=Median"); > run("Images to Stack", "name=Stack title=[] use"); >} > >waitForUser("Click OK to continue"); >run("Close"); > > > >Now when I run this, all is well but it crashes at the Z-projection line and >the error I get is > >Numeric value expected in run() function >Dialog box title 'ZProjection" >Key: "stop slice" >Value or variable name "i+10" > >Why do I get this as an error? I created a loop and I need to take the >Z-projection (median) for frames 1 to 11 the, 2 to 12, then 3 to 13 etc.., >which is start=i and stop=i+10. Can anyone help me please? > >Thank you in advance > >-- >View this message in context: http://imagej.1557.n6.nabble.com/Z-projection-median-Macro-help-tp4998344.html >Sent from the ImageJ mailing list archive at Nabble.com. |
In reply to this post by octavius
I think this macro that I wrote a few years ago does what you need except that it doesn't do anything to the last n images in the stack.
var projectiondepth = 15; // set to whatever you want the default to be //================================================================== macro "Projections of variable width"{ projtypes = newArray("Max Intensity", "Average Intensity", "Standard Deviation", "Min Intensity", "Median"); Dialog.create("Projections of variable width"); Dialog.addMessage("Each slice of the stack is replaced with a projection of the depth\ndefined."); Dialog.addChoice("Label", projtypes, "Max Intensity"); Dialog.addNumber("Slices to project: ", projectiondepth); Dialog.show(); projection = Dialog.getChoice(); projectiondepth = projection; zdepth = Dialog.getNumber(); projectStackVariableWidth(projection, zdepth); } // Projections of variable width //================================================================== function projectStackVariableWidth(projtype, zdepth) { setBatchMode(true); original = getImageID(); end = nSlices(); for (i=1;i<=(end-zdepth);i++){ stop = i + zdepth; run("Z Project...", "start="+i+" stop="+stop+" projection=["+projtype+"]"); run("Select All"); run("Copy"); run("Close"); selectImage(original); run("Set Slice...", "slice="+i); run("Paste"); } setBatchMode(false); run("Select None"); } // end projectStackVariableWidth() ________________________________________________________ Michael Cammer, Assistant Research Scientist Skirball Institute of Biomolecular Medicine Lab: (212) 263-3208 Cell: (914) 309-3270 -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of octavius Sent: Tuesday, May 22, 2012 3:18 PM To: [hidden email] Subject: Z-projection (median) Macro help Hello all, I kindly request any help. I have a video that consists of 36438 frames. I would like to take the Z-projection median between frame 1 and frame 11, frame 2 and frame 12, frame 3 and frame 13, etc...so it is for every 10th frame. Then make a stack out of those images. I wrote the following macro: n=nSlices(); n=36438; for (i=1; i<=n; i++) { showProgress(i, n); setSlice(i); run("8-bit"); selectWindow("3t3-008.nd2 - C=0"); #file name is 3t3-008.nd2 - C=0 run("Z Project...", "start=i stop=i+10; projection=Median"); run("Images to Stack", "name=Stack title=[] use"); } waitForUser("Click OK to continue"); run("Close"); Now when I run this, all is well but it crashes at the Z-projection line and the error I get is Numeric value expected in run() function Dialog box title 'ZProjection" Key: "stop slice" Value or variable name "i+10" Why do I get this as an error? I created a loop and I need to take the Z-projection (median) for frames 1 to 11 the, 2 to 12, then 3 to 13 etc.., which is start=i and stop=i+10. Can anyone help me please? Thank you in advance -- View this message in context: http://imagej.1557.n6.nabble.com/Z-projection-median-Macro-help-tp4998344.html Sent from the ImageJ mailing list archive at Nabble.com. |
In reply to this post by Christine Labno
Thank you all for your generous assistance.
Unfortunately with 36438 frames, the computer is not running it all! Is it safe to divide the data into parts say analyse the first 1000 etc...Considering Christine's modified code: n=nSlices(); n=1000; t=getTitle; run("8-bit"); for (i=1; i<=n; i++) { showProgress(i, n); selectWindow(t); setSlice(i); run("Z Project...", "start=i stop=i + 10; projection=Median"); print(i); } selectWindow(t); close(); run("Images to Stack", "name=Stack title=[] use"); waitForUser("Click OK to continue"); Then for the next part: n=nSlices(); n=2000; t=getTitle; run("8-bit"); for (i=1000; i<=n; i++) { showProgress(i, n); selectWindow(t); setSlice(i); run("Z Project...", "start=i stop=i + 10; projection=Median"); print(i); } selectWindow(t); close(); run("Images to Stack", "name=Stack title=[] use"); waitForUser("Click OK to continue"); run("Close"); etc.... Where n and i are changed? Is this accurate and safe to do? Thank you all in advance! |
On Wednesday 23 May 2012 15:17:14 octavius <[hidden email]> wrote:
> run("Z Project...", "start=i stop=i + 10; projection=Median"); The same mistakes again?... That line has 3 syntax errors, see my previous email to see what is wrong. G. |
Free forum by Nabble | Edit this page |