Skip to content

Conversation

@jokasimr
Copy link
Contributor

@jokasimr jokasimr commented Sep 5, 2025

Fixes #24

Not sure if this is actually the tool that is requested, or if the approach does what we need, but I think it's good to have a starting point for discussion.

@jokasimr
Copy link
Contributor Author

jokasimr commented Sep 5, 2025

The implementation here

  1. takes the ratios of intensities at subsequent gain values,
  2. fits a line to each of them in the wavelength dimension,
  3. then evaluates the ratio of the slope and the intercept of each line as a measure of "flatness".
  4. The "flatness" is compared to a threshold to determine the gain where saturation occurs.

Is this algorithm sufficient?

Is this the interface we need?

Is there any test data (beside the example posted in the issue)?

@YooSunYoung
Copy link
Member

Is this algorithm sufficient?

I think so...?

Is this the interface we need?

We should probably have a visualization tool too. (i.e. notebook in code shelf)

Is there any test data (beside the example posted in the issue)?

Unfortunately not. But it will be needed from the day 1 of hot-comissioning.
As far as I know, instrument scientists were just using the ImageJ with the tiff files that loscovision SW produces.
We should also figure out how the gain is written in the file.

@jokasimr
Copy link
Contributor Author

jokasimr commented Sep 8, 2025

We should probably have a visualization tool too. (i.e. notebook in code shelf)

What kind of visualization do you have in mind?
A 1D graph with the "saturation" as a function of gain?

@YooSunYoung
Copy link
Member

What kind of visualization do you have in mind?
A 1D graph with the "relative magnitude of the slope, of the ratio between subsequent intensities" as a function of gain?

Yes...!
But I just realized that the function doesn't really yield any intermediate results to be visualized...

So... maybe the final interface for user(instrument scientist), including visualization can be written later from here...?

@jokasimr
Copy link
Contributor Author

jokasimr commented Sep 8, 2025

Yes...!
But I just realized that the function doesn't really yield any intermediate results to be visualized...

That can be fixed. 👍

I just scheduled a meeting with Soren this afternoon to talk about what interface he needs.

@jokasimr
Copy link
Contributor Author

jokasimr commented Sep 8, 2025

Example signal as function of gain and wavelength (input to function):

Saturation kicks in around gain=100, and that causes the strange intensity in the upper part of the image.

example_saturation

"Saturation indicator", the maximum indicates that saturation has kicked in:

indicator

To avoid saturation, set the gain slightly to the left of the peak.

@jokasimr jokasimr marked this pull request as ready for review September 9, 2025 07:18
@github-project-automation github-project-automation bot moved this to In progress in Development Board Sep 9, 2025
@jokasimr jokasimr moved this from In progress to Selected in Development Board Sep 9, 2025
@jokasimr
Copy link
Contributor Author

jokasimr commented Sep 9, 2025

These figures display the indicator for signals with three different levels of noise.
In the first figure the input signal has no noise, in the next two figures the input signal has increasing levels of noise.
In all cases saturation is set to kick in around gain=100.
The purpose is to illustrate that the method is robust to noise.

no-noise some-noise lot-of-noise

This figure shows what the indicator looks like for Sun's example data in the issue description:
sun-example

sharpness-and-focus-point
maximum_resolution_achievable
saturation_indicator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the notebook called saturation_indicator missing...?

And maximum_resolution_achievable is also missing from the menu: https://remote-unzip.deno.dev/scipp/essimaging/artifacts/3961599931/tools/index.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍 added those by mistake.

"laplace_2d",
"maximum_resolution_achievable",
"resample",
"saturation_indicator",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, might be because of some white space in the docs comment.
I'll try to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'm not sure why the api reference is not rendered properly here. Do you know @YooSunYoung ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry I missed the comment. It looks like you fixed it though : D ...!

@jokasimr jokasimr requested a review from YooSunYoung September 9, 2025 12:56
"laplace_2d",
"maximum_resolution_achievable",
"resample",
"saturation_indicator",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry I missed the comment. It looks like you fixed it though : D ...!

@jokasimr jokasimr merged commit 90b0ff0 into main Sep 9, 2025
4 checks passed
@jokasimr jokasimr deleted the saturation-indicator branch September 9, 2025 15:16
@github-project-automation github-project-automation bot moved this from Selected to Done in Development Board Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Requirement] Timepix image intensifier saturation workflow.

3 participants