Login  Register

Re: Problem with Maximum intensity projection

Posted by vischer on Mar 23, 2018; 8:53pm
URL: http://imagej.273.s1.nabble.com/Problem-with-Maximum-intensity-projection-tp5020309p5020329.html

Hi Gabriel,

Herbie already gave a link to the documentation:
> <https://imagej.nih.gov/ij/macros/examples/MathMacroDemo.txt>


I simply used the macro recorder and chose:
        Process>Math>Macro...
and forgot to explain.


My demo version runs quick enough for the example. But a faster version is shown below, where the per-pixel macro code is only used for a single slice (the projection):

---

random("seed", 0);
newImage("Demo", "8-bit random", 20, 20, 10);
run("Scale...", "x=30 y=30 interpolation=None average create process");
//demo image: in top left square, max intensity is 190 and occurs in slice#9 (1-based)

//Create a projection of maximum positions
run("32-bit"); //stack holding integers, <100 slices
for(slc = 1; slc <= nSlices; slc++){
        setSlice(slc);
        run("Add...", "slice value=" + (slc/100) );
}
run("Z Project...", "projection=[Max Intensity]");
run("Macro...", "code=[round(v%1 * 100)]");
rename("Max_Positions");
run("Fire");


---
best regards, Norbert

>
> On 23. Mar 2018, at 16:06, Gabriel Landini <[hidden email]> wrote:
>
> On Friday, 23 March 2018 09:26:08 GMT [hidden email] wrote:
>> The macro below works if your stack contains integers.
>> It adds the slice information as fractional part.
>
> Wow, Norbert, that is very clever.
> Can you please explain syntax of the line:
> run("Macro...", "code=v+0.001*z stack");
>
> I suppose that v is the intensity and z the slice. What is "code", the result?
> Is this documented anywhere?
>
> Cheers
>
> Gabriel
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html