Warning log when using method get_region() (SpatialImage, LabelledImage, TissueImage)
Using get_region() causes warning or error log because of the (non-)instanciation of the attributes. Also it could be a problem in case the wanted attributes are not the default ones (except voxelsize).
In SpatialImage :
def get_region(self, region):
Attributes of the image are not recovered in the method. The line 1544 could be modified from:
out_sp_img = SpatialImage(reg_val, voxelsize=tmp_vox)
to :
out_sp_img = SpatialImage(reg_val, voxelsize=tmp_vox, unit=self.unit, axes_order=self.axes_order, origin=self.origin)
In LabelledImage:
from timagetk.components.image import get_image_attributes attrs = get_image_attributes(self) return LabelledImage(SpatialImage.get_region(self, region), **attrs)
not_a_label
should be removed and directly set in instanciation
not_a_label = attrs.pop('not_a_label', None) return LabelledImage(SpatialImage.get_region(self, region), not_a_label=not_a_label)
In TissueImage (2D and 3D)
from timagetk.components.image import get_image_attributes attrs = get_image_attributes(self) return TissueImage2D(LabelledImage.get_region(self, region), **attrs)
background
should be removed from attrs and directly set in instanciation
background = attrs.pop('background', None) return LabelledImage(SpatialImage.get_region(self, region), background=background)
This should prevent warning and ensure that non-default attributes are recovered :)