Login  Register

calculating DF/F and movement correction

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

calculating DF/F and movement correction

Nicolás Pírez
Dear List,



I am new at using ImageJ. I am using it to measure the changes in
fluorescence in a stack (time lapse). I have been using the ROIManager and
Multimeassure to obtain the fluorescence levels.

I have two questions: is there a function to calculate the DF/F
automatically? – eg: [(Fn/F0)/F0]X100%.



Additionally, I would like to be able to measure this value even in where
is some drift in the ROI across different slices in the stack (all images
are of the same field, but there is some movement X-Y). Is there a movement
correct function, so that the ROI can “follow” the movement?



Thanks a lot,


Nicolás Pírez.

--
Nicolás Pírez, Ph.D.
[hidden email]

Fundación Instituto Leloir, Lab. 109.
Av. Patricias Argentinas 435
Ciudad de Buenos Aires (C1405BWE)
Argentina
Phone +54 (11) 5238-7500 ext: 2109
Fax +54 (11) 5238-7501

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

Re: calculating DF/F and movement correction

Jacob Keller
If you get an answer for the movement correction question, I would love to
hear it--I have been trying to do this for some time. You can try StackReg,
but for me, since it works by a "moving window" approach to image
alignment, errors seem to accumulate and the sample moves slowly over
hundreds of images. If there were some way to align each image to a "master
image" that would be much better for our purposes.

Jacob


On Fri, Aug 10, 2012 at 9:28 AM, Nicolás Pírez <[hidden email]>wrote:

> Dear List,
>
>
>
> I am new at using ImageJ. I am using it to measure the changes in
> fluorescence in a stack (time lapse). I have been using the ROIManager and
> Multimeassure to obtain the fluorescence levels.
>
> I have two questions: is there a function to calculate the DF/F
> automatically? – eg: [(Fn/F0)/F0]X100%.
>
>
>
> Additionally, I would like to be able to measure this value even in where
> is some drift in the ROI across different slices in the stack (all images
> are of the same field, but there is some movement X-Y). Is there a movement
> correct function, so that the ROI can “follow” the movement?
>
>
>
> Thanks a lot,
>
>
> Nicolás Pírez.
>
> --
> Nicolás Pírez, Ph.D.
> [hidden email]
>
> Fundación Instituto Leloir, Lab. 109.
> Av. Patricias Argentinas 435
> Ciudad de Buenos Aires (C1405BWE)
> Argentina
> Phone +54 (11) 5238-7500 ext: 2109
> Fax +54 (11) 5238-7501
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
*******************************************
Jacob Pearson Keller
Northwestern University
Medical Scientist Training Program
email: [hidden email]
*******************************************

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

Re: calculating DF/F and movement correction

Krs5
Did you have a look at the image stabilizer plugin (http://www.kangli.org/code/Image_Stabilizer.html)?

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Centre for Core Biotechnology Services
University of Leicester
http://www.le.ac.uk/biochem/microscopy/home.html



-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Jacob Keller
Sent: 10 August 2012 16:35
To: [hidden email]
Subject: Re: calculating DF/F and movement correction

If you get an answer for the movement correction question, I would love to
hear it--I have been trying to do this for some time. You can try StackReg,
but for me, since it works by a "moving window" approach to image
alignment, errors seem to accumulate and the sample moves slowly over
hundreds of images. If there were some way to align each image to a "master
image" that would be much better for our purposes.

Jacob


On Fri, Aug 10, 2012 at 9:28 AM, Nicolás Pírez <[hidden email]>wrote:

> Dear List,
>
>
>
> I am new at using ImageJ. I am using it to measure the changes in
> fluorescence in a stack (time lapse). I have been using the ROIManager and
> Multimeassure to obtain the fluorescence levels.
>
> I have two questions: is there a function to calculate the DF/F
> automatically? - eg: [(Fn/F0)/F0]X100%.
>
>
>
> Additionally, I would like to be able to measure this value even in where
> is some drift in the ROI across different slices in the stack (all images
> are of the same field, but there is some movement X-Y). Is there a movement
> correct function, so that the ROI can "follow" the movement?
>
>
>
> Thanks a lot,
>
>
> Nicolás Pírez.
>
> --
> Nicolás Pírez, Ph.D.
> [hidden email]
>
> Fundación Instituto Leloir, Lab. 109.
> Av. Patricias Argentinas 435
> Ciudad de Buenos Aires (C1405BWE)
> Argentina
> Phone +54 (11) 5238-7500 ext: 2109
> Fax +54 (11) 5238-7501
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
*******************************************
Jacob Pearson Keller
Northwestern University
Medical Scientist Training Program
email: [hidden email]
*******************************************

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

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

Re: calculating DF/F and movement correction

Jacob Keller
Yes! this is it! To make this plugin align all imags to a single image, one
just sets the "template update coefficient" to 1, and no adjustments are
made to the template. Excellent! Thanks Kees,

Jacob

On Fri, Aug 10, 2012 at 10:56 AM, Straatman, Kees R. (Dr.) <
[hidden email]> wrote:

> Did you have a look at the image stabilizer plugin (
> http://www.kangli.org/code/Image_Stabilizer.html)?
>
> Kees
>
>
> Dr Ir K.R. Straatman
> Senior Experimental Officer
> Centre for Core Biotechnology Services
> University of Leicester
> http://www.le.ac.uk/biochem/microscopy/home.html
>
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Jacob Keller
> Sent: 10 August 2012 16:35
> To: [hidden email]
> Subject: Re: calculating DF/F and movement correction
>
> If you get an answer for the movement correction question, I would love to
> hear it--I have been trying to do this for some time. You can try StackReg,
> but for me, since it works by a "moving window" approach to image
> alignment, errors seem to accumulate and the sample moves slowly over
> hundreds of images. If there were some way to align each image to a "master
> image" that would be much better for our purposes.
>
> Jacob
>
>
> On Fri, Aug 10, 2012 at 9:28 AM, Nicolás Pírez <[hidden email]
> >wrote:
>
> > Dear List,
> >
> >
> >
> > I am new at using ImageJ. I am using it to measure the changes in
> > fluorescence in a stack (time lapse). I have been using the ROIManager
> and
> > Multimeassure to obtain the fluorescence levels.
> >
> > I have two questions: is there a function to calculate the DF/F
> > automatically? - eg: [(Fn/F0)/F0]X100%.
> >
> >
> >
> > Additionally, I would like to be able to measure this value even in where
> > is some drift in the ROI across different slices in the stack (all images
> > are of the same field, but there is some movement X-Y). Is there a
> movement
> > correct function, so that the ROI can "follow" the movement?
> >
> >
> >
> > Thanks a lot,
> >
> >
> > Nicolás Pírez.
> >
> > --
> > Nicolás Pírez, Ph.D.
> > [hidden email]
> >
> > Fundación Instituto Leloir, Lab. 109.
> > Av. Patricias Argentinas 435
> > Ciudad de Buenos Aires (C1405BWE)
> > Argentina
> > Phone +54 (11) 5238-7500 ext: 2109
> > Fax +54 (11) 5238-7501
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
>
>
> --
> *******************************************
> Jacob Pearson Keller
> Northwestern University
> Medical Scientist Training Program
> email: [hidden email]
> *******************************************
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
*******************************************
Jacob Pearson Keller
Northwestern University
Medical Scientist Training Program
email: [hidden email]
*******************************************

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

find all locations of the same pixel value

周鑫
In reply to this post by Jacob Keller
Dear all,

I want to find in one image all the locations which have the same pixel value.

currently I wrote a function for that:

=======================================

ArrayList<int[]> locations = new ArrayList<int[]>();
  for (int x=0; x<iproc.getWidth(); x++)
  {
   for(int y=0; y<iproc.getHeight(); y++)
   {
    if (iproc.getPixel(x, y) == pixelValue)
    {
     locations.add(new int[]{x,y});
    }
   }
  }
  return locations;

=======================================

but I wonder if there is something more smart, or build-in functions that can do the job quicker.

This is for me a basic operation, which will be done again and again. There must be more intelligent ways.

Many thanks, Xin



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

Re: find all locations of the same pixel value

Michael Doube-3
Dear Xin,

Maybe the compiler optimizers are better now, but in my experience it is
faster to declare the loop test value as a final value and not call a
function each time:

final int width = iproc.getWidth();
for (int x = 0; x < width; x++){

[and so on]

This is a small change that might make a big difference because your
loop iterates very many times.

Best regards,

Michael

On 14/08/12 08:09, 周鑫 wrote:

> Dear all,
>
> I want to find in one image all the locations which have the same pixel value.
>
> currently I wrote a function for that:
>
> =======================================
>
> ArrayList<int[]> locations = new ArrayList<int[]>();
>   for (int x=0; x<iproc.getWidth(); x++)
>   {
>    for(int y=0; y<iproc.getHeight(); y++)
>    {
>     if (iproc.getPixel(x, y) == pixelValue)
>     {
>      locations.add(new int[]{x,y});
>     }
>    }
>   }
>   return locations;
>
> =======================================
>
> but I wonder if there is something more smart, or build-in functions that can do the job quicker.
>
> This is for me a basic operation, which will be done again and again. There must be more intelligent ways.
>
> Many thanks, Xin
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

Re: find all locations of the same pixel value

Michael Schmid
In reply to this post by 周鑫
Hi Xin,

if you have thousands of pixels of the same value, you will create thousands of new int[] objects.  The Garbage Collector will have a lot of work to find out whether each of them is still needed, and eventually to remove them.

If your image size is not too large, simply create two arrays, say, xPixel, and yPixel, each of them the same size as the number of pixels, and write into them as much data as you need.

int width = iproc.getWidth();
int height = iproc.getHeight();
int[] xPixel = new int[width*height];
int[] yPixel = new int[width*height];

int nEqual = 0; // number of pixels with a value equal to the given one.
for (int x=0; x<width; x++) {
  for(int y=0; y<height; y++) {
    if (iproc.getPixel(x, y) == pixelValue) {
      xPixel[nEqual] = x;
      yPixel[nEqual] = y;
      nEqual++;
    }
  }
}

If you don't need the sequence as in your program, it would be faster to reverse the x and y loops (y in the outer loop). This addresses the pixels in the same sequence as they are stored in memory.

As a return value, you may then create a new 2-dimensional array,
  int[][] locations = int[2][nEqual],
and use System.arraycopy to copy nEqual items from xPixel into locations[0]; same for yPixel to locations[1].


If your image is very large and you run out of memory, you have a a few options:
- use short instead of int for x & y (unless any image is larger than 32767 pixels in width or height)
- encode x & y in a single int; see the built-in MaximumFinder for how to do this (intEncodeXMask, intEncodeYMask and intEncodeShift) - this works also with width or height > 32767)
- if the expected number of pixels with the given value is low, use smaller xPixel, yPixel arrays.  If you run over the array size, create new arrays of larger size (e.g. twice the size), copy the contents, and discard the old arrays.  See xstack, ystack in ij.process.FloodFiller.java for an example.


Michael
________________________________________________________________
On Aug 14, 2012, at 08:09, 周鑫 wrote:

> Dear all,
>
> I want to find in one image all the locations which have the same pixel value.
>
> currently I wrote a function for that:
>
> =======================================
>
> ArrayList<int[]> locations = new ArrayList<int[]>();
>  for (int x=0; x<iproc.getWidth(); x++)
>  {
>   for(int y=0; y<iproc.getHeight(); y++)
>   {
>    if (iproc.getPixel(x, y) == pixelValue)
>    {
>     locations.add(new int[]{x,y});
>    }
>   }
>  }
>  return locations;
>
> =======================================
>
> but I wonder if there is something more smart, or build-in functions that can do the job quicker.
>
> This is for me a basic operation, which will be done again and again. There must be more intelligent ways.
>
> Many thanks, Xin
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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