def copy_volume(self, existing_volume, starts=None, sizes=None): """create a Volume object by copying an existing Volume Usage: copy_volume(existing_volume [, start=(s0,s1, ...), sizes=(n0,n1,...)]) Arguments: Volume : existing_volume start : extract a subvolume starting at given voxel (optional) size : extract a subvolume of given dimensions (optional) """ if hasattr(self, 'volume_io_obj'): raise RuntimeError, \ 'volume_io_obj can only be created by a constructor' if existing_volume.__class__ is not Volume: raise TypeError, ("Cannot create volume of type %s from type Volume." + " Try copy='definition' instead.") \ % existing_volume.__class # copy the whole volume if starts is None and sizes is None: self.volume_io_obj = VolumeIO_a.copy_volume( existing_volume.volume_io_obj) # or copy only a subvolume else: Volume._copy_sub_volume_definition_no_alloc( self, existing_volume, starts, sizes) VolumeIO_a.alloc_volume_data(self.volume_io_obj) hyperslab = VolumeIO._get_real_subvolume( existing_volume.volume_io_obj, tuple(starts), tuple(sizes)) VolumeIO._set_real_subvolume(self.volume_io_obj, (0, ) * existing_volume.get_n_dimensions(), hyperslab) if self.volume_io_obj is None: raise RuntimeError self._copy_attributes(existing_volume.attributes)
def copy_volume(self, existing_volume, starts=None, sizes=None): """create a Volume object by copying an existing Volume Usage: copy_volume(existing_volume [, start=(s0,s1, ...), sizes=(n0,n1,...)]) Arguments: Volume : existing_volume start : extract a subvolume starting at given voxel (optional) size : extract a subvolume of given dimensions (optional) """ if hasattr(self, 'volume_io_obj'): raise RuntimeError, \ 'volume_io_obj can only be created by a constructor' if existing_volume.__class__ is not Volume: raise TypeError, ("Cannot create volume of type %s from type Volume." + " Try copy='definition' instead.") \ % existing_volume.__class # copy the whole volume if starts is None and sizes is None: self.volume_io_obj = VolumeIO_a.copy_volume(existing_volume.volume_io_obj) # or copy only a subvolume else: Volume._copy_sub_volume_definition_no_alloc(self, existing_volume, starts, sizes) VolumeIO_a.alloc_volume_data(self.volume_io_obj) hyperslab = VolumeIO._get_real_subvolume(existing_volume.volume_io_obj, tuple(starts), tuple(sizes)) VolumeIO._set_real_subvolume(self.volume_io_obj, (0,) * existing_volume.get_n_dimensions(), hyperslab) if self.volume_io_obj is None: raise RuntimeError self._copy_attributes(existing_volume.attributes)
def get_hyperslab(self, start, size, typecode=numpy.float_): "get an n dimensional array of real values from the volume" return self._cast(VolumeIO._get_real_subvolume(self.volume_io_obj, tuple(start), tuple(size)), typecode)
def get_hyperslab(self, start, size, typecode=numpy.float_): "get an n dimensional array of real values from the volume" return self._cast( VolumeIO._get_real_subvolume(self.volume_io_obj, tuple(start), tuple(size)), typecode)