Imported from https://github.com/elras/SoftsegmentNeurons