nii toolbox implementation fixes