Search code examples
pythonmachine-learningtensorflowniftynet

NiftyNet: indices are out-of-bounds error


I'm just starting to use NiftyNet for medical image segmentation. To get going with the software, I was trying to run the demo that segments images from the Brats Challenge dataset (http://www.braintumorsegmentation.org/).

I have downloaded the Brats, data, used rename_crop_brats on it, and set my $PYTHONPATH. However, when I run the command:

python net_run.py train -c train_whole_tumor_sagittal.ini --app brats_segmentation.BRATSApp --name anisotropic_nets.wt_net.WTNet

I get the following error message:

tensorflow.python.framework.errors_impl.InvalidArgumentError: Provided indices are out-of-bounds w.r.t. dense side with broadcasted shape

I'm not quite sure what I've messed up here, any advice welcomed.


Solution

  • This error means that you have more discrete labels in your training images than the your network can output. Here, it seems like there are more than 2 labels, while this network is set up to do binary classification.

    Could you check which file the 'histogram_ref_file' in the .ini file is pointing to? It should point to the one provided in the [niftynet]/demos/BRATS17 directory, which binarises the tumour mask. This file should have the following text:

    labellabelfrom 0 1 2 4
    labellabelto 0 1 1 1
    

    Which assigns all tumour labels to 1, and all background labels to 0. If you haven't given the path to this file, the network will have generated it automatically, giving the training images 4 discrete classes.

    Does this solve the problem?