Giter Site home page Giter Site logo

Save about notebooks HOT 3 CLOSED

SpyridoulaZagkou4 avatar SpyridoulaZagkou4 commented on July 22, 2024
Save

from notebooks.

Comments (3)

madsendennis avatar madsendennis commented on July 22, 2024

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.

SpyridoulaZagkou4 avatar SpyridoulaZagkou4 commented on July 22, 2024

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.

madsendennis avatar madsendennis commented on July 22, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.