Intensity correction using value from .txt file

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

Intensity correction using value from .txt file

jforien
Dear all,

I have a stack of 121 images and a text file of 121 values on individual line. Value of the first line correspond to the first slice, value of the second line corrrespond to the second slice and so on.

I would like to multiply each slices of the stack with their respective values contained in the .txt file.

Does anyone know a method to do it in ImageJ?

Thanks in advance

Jean-Baptiste
Reply | Threaded
Open this post in threaded view
|

Re: Intensity correction using value from .txt file

Rasband, Wayne (NIH/NIMH) [E]
On Nov 2, 2012, at 6:40 AM, jforien wrote:

> Dear all,
>
> I have a stack of 121 images and a text file of 121 values on individual
> line. Value of the first line correspond to the first slice, value of the
> second line corrrespond to the second slice and so on.
>
> I would like to multiply each slices of the stack with their respective
> values contained in the .txt file.
>
> Does anyone know a method to do it in ImageJ?

Here is a macro that does this:

  path = getDirectory("home") + "values.txt";
  values = split(File.openAsString(path), "\n");
  n = values.length;
  if (n!=nSlices)
     exit("Number of values != stack size");
  for (i=0; i<n; i++) {
     setSlice(i+1);
     run("Multiply...", "value="+values[i]+" slice");
  }

-wayne

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

Re: Intensity correction using value from .txt file

jforien
Thank you very much!

JB