ellisdg / 3DUnetCNN

Pytorch 3D U-Net Convolution Neural Network (CNN) designed for medical image segmentation
MIT License
1.9k stars 653 forks source link

nibabel.filebasedimages.ImageFileError #5

Closed build2create closed 7 years ago

build2create commented 7 years ago

I am also using BRATS dataset containing the images in mha format. Will that not work? I saw in your readme that you have used BRATS 2015 dataset. The folders inside my ./data for a particular patient looks something like this screenshot from 2017-04-07 15 16 09 The content inside the folder lloks like this screenshot from 2017-04-07 15 24 15

I even tried to zip the mha file and then give it as input but no help. I tried this in normalize.py background_path = os.path.join(subject_folder, subject_folder.split("/")[-1]+str(".mha.gz"))

Please let me know what is the correct way to give input of images. Also what is foreground and background in your context? I mean we are using 4 modalities T1,T2, T1c and FLAIR and of course ground truth. I cannot understand background or foreground in this context.

PS I am using latest code updated 13 hours ago

build2create commented 7 years ago

Please give details about your input file format. I am also using BRATS but there are images of extension mha. While you are giving input as .ni.gz image. I have also tried converting mha to nii but not much help. Getting value error then. Please help

ellisdg commented 7 years ago

Hey @build2create, I just uploaded preprocess.py with my preprocessing methods in it.

from preprocess import convert_brats_data
from config import config

print(config["data_dir"])  # shows where the data will be converted to. Change this in the source code if you want a different directory
convert_brats_data("/path/to/BRATS/BRATS2015_Training",  config["data_dir"])

You need to have N4BiasFieldCorrection from ANTs installed in order to make it work.

As a general note, the '.mha' files can be converted using SimpleITK.

ellisdg commented 7 years ago

@build2create I am using background to denote the image pixels that are not a part of the brain. The foreground is the opposite of the background. I save these images because the original files have a lot of extra padding around them. Reducing this extra padding makes running them through CNN slightly less memory intensive.

build2create commented 7 years ago

@ellisdg Done. That worked like a charm. Thanks. But now I am getting a new error in line 64 of data.py data_list.append(read_image(os.path.join(folder, modality + ".nii.gz"), image_shape=image_shape, crop=crop)).get_data() sayingAttributeError: 'NoneType' object has no attribute 'get_data' . So I changed it to data_list.append(read_image(os.path.join(folder, modality + ".nii.gz"), image_shape=image_shape, crop=crop).get_data()). It worked. But now I am getting ValueError: setting an array element with a sequence. due to line 34 data_storage.append(subject_data[:3][np.newaxis]) in data.py

ellisdg commented 7 years ago

I won't be able to look into it until tomorrow or Monday. If you figure out what is going wrong before then, could you submit a pull request that fixes the issue?

On Apr 8, 2017 12:12 PM, "build2create" notifications@github.com wrote:

@ellisdg https://github.com/ellisdg Please reply

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ellisdg/3DUnetCNN/issues/5#issuecomment-292731956, or mute the thread https://github.com/notifications/unsubscribe-auth/AIKZkykS4sbCebC88Uc47EdgRf8TCiKVks5rt7_7gaJpZM4M2sp4 .

build2create commented 7 years ago

@ellisdg Did you figure out the problem? I am still stuck.

ellisdg commented 7 years ago

@build2create I believe that issue should be fixed now.

build2create commented 7 years ago

Thanks a lot it worked!