Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nibabel.filebasedimages.ImageFileError #5

Closed
build2create opened this issue Apr 7, 2017 · 8 comments
Closed

nibabel.filebasedimages.ImageFileError #5

build2create opened this issue Apr 7, 2017 · 8 comments

Comments

@build2create
Copy link

build2create commented Apr 7, 2017

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
Copy link
Author

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
Copy link
Owner

ellisdg commented Apr 7, 2017

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
Copy link
Owner

ellisdg commented Apr 7, 2017

@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
Copy link
Author

build2create commented Apr 8, 2017

@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() saying AttributeError: '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
Copy link
Owner

ellisdg commented Apr 8, 2017 via email

@build2create
Copy link
Author

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

@ellisdg
Copy link
Owner

ellisdg commented Apr 10, 2017

@build2create I believe that issue should be fixed now.

@build2create
Copy link
Author

Thanks a lot it worked!

@ellisdg ellisdg closed this as completed Apr 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants