Skip to content

2127 flat, dark, background in pyFAI-calib2 [PROPOSAL] #2143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 30, 2024

Conversation

EdgarGF93
Copy link
Collaborator

@EdgarGF93 EdgarGF93 commented Apr 18, 2024

Proposal for including dark current and flat field images in pyFAI-calib2

  • Dark current file(s)
  • Flat field file

Idea:

  • Currently, pyFAI-calib2 works with ImageModels to handle the data arrays from the file and the mask. ImageFromFilenameModel is a generic class that handles the filename and the data array. MaskedImageModel computes the masking of the array.
  • Idea: to include two new classes:
  1. DarkedMaskedImageModel, same as MaskedImageModel but also takes an instance of ImageFromFilenameModel for the dark current file, and computes the masking and following subtraction of the dark current array

darked_masked_data = Masking(data_array) - dark_current_array

  1. CorrectedImageModel, takes two instances of DarkedMaskedImageModel and an instance of ImageFromFilenameModel for the flat field file, and computes the subtraction of both DarkedMaskedImageModel following by a normalization with flat field array. The idea is to use the second instance of DarkedMaskedImageModel as a background file. This is the correction protocol:

corrected_image = (darked_masked_image_data - darked_masked_background_data) / flat_field

inspired by: https://lookingatnothing.com/index.php/archives/2251

@EdgarGF93 EdgarGF93 added work in progress Don't review improvement needed proposal Something which have to be tested labels Apr 18, 2024
@EdgarGF93 EdgarGF93 changed the title 2127 flat and dark [PROPOSAL] 2127 flat_dark_background_for_pyFAI-calib2 [PROPOSAL] Apr 18, 2024
@EdgarGF93 EdgarGF93 changed the title 2127 flat_dark_background_for_pyFAI-calib2 [PROPOSAL] 2127 flat, dark, background in pyFAI-calib2 [PROPOSAL] Apr 18, 2024
@EdgarGF93
Copy link
Collaborator Author

EdgarGF93 commented Apr 23, 2024

Now there is an instance of a PreProcessedImageModel, which takes into account the mask, the flat and the dark
The flat and the dark now can be uploaded through CLI and GUI
In principle, the preprocessed image now appears during the PeakPicking and Geometry tasks, and flat and dark are used to integrate in 2d and 1d in the final task (IntegrationTask)

Most likely, there are still things to wire if the image is changed during the tasks

Copy link
Member

Choose a reason for hiding this comment

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

Can't this be replaced by preprocessedImageModel ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

correct, DarkedMaskedImageModel.py is no longer needed

@kif
Copy link
Member

kif commented Apr 25, 2024

Is this still WIP ?

@EdgarGF93
Copy link
Collaborator Author

Yes, I will test the change of the image and I will label Ready to merge

@EdgarGF93
Copy link
Collaborator Author

now, flat and dark images can be uploaded through CLI, dialog file and drag&drop, and they will be properly computed along all the calib2 tasks

@EdgarGF93 EdgarGF93 added ready to merge Please review and removed work in progress Don't review improvement needed proposal Something which have to be tested labels Apr 25, 2024
@kif
Copy link
Member

kif commented Apr 25, 2024

@jonwright are you willing to test it ?

@kif kif requested a review from jonwright April 25, 2024 13:23
Copy link
Member

@kif kif left a comment

Choose a reason for hiding this comment

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

LGTM

flat.changed.connect(self.__invalidateValue)
self.__value = None

def __computeImageData(self):
Copy link
Member

Choose a reason for hiding this comment

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

Is this cached anywhere ?

@jonwright
Copy link
Collaborator

Sure - we will try this later today or during the weekend - sometime soon after we figure out how to install pyFAI from a pull request.

@kif
Copy link
Member

kif commented Apr 26, 2024 via email

@kif kif merged commit 14b8777 into silx-kit:main Apr 30, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Please review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants