It does mask and crop the brain successfully but since median filtering is done on the whole 4D dataset, computation time is increased a lot.