Comments (3)
Hi. Have a look at the nibabel getting started page: https://nipy.org/nibabel/gettingstarted.html
And remember to apply the original image transformation to your prediction. So something like:
import nibabel as nib
img = nib.load('your_input_img_to_be_segmented.nii')
segmentedImage = UNET(img) # segment the image using unet - output is then the segmented volume
outvol = nib.Nifti1Image(segmentedImage, img.affine, img.header) # use the header and affine from the original image
nib.save(outvol, 'your_segmented_img.nii')
from notebooks.
yeah thank you , i have an error when i try to print affine for predicted mask ---> 'numpy.ndarray' object has no attribute 'affine'. In your code you use dataobj_images.DataobjImage to recognizepredicted mask. Can I use the same instructions for this type?
from notebooks.
That is just to convert it into the datatype that the nifty widget uses.
The predicted mask has no affine attribute as it is a numpy array. You need to apply the same transformation to your prediction as was in the original .nii image that you wanted to segment.
If following the code, this is saved in: imgTargetNii = nib.load(targetImagePath)
so the imgTargetNii.affine and imgTargetNii.header should contain the info that you want to apply to your predicted mask as well.
You can also just use: nib.Nifti1Image(segmentedImage), but the location of the segmentation might be different than the imgTargetNii.
from notebooks.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notebooks.