doFit functions problem

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

doFit functions problem

wolf indark
Dear ImageJ users

I try to perform a gaussian fit froma a macro I am writing. Data is 2D. When
the width of the gaussian curve is narrow, ImageJ doFit function does not
fit the data. I can fit the data to Gaussian curve by changing simlex
initial guesses.

However, from the macro code, even though I gaved the initialGues array for
the parameters a, b, c, d. But it doesnt change anything. From the simlex
parameter dialog box, when I change the initial parameters, it works.

what is the problem with the macro Fit functions ?
I will be pleased if you share your opinions.

best regards
Reply | Threaded
Open this post in threaded view
|

Re: doFit functions problem

Nathaniel Ryckman
It's really hard to tell anything from the information that you have given. If you give an example, we can figure out if your macro code is incorrect or the Java code behind imageJ is incorrect.

Make sure that your macro code looks something like this:

http://rsbweb.nih.gov/ij/macros/examples/RodbardSigmoidFit.txt

If you are interested in tracing exactly what happens when you run the Macro code vs running the imageJ code, you can always sift through the source code:

http://rsbweb.nih.gov/ij/download/src/

I personally recommend developing programs in Java. I think the macro code is still too buggy to be used to make a large program.

Good luck!
Reply | Threaded
Open this post in threaded view
|

Re: doFit functions problem

Michael Schmid
In reply to this post by wolf indark
Hi Wolf,

two possible reasons for such problems:

(1) If the background is not in the fit or not sufficiently constant.
What are your parameters? You can't have a general 2D Gaussian with 4  
parameters, you need 8!

v = a + b * exp(-(c*(x-f)^2+d*(x-f)*(y-g)+e*(y-f)^2))

Finding the solution of an 8-parameter fit will usually take some  
time and with many parameters there is also a danger of running into  
local minima.

Even if the Gaussian has the same width in x and y and no off-
diagonal term, you have 5:

v = a + b * exp(-c*((x-d)^2+(y-e)^2))


(2) Maybe your initial values are not good enough? You can use the  
Moment Calculator plugin for the initial values.

Michael
________________________________________________________________

On 2 Jun 2011, at 15:27, wolf indark wrote:

> Dear ImageJ users
>
> I try to perform a gaussian fit froma a macro I am writing. Data is  
> 2D. When
> the width of the gaussian curve is narrow, ImageJ doFit function  
> does not
> fit the data. I can fit the data to Gaussian curve by changing simlex
> initial guesses.
>
> However, from the macro code, even though I gaved the initialGues  
> array for
> the parameters a, b, c, d. But it doesnt change anything. From the  
> simlex
> parameter dialog box, when I change the initial parameters, it works.
>
> what is the problem with the macro Fit functions ?
> I will be pleased if you share your opinions.
>
> best regards
Reply | Threaded
Open this post in threaded view
|

Analyze Particles- saving zero results values

Citron, Bruce
I have a macro that uses Analyze Particles and automatically increments
through a collection of pairs of tifs of dual stained cells, e.g., Hoechst
plus Annexin stained.
It works fine unless there are zeros counts in a particular tif.  That data,
the 0 cell count, does not appear in the Summary window.
That makes it difficult for copy pasting into the data analysis excel
spreadsheet.

An example of part of a Summary table is:
Slice                    Count      Total Area   Average Size  Area Fraction
Mean
HT22 MI H Well 2-2.tif    62    0.189    0.003    0.3    63.808    0.914
0.854
HT22 MI A Well 2-2.tif    9    0.035    0.004    0.1    87.602    0.948
0.887
HT22 MI H Well 2-3.tif    55    0.217    0.004    0.4    64.776    0.888
0.858
HT22 MI H Well 2-4.tif    95    0.466    0.005    0.8    73.232    0.914
0.881
HT22 MI A Well 2-4.tif    11    0.064    0.006    0.1    96.743    0.949
0.890
Where Well 2, field 3 did not have any Annexin positive cells and results in
a missing row from the data.

What would be a recommended way to obtain all of the rows of data, even if
there are zero cells (particles) present?
(And I am not wedded to the Summary table, I wouldn¹t mind writing data to a
file from the macro, if needed.)
Thank you,
Bruce
--
Bruce A. Citron, Ph.D., Bay Pines VA
Reply | Threaded
Open this post in threaded view
|

Re: Analyze Particles- saving zero results values

Nathaniel Ryckman
You can add in a row if the particle analyzer returned 0 entries.

Here is some pseudo-code for you:

before = roiManager(Count);
run("Particle Analyzer");
after = roiManager(Count);

if(after == before)
{
                endIndex = nResults;
                setResult("Slice", endIndex, fileName);
                setResult("Mean", endIndex, 0);
                setResult("Count", endIndex, 0);
}


Here is a small tutorial for messing with tables:

http://www.image-stack.de/IIP%20with%20ImageJ/CHAPTER01/CHAPTER01-3/chapter01-3.html

I think fileName is a global variable like nResults. If it is not, you will need to find another way to get the name of the current file.

Good luck! Tell me if you need any more help :-).

Bruce Citron wrote
I have a macro that uses Analyze Particles and automatically increments
through a collection of pairs of tifs of dual stained cells, e.g., Hoechst
plus Annexin stained.
It works fine unless there are zeros counts in a particular tif.  That data,
the 0 cell count, does not appear in the Summary window.
That makes it difficult for copy pasting into the data analysis excel
spreadsheet.

An example of part of a Summary table is:
Slice                    Count      Total Area   Average Size  Area Fraction
Mean
HT22 MI H Well 2-2.tif    62    0.189    0.003    0.3    63.808    0.914
0.854
HT22 MI A Well 2-2.tif    9    0.035    0.004    0.1    87.602    0.948
0.887
HT22 MI H Well 2-3.tif    55    0.217    0.004    0.4    64.776    0.888
0.858
HT22 MI H Well 2-4.tif    95    0.466    0.005    0.8    73.232    0.914
0.881
HT22 MI A Well 2-4.tif    11    0.064    0.006    0.1    96.743    0.949
0.890
Where Well 2, field 3 did not have any Annexin positive cells and results in
a missing row from the data.

What would be a recommended way to obtain all of the rows of data, even if
there are zero cells (particles) present?
(And I am not wedded to the Summary table, I wouldn¹t mind writing data to a
file from the macro, if needed.)
Thank you,
Bruce
--
Bruce A. Citron, Ph.D., Bay Pines VA
Reply | Threaded
Open this post in threaded view
|

Re: Analyze Particles- saving zero results values

Citron, Bruce
In reply to this post by Citron, Bruce
Wayne Rasband has solved this with the latest version of ImageJ and zero
counts are now included in the summary.
-Bruce
Reply | Threaded
Open this post in threaded view
|

Re: Analyze Particles- saving zero results values

Nathaniel Ryckman
Nice. Just out of curiosity, are the values in the 0 count rows all set to NULL or 0?

Bruce Citron wrote
Wayne Rasband has solved this with the latest version of ImageJ and zero
counts are now included in the summary.
-Bruce
Reply | Threaded
Open this post in threaded view
|

Re: Stack Histogram is great!

Citron, Bruce
In reply to this post by Citron, Bruce
I greatly appreciate adding the Stack Histogram option to
Adjust-Threshold!!!
Coincidentally, I needed this for the first time today, attempting to
process some extracted stacks from Olympus .oib confocal images.

For some reason, I was sporadically getting different abilities to threshold
at all for different stacks, likely due to first slice sometimes being
totally blank.
I was resorting to running the full histogram on the stack, multiplying by
the total voxels, then dividing by the voxel count above the desired level
to get some information about intensity in a 3-d region of interest.

I was running 1.45i, I googled ImageJ threshold stack and the third hit was
ImageJ News- Added a "Stack histogram" checkbox to the
Image>Adjust>Threshold dialog so I updated and all is right with the world.

Now, with the Stack Histogram option, I get exactly the same average
intensities to four significant digits by the histogram after thresholding
with Set Measurements- Limit to threshold.
Thanks very much,
Bruce