Creating multiple Arrays with for buckle

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating multiple Arrays with for buckle

William Nicolas
Hello everyone,

I am actually working on a macro for fluorescence intensity quantifier, and I would like my macro to create for each image a new Array with serial names. i.e I want to analyze two images, thus I want 2 arrays for saving the intensity levels named something like ArrayImage1, ArrayImage2. I was thinking of doing this with a for buckle but I don’t know how to increment the name of the Arrays.

Hope I am clear enough…. thanks in advance for the help :)

Regards

William
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Creating multiple Arrays with for buckle

Rasband, Wayne (NIH/NIMH) [E]
On Feb 15, 2015, at 3:34 PM, William Nicolas <[hidden email]> wrote:
>
> Hello everyone,
>
> I am actually working on a macro for fluorescence intensity quantifier, and I would like my macro to create for each image a new Array with serial names. i.e I want to analyze two images, thus I want 2 arrays for saving the intensity levels named something like ArrayImage1, ArrayImage2. I was thinking of doing this with a for buckle but I don’t know how to increment the name of the Arrays.

There isn’t a way to create multiple arrays named array1, array2, … arrayn, where n is a variable, but you can easily create a Results table with n columns. Here is an example:

  n = getTime()%10 + 1;
  run("Clear Results");
  for (i=1; i<=n; i++) {
     for (j=0; j<10; j++)
        setResult("Image"+i, j, random());
  }

-wayne








--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Creating multiple Arrays with for buckle

William Nicolas
In reply to this post by William Nicolas
Thanks a lot Wayne, I find your use of the getTime function interesting. I found another way around during the gap period between my question and your answer but I will keep in mind your code.

Thanks !

Regards,

William

> Le 16 févr. 2015 à 06:00, IMAGEJ automatic digest system <[hidden email]> a écrit :
>
> Date:    Mon, 16 Feb 2015 03:04:42 +0000
> From:    "Rasband, Wayne (NIH/NIMH) [E]" <[hidden email] <mailto:[hidden email]>>
> Subject: Re: Creating multiple Arrays with for buckle
>
> On Feb 15, 2015, at 3:34 PM, William Nicolas <[hidden email] <mailto:[hidden email]>> wrote:
>>
>> Hello everyone,
>>
>> I am actually working on a macro for fluorescence intensity quantifier, and I would like my macro to create for each image a new Array with serial names. i.e I want to analyze two images, thus I want 2 arrays for saving the intensity levels named something like ArrayImage1, ArrayImage2. I was thinking of doing this with a for buckle but I don’t know how to increment the name of the Arrays.
>
> There isn’t a way to create multiple arrays named array1, array2, … arrayn, where n is a variable, but you can easily create a Results table with n columns. Here is an example:
>
>  n = getTime()%10 + 1;
>  run("Clear Results");
>  for (i=1; i<=n; i++) {
>     for (j=0; j<10; j++)
>        setResult("Image"+i, j, random());
>  }
>
> -wayne


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