Skip to content
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

Add back channel normalization before preprocessing #613

Merged
merged 4 commits into from
Jun 24, 2022

Conversation

cliu72
Copy link
Contributor

@cliu72 cliu72 commented Jun 22, 2022

What is the purpose of this PR?

Add back channel normalization before pixel matrix generation, which seems to have been lost when parallelization was added. As in this commit: https://github.com/angelolab/ark-analysis/tree/370415cea71ec675c4be9f2c57a8644702390350 before the parallelization functionality was added, pixel values should be channel normalized before being fed into create_fov_pixel_data.

How did you implement your changes

Added back the code to channel normalize in preprocess_fov before calling create_fov_pixel_data.

Remaining issues

Don't think there are remaining issues.

@cliu72
Copy link
Contributor Author

cliu72 commented Jun 22, 2022

Looks like some test is failing after this change. @alex-l-kong can you take a look? Don't really know how to read these travis logs

@alex-l-kong
Copy link
Contributor

@cliu72 thanks for looking into this, not sure why the channel normalization got deleted after merging master into the parallelization branch (better check my merge tool). I'll take a look at the tests.

@alex-l-kong
Copy link
Contributor

@cliu72 the test needed the new argument for channel normalization values. Also, I updated preprocess_fov to take in channel_norm_df instead of channel_norm_path for consistency purposes (since we pass in pixel_norm_val and not pixel_norm_path).

@ngreenwald
Copy link
Member

How did this slip past the tests? I thought we had a test that specifically checked that images were normalized correctly

@alex-l-kong
Copy link
Contributor

alex-l-kong commented Jun 22, 2022

@ngreenwald the test for calculate_channel_percentiles verifies that it works fine, however the test for create_pixel_matrix doesn't verify the actual values since it generates random values each time. I set it up this way to verify that the function is robust in subsetting to different values that the images could take on.

We could start using a pre-defined dataset to test, similar to how mibi-bin-tools is currently set up. Alternatively, we could consider further refactoring create_pixel_matrix and its helper functions. It's getting a bit bloated and separating out the different steps could make it easier to verify integrity. That way, we can more easily test specific components with hard-coded values, and then randomize the higher-level tests.

@ngreenwald
Copy link
Member

This test I wrote checks to make sure the data has been divided by the right channel-specific normalization factor:
https://github.com/angelolab/ark-analysis/blob/master/ark/phenotyping/som_utils_test.py#L1330

How is it passing if this part of the code got dropped?

@alex-l-kong
Copy link
Contributor

alex-l-kong commented Jun 22, 2022

@ngreenwald ok I see the problem now: mocked_create_fov_pixel_data never actually gets entered. Instead, the test enters the create_fov_pixel_data in som_utils.py. This means none of the assertions in mocked_create_fov_pixel_data actually get checked.

We'll need to find a way to get this mocked up correctly. My guess is it's because you're trying to mock a function that gets called internally by create_pixel_matrix (as opposed to mocking a function that you directly call in a test in som_utils_test.py). I'm working on addressing the new file norm file save location, I'll look into it there.

Copy link
Member

@ngreenwald ngreenwald left a comment

Choose a reason for hiding this comment

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

Okay sounds good. When you get the mocking figured out, can you confirm that the test fails with the current version in master and is fixed by candace's addition here

@alex-l-kong
Copy link
Contributor

@ngreenwald verified that the new mocked function is being entered and passed.

@ngreenwald ngreenwald merged commit 6f49621 into master Jun 24, 2022
@ngreenwald ngreenwald deleted the add_back_px_chan_norm branch June 24, 2022 05:56
@srivarra srivarra added the bug Something isn't working label Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants