Coder Social home page Coder Social logo

Comments (3)

mateuszbuda avatar mateuszbuda commented on August 20, 2024

Thanks for your interest in this repo.
Image slices are expected to be 3D: 2 spacial dimensions and 1 for 3 channels.
Masks slices are 2D.
One image volume is expected to be 4D: an array of 3D image slices.
Corresponding mask volume is expected to be 3D: an array of 2D mask slices.
At the end of the dataset initialization, mask slices are expanded to 3D volumes with one channel.

# add channel dimension to masks
self.volumes = [(v, m[..., np.newaxis]) for (v, m) in self.volumes]

Variable volumes is expected to be a list of tuples that contain 4D image volume and 4D mask volume.
The order of dimensions is: [slices, height, width, channels].
For example, an image volume with 10 slices and slices of size 200x300 has shape (10, 200, 300, 3) and corresponding mask volume has shape (10, 200, 300, 1).
I hope it helps.

from brain-segmentation-pytorch.

gireeshkbogu avatar gireeshkbogu commented on August 20, 2024

Thank you for the quick response and detailed explanation. I converted .nii.gz files to tiff by thinking that all the input to your code is 2D.
Do you know how can I convert .nii.gz files into .tff (3D images and 2D masks)?

from brain-segmentation-pytorch.

mateuszbuda avatar mateuszbuda commented on August 20, 2024

The model is 2D with 3-channel input but on a higher level it segments volumes.
If you have files for only one modality, you can try to copy it to have 3-channel slices or use gray2rgb function from skimage: https://scikit-image.org/docs/dev/api/skimage.color.html#skimage.color.gray2rgb.
If you have files for three modalities, you have to register them first and then read in the same order and concatenate along the lest dimension/axis.
For masks, you can read them with imread function from skimage with as_gray=True: https://scikit-image.org/docs/dev/api/skimage.io.html#skimage.io.imread.

from brain-segmentation-pytorch.

Related Issues (20)

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.