Ryo-Ito / brain_segmentation

Implementation of VoxResNet for 3D brain segmentation
MIT License
66 stars 17 forks source link

Some questions about source code #3

Closed mjiansun closed 7 years ago

mjiansun commented 7 years ago

Question: 1) In 'load.py', i dont understand why change 3D image to 4D image? 2) In 'load.py', scalar_img, mask_img and label_img represent respectively? 3) In 'load.py', if mask_img, scalar_img and label_img is 3D image, 'slices' will be [slice(),slice(),slice()]. So scalar_path is 3D?

Source code: if scalar_img.ndim == 3: scalar_img = (scalar_img - np.mean(scalar_img)) / np.std(scalar_img) scalar_img = scalar_img[:, :, :, None].astype(np.float32) label_img = load_nifti(label_file).astype(np.int32) mask_img = load_nifti(maskfile) slices = [slice(len / 2, -len / 2) for len in shape] mask_img[slices] *= 2
indices = np.where(maskimg > 1.5) i = np.random.choice(len(indices[0])) slices = [slice(index[i] - len / 2, index[i] + len / 2) for index, len in zip(indices, shape)] scalar_patch = scalar_img[slices] label_patch = label_img[slices] scalar_patch = scalar_patch.transpose(3, 0, 1, 2) scalars.append(scalar_patch) labels.append(label_patch)

Ryo-Ito commented 7 years ago
  1. Because the original paper stacked two 3d images to make input of the network. Its size will be something like (xlen, ylen, zlen, 2), and this is 4 dimensional. My code also expects input to be 4d image, but I added some extra lines to cope with 3d input image. In addition, the neural network framework used in this code expects the input to be 5d array (batch_size, xlen, ylen, zlen, n_channels) in order to perform 3d convolution.
  2. scalar_img: preprocessed T1-weighted image, whose size is expected to be (xlen, ylen, zlen, 2). mask_img: binary (0 or 1) 3d image indicates brain region label_img: n-ary target label image, each index represents different anatomical region
  3. Actually, scalar_patch is expected to be 4d patch in my code.
John1231983 commented 7 years ago

@mjiansun: This issue is discussed in issue #2. You can find more information at there @Ryo-Ito : Do you know what is the benefit of reslice step? How much the performance improve comparison without reslice step? Thanks

Ryo-Ito commented 7 years ago

@John1231983 I'm not sure what you mean by "reslice." Does it refer to patch extraction step?

John1231983 commented 7 years ago

No. As you mention in #2: "Yes, I resliced the brain images by myself to make them isotropic.". It will reslice both raw and label images. I ask about this comment

Ryo-Ito commented 7 years ago

@John1231983 I don't think it improves the accuracy dramatically as long as dataset has somewhat consistent voxel size.

mjiansun commented 7 years ago

@John1231983 Hi John, As you mention in #2 , i have same problem.How do you slove this problem? RuntimeError: CUDA environment is not correctly set up (see https://github.com/pfnet/chainer#installation).CuPy is not correctly installed. Please check your environment

John1231983 commented 7 years ago

@mjiansun: In my case, I uninstall cuda and reinstall it. I am using cuda 8.0 (install from .run file) and cudnn 5.0. Good luck

mjiansun commented 7 years ago

@Ryo-Ito @John1231983 Thank you very much!But i meet a serious problem when i import theano. >>> import theano WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: Unable to get the number of gpus available: unknown error)

John1231983 commented 7 years ago

What is GPU device? I am using Titan X. I think the error means you have no GPU

mjiansun commented 7 years ago

2017-03-06 11 53 03

John1231983 commented 7 years ago

Let see my issue and how can I solve it in https://github.com/pfnet/chainer/issues/2259.

mjiansun commented 7 years ago

Thank you.

mjiansun commented 7 years ago

@Ryo-Ito @John1231983 Questions: 1)In load.py,mask_img[slices] *= 2, what this code is doing?

mjiansun commented 7 years ago

I understand this action.