Working with MRI data in 2D

Dear all,
I am working on a project to denoise brain MRI images. I am downloading the simulated data from brainweb, which comes in MINC format. I then convert them to .nii. I want to work with 2D slices to begin with. ImageDataBunch works with jpeg or png to my knowledge. I was hoping for some guidance as to how to create the ImageDataBunch for 2D MR data.

Following a Medium post by Jacob Reinbold, I was able to output tiff images from niftii. That is as far as I have gone. He also has git repo for creating dataloaders using tiff.

Any help would be greatly appreciated.

Vishwa

1 Like

Hello,

I am currently working with CT scan data. I have been using this library to convert .nii.gz to .png: https://github.com/FNNDSC/med2image

1 Like

Thank you. I am wondering about the loss of data when i convert from nii to jpg or png. They are 8 bit images right?

I used .png images to avoid the loss associated with .jpg on my original images. Since I am doing segmentation, I did have to manually convert the masks to 8 bit (med2image would not assign proper pixel values based on the segmentation i.e. rather than pixel values 0, 1, 2, 3, … it would assign 0, 12, 24, …) using PIL. To be honest, I do not know exactly what type of pixel data the med2image library produces. The values for each pixel (according to the open_image(path).data printout in fastai) appear to be floating point, but I am not sure if that is their actual value or just they way they are interpreted by fastai