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

Upgrades code for Python 3.8 & adds slider for image brightness and mask alpha channel #89

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

klezm
Copy link

@klezm klezm commented May 15, 2020

Overall there are 4 changes to the code

  1. Upgrade the code to be ready for Python 3.8 (using https://github.com/asottile/pyupgrade)
  2. I added a slider to control the brightness of the image. Actually i change the alpha channel and set or unset a black Background.
  3. Another slider for the alpha channel of the mask
  4. minor changes in the appearance
    1. Change palette from Reds to white and magenta
    2. more space for the plots in the matplotlib window

Examples:

1

The same as above, but now with a bright image and a more transparent mask:

2

@ofgulban
Copy link
Owner

Hi @klezm ,

Thanks a lot for your detailed and orderly pull request. Looks very good already. I will have a more detailed look next week after tuesday for merging :)

May I ask what type of image is your input in the pictures above? Just curiosity :)

@klezm
Copy link
Author

klezm commented May 15, 2020

I found some open datasets on http://www.informatik.uni-leipzig.de/~wiebel/public_data/index.html where I picked the "Abdominal MRI" dataset.

But for my purpose I used your tools to analyse microscopy images.

Btw. I would recommend you to look at the commits separately since most of the changes are from pyupgrade

@klezm
Copy link
Author

klezm commented May 15, 2020

That's the code i used to convert a numpy array to the nifti format.

import nibabel
import numpy as np

ims = np.arange(3*5*5).reshape((3, 5, 5))
print(ims.shape)  # 3 Images of shape (5, 5)

ims = np.moveaxis(ims, 0, -1)  # segmentator has a "cylce" button to move the axes as well
nii = nibabel.Nifti1Image(ims, affine = np.eye(4))
print(nii.dataobj.shape)

nibabel.save(nii, "test.nii")
# nii.to_filename("test.nii")  # equivalent to the command above

Maybe I could implement the functionality to load folders as well.

@ofgulban
Copy link
Owner

Hey @klezm , cool. I did not work with microscopy images but I am happy to hear that Segmentator is being used on images other than MRI brains :).

If you would like to add functionality to load such images, I would be happy to have it as another pull request. Though, your code seems perfect for a quick nifti conversion. I also have similar scripts to generate synthetic images etc.

Sorry I was a bit late responding, had a paper came back for revision recently. Probably I will only have time to inspect the pull requests around a month or so. But I really appreciate your contribution, and do feel free to add the additional image loading capability if you wish so :)

@ofgulban ofgulban added this to the v1.7.0 milestone May 21, 2020
@ofgulban ofgulban self-assigned this May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants