by

## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
E | M
@ewuramaminka

I have loaded CT dicom images. I want to segment the tissue within the CT. E.g. I want to determine there is 30% soft tissue 45% bone tissue, 20% air etc ... based on hounsefield units.

Anyone an expert in biomedical image analysis with scikit image?
Any useful libraries?

Looking for help. Thanks ☺️

Curtis Rueden
@ctrueden
@ewuramaminka I would encourage you to start a thread on https://forum.image.sc with an example of your images, and tagged with scikit-image.
E | M
@ewuramaminka
@ctrueden sure. Doing this now. Thanks
E | M
@ewuramaminka
for a frame of image slices --> fig, axes=plt.subplots(nrows=2, ncols=36) how can I maximize the frame ? I have tried ==> mng = plt.get_current_fig_manager()
mng.resize(*mng.window.maxsize()) but i get AttributeError: 'FigureManagerBase' object has no attribute 'window'. please assist.
Mark Harfouche
@hmaarrfk
you want to maximize the window?
E | M
@ewuramaminka

Yes. Because i made over 70 subplots and figure is so small as shown in console

Can my subplot frame be created in a window which can be maximized ?

Mark Harfouche
@hmaarrfk
making 70 subplots seems like a bad idea, do you have a 20k screen that is 60 inches wide?
@ewuramaminka for processing medical CT images using skimage, a great starting resource is the Data Science Bowl 2017 with a large number of Jupyter Notebooks (called Kaggle Kernels) on how to preprocess the data, segment lungs, and ultimately train models: https://www.kaggle.com/gzuidhof/full-preprocessing-tutorial and https://www.kaggle.com/ankasor/improved-lung-segmentation-using-watershed are a good start. They also deal directly with the DICOM data and show how that can be opened, rescaled, etc. The kernels page is here: https://www.kaggle.com/c/data-science-bowl-2017/kernels and the competition also has a large number of discussions which can provide useful starting points.
E | M
@ewuramaminka
@kmader thanks a lot!
Tanim Islam
@tanimislam
Hi all, can scikit-image save an $M \times N$ integer numpy array into a 16-bit grayscale image?
Juan Nunez-Iglesias
@jni
yep, if you do from skimage import io; io.imsave('filename.png', arr.astype(np.uint16)), it should work. I'm assuming of course that you don't have any integers larger than 65535
Tanim Islam
@tanimislam
thanks @jni
and yes, no integers larger than 65535 (numpy array represents 16-bit grayscale data)
Stefan van der Walt
@stefanv

Hi everyone; we're going to try something new for the chat forum. Please direct your browsers to:

https://skimage.zulipchat.com

We'll try this forum for a few weeks to see how it goes!

Sreekar Reddy
@sreekar2307
Any non-intelligent algorithms for image classification?
E | M
@ewuramaminka
How do I load a nifty image ? I want to use threshold otsu to separate composition

I used nibabel to load it fine but it’s a 3D and I threshold it using threshold_otsu

The error I’m getting is “Nifti1Image’ object has no attribute min

Curtis Rueden
@ctrueden
@ewuramaminka Are you able to post a link to a sample non-working NIFTI image?
E | M
@ewuramaminka
Sure
Curtis Rueden
@ctrueden
@ewuramaminka Is this image all zeroes?
Nevermind, I see that it is not.
@ewuramaminka I got it working by opening the image through ImageJ using pyimagej. :-)
Curtis Rueden
@ctrueden
I will post a gist shortly.
Curtis Rueden
@ctrueden
This gets you a numpy array from your NIFTI data, which is presumably what you want? Then you can analyze it with skimage (and/or ImageJ) as per usual.
Curtis Rueden
@ctrueden
@ewuramaminka I checked your code and saw you using SimpleITK. Is that working? If so, you could also stick with that.
You mention nibabel above… your error suggests to me the object you get back isn’t an numpy array, but a Nifti1Image object. There is probably a function you can call on it that will give you a numpy array? Sorry, I don’t know that library.
E | M
@ewuramaminka
@ctrueden i realised you plotted one slice ?
Curtis Rueden
@ctrueden
Yeah, there might be a bug with converting the whole 3D thing to numpy at once. As a workaround, it can be converted slice by slice.
But it sounds like you have other/better ways of getting the data into Python already. Particularly nibabel which looks pretty tailored to your needs?
It’s just a matter of getting the pixels as a numpy array, right?
E | M
@ewuramaminka
nibabel doesnt even let me create the histograms i want
my current need is to use threshold_otsu to threshold my nifty .. if u could please try that
using simple ITK
Curtis Rueden
@ctrueden

It looks like you need to write:

import nibabel as nib
data = img.get_fdata()

and then type(data) will be numpy.ndarray instead of Nifti1Image. And you can compute stuff on the data. Does that help?

E | M
@ewuramaminka
ok i just tried
i still got this 'AttributeError: 'Nifti1Image' object has no attribute 'get_fdata'
Curtis Rueden
@ctrueden
Which version of nibabel?
We can check the source code.
From the changelog: it looks like the get_fdata was added in version 2.2? Are you using an older version? If so, try upgrading.
Gotta run to a meeting. Good luck.
E | M
@ewuramaminka
2.0.2
nibabel ver - 2.0.2
Curtis Rueden
@ctrueden
See if you can update to 2.2 or newer.
E | M
@ewuramaminka
I finally got stik to load it
Thanks very much