Re: Macro-getOption Built-in function
Posted by
dpoburko on
Aug 04, 2009; 8:21pm
URL: http://imagej.273.s1.nabble.com/volume-measurement-and-memory-problems-tp3691572p3691580.html
Paola Lepanto wrote:
> Damon Poburko escribió:
>> Gabriel Landini wrote:
>>> On Monday 03 August 2009, Damon Poburko wrote:
>>>
>>>> If I understand your problem ,you simply need a way to run a
>>>> Z-projection, where the first and last image are somehow
>>>> dynamically set.
>>>>
>>>> Here is an example:
>>>>
>>>> //first slice
>>>> A = 0;
>>>> //nslices give you the number of slices, whereas the "slice
>>>> number/position will be numbered starting at zero
>>>> B = nslices()-1;
>>>>
>>>> run("Z Project...", "start="+ A +" stop=" + B + " projection=[Average
>>>> Intensity]");
>>>>
>>>
>>> I think that slices start at "1" and end at "nSlices".
>>>
>>> G.
>>>
>> Thanks for the correction Gabriel. I must have been a little off when
>> writing this.
>>
>> Cheers,
>> Damon
> Thank you, but I couldn´t make it work through the way you showed me:
> it makes a Z proyection from the whole stack. What I would like to do
> is to select in each image the range of slices to make the projection.
> So I tried to make this other macro that fails to recognize A as the
> number (a pop up says that it expects a numeric value for "Stop") I
> put in the dialog box. Am I using the correct functions?, perhaps you
> can help me:
>
> Dialog.create("Z projection stop");
> Dialog.addNumber("Stop:", 30);
> Dialog.show();
> A = Dialog.getNumber();
> run("Z Project...", "start=1 stop=+A+ projection=[Average Intensity]");
>
> Thank you again,
> Paola
Hi Paolo,
You are 98% there. This should do it.
run("Z Project...", "start=1 stop=" + A + " projection=[Average
Intensity]");
Notice the extra quotation marks. When you interrupt anything in
quotations to introduce a variable, be sure to add the extra quotations
on either side of the pluses so that you have discrete bits of STRING
flanking your + variable +.
For examples,
A = 10;
print("I would like " + A + " donuts.");
// this will print "I would like 10 donuts"
print("I would like + A + donuts.");
// this will print "I would like + A + donuts", which won't make sense
in terms of code.
Cheers,
Damon