# Dealing with empty frames in MRI images

I started working on the application of deep learning in medical imaging recently. While dealing with MRI images in the BraTS dataset, I observe that first and last few frames are always completely empty (black). I want to ask those who are already working in the field, is there a way to remove them in a procedural manner before training and add them correctly after the training as a postprocessing step (to comply with the ground truth segmentations' shape)? Has anyone tried that? I could not find any results on Google. So asking here.

Edit: I think I did not make my point clear enough. I meant to say first and last few frames of each MRI scan are empty. How to deal with those is what I intended to ask.

## 2 Answers

I've worked on the BRATS dataset and I can verify that this is pretty much standard process. Besides throwing the totally blank images, I also throw away the images in the beginning and ending of the sequence that show the tip of the scull and the base of the neck.

Generally when dealing with MRIs, I do this with a script (think of is as a preprocessing step) I run on each image that counts the amount of pixels that have a positive intensity (I actually add a small value to this to account for noise). Let's say for images with values 0-255 I count the amount of pixels with an intensity of over 10-15, let's call this $$x$$. After that I set a threshold (empirically), let's call it $$t$$ and discard images with $$x < t$$.

Specifically for BRATS, because you have the labels, you can see which of these have the desired classes and discard most of the rest. If you try to train a network on the dataset as is you face an enormous imbalance ratio. I've had trouble training networks due to this and the most success I got was when I threw away most of the irrelevant images.

As an expert in image analysis I don't think this would be a problem. I have never worked with MRI images from the particular dataset you described but I found that the format of the file containing the images is NIfTI. NIfTI files can be imported in Matlab(niftiread function), ImageJ and Python (NiBabel-Nipy). Thus you should be able to write a script to import the images from the file, select which images you want to keep, and save the output I'm the same format as the input (NIfTI).