remove nib saving from final layer
from __future__ import absolute_import, print_function
import numpy as np
-import scipy.ndimage
-import nibabel as nib
from niftynet.layer.base_layer import RandomisedLayer
@@ -112,16 +110,7 @@ class RandomBiasFieldLayer(RandomisedLayer):
'''
assert self._bf_coeffs is not None
bf_map = self._generate_bias_field_map(image.shape)
- print(np.asarray(np.where(np.abs(bf_map)>0)).shape)
bf_image = image * bf_map
- print(bf_image.shape, image.shape, np.max(bf_image), np.max(image),
- np.max(bf_map), np.min(bf_map))
- bf_nii = nib.Nifti1Image(bf_map, np.diag([1,1,1,1]))
- bf_image_nii = nib.Nifti1Image(bf_image, np.diag([1,1,1,1]))
- image_nii = nib.Nifti1Image(image, np.diag([1,1,1,1]))
- nib.save(bf_nii, './TestBF.nii.gz')
- nib.save(bf_image_nii, './TestModif.nii.gz')
- nib.save(image_nii, './InitModify.nii.gz')
return bf_image
def layer_op(self, inputs, interp_orders, *args, **kwargs):
@@ -144,25 +133,4 @@ class RandomBiasFieldLayer(RandomisedLayer):
raise NotImplementedError("unknown input format")
return inputs
- # if inputs.spatial_rank == 3:
- # if inputs.data.ndim == 4:
- # for mod_i in range(inputs.data.shape[-1]):
- # inputs.data[..., mod_i] = self._apply_transformation_3d(
- # inputs.data[..., mod_i], inputs.interp_order)
- # if inputs.data.ndim == 5:
- # for t in range(inputs.data.shape[-1]):
- # for mod_i in range(inputs.data.shape[-2]):
- # inputs.data[..., mod_i, t] = \
- # self._apply_transformation_3d(
- # inputs.data[..., mod_i, t], inputs.interp_order)
- # if inputs.interp_order > 0:
- # inputs.data = inputs.data.astype(np.float)
- # elif inputs.interp_order == 0:
- # inputs.data = inputs.data.astype(np.int64)
- # else:
- # raise ValueError('negative interpolation order')
- # return inputs
- # else:
- # # TODO: rotation for spatial_rank is 2
- # # currently not supported 2/2.5D rand rotation
- # return inputs
+
