-
Notifications
You must be signed in to change notification settings - Fork 43
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 cc3d with multiple channels? #57
Comments
Hi,
Multiple channels are not supported. I'm not totally sure what that would
mean as often the channels are interrelated and sometimes they represent
different data planes.
You can either: Run cc3d against each channel separately and recombine them
after or you can combine all the channels into a single image (say combine
RGB into a uint32 image).
If you tell me more about your data I can recommend something more specific.
Will
…On Mon, Nov 9, 2020 at 3:56 AM sneh-debug ***@***.***> wrote:
hello,
I am using 3D images ,so for that how can i apply connected component
library?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#57>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AATGQSMJRV72YSVHAWMSZYTSO6VD3ANCNFSM4TPBOWKA>
.
|
hello @william-silversmith ,i want to apply cc3d on segmentation result image containing multiple class and the dimensions of result image is 128128128 |
Here's what I suspect you want to do: # Let multichannel be the segmentation image.
output = np.zeros(multichannel.shape, dtype=np.uint32)
for i in range(multichannel.shape[3]):
output[:,:,:,i] = cc3d.connected_components(multichannel[:,:,:,i]) If instead by multichannel, you don't mean mean a 4D image and instead mean simply an image with multiple label types (i.e. label 1 might be adjacent to label 2), just use cc3d normally, that's what it was designed for. |
output_dir='./'
PNii = nibabel.load('./prediction/BraTS20_Training_368/prediction.nii.gz')
P = PNii.get_fdata()
print(P.shape)
#multichannel='./prediction/BraTS20_Training_368/prediction.nii.gz'
output = np.zeros(P.shape, dtype=np.uint32)
for i in range(P.shape[2]):
output[:,:,i] = cc3d.connected_components(output[:,:,i])
print(output.shape)
output=sitk.GetImageFromArray(output)
#get the save path
sitk.WriteImage(output,output_dir + 'new.nii.gz') This is my code for apply cc3d and saving it into 3d image with .nii.gz format but the output image is blank image? Please tell me what mistake i am doing here. |
Hi sneh, it looks like you are passing a blank output to cc3d. However, the way you're doing it you'll run connected components on each 2D slice, which may not be what you want. The following will probably produce 3D connected components if P is a numpy array. output_dir='./'
PNii = nibabel.load('./prediction/BraTS20_Training_368/prediction.nii.gz')
P = PNii.get_fdata()
output = cc3d.connected_components(P)
output=sitk.GetImageFromArray(output)
sitk.WriteImage(output,output_dir + 'new.nii.gz') |
then it gives following error: |
If your data is floating point, it's not supported. You'll have to find a way to convert it to integer labels. This could be as easy as |
@william-silversmith it worked . thank you. can we increase the intensity value? The image obtained from cc3d is not clear, very difficult to visualize. |
I'm glad it worked! To visualize more easily, try casting the output to a float before passing it to |
Closing this question due to inactivity. Please reopen if you still need help! |
hello,
I am using 3D images ,so for that how can i apply connected component library?
The text was updated successfully, but these errors were encountered: