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

Using imread for Ophys Projections automatically casts them to floats #2672

Open
Ahad-Allen opened this issue Mar 31, 2023 · 0 comments
Open
Labels

Comments

@Ahad-Allen
Copy link
Contributor

Describe the bug
Currently, the projections.py code for ophys projections uses imread to process the image paths it receives from LIMS. This is problematic, as the images are were changed to be integer representations for newer experiments are normalized from 0-255. Because the images are png files, imread will automatically cast them to float32 values ranging from 0-1.

To Reproduce
Calling the from_lims() function of the projections.py file of the sdk will cause this problem. The offending code is in line 53:
img = mpimg.imread(filepath)

Expected behavior
The SDK should probably use the Image class from PIL to handle this instead:
img = PILImage.open(filepath)
This will preserve the integer representation of the new projection files, and should still work with the older floating point projection files.

Actual Behavior
The returned image is represented as a 0-1 floating point number.

Environment (please complete the following information):

  • Python version: 3.6.8
  • AllenSDK version: Current Master

Additional context
This likely affects newer Ophys projects internally exclusively, as the older ones still rely on projections with a 0-1 floating point representation.

Do you want to work on this issue?
I have no problems working on the issue.

@Ahad-Allen Ahad-Allen added the bug label Mar 31, 2023
Ahad-Allen added a commit to Ahad-Allen/AllenSDK that referenced this issue May 5, 2023
Changing imread to PILIMAGE allows
for the projection images to be read as
integers rather than floats
@Ahad-Allen Ahad-Allen mentioned this issue May 5, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant