def _get_voxel_time_series_region(self, ts_h5, x, y, z, var=0, mode=0): region_mapping_volume_gid = ts_h5.region_mapping_volume.load() if region_mapping_volume_gid is None: raise Exception("Invalid method called for TS without Volume Mapping!") volume_rm_h5_class, volume_rm_h5_path = self._load_h5_of_gid(region_mapping_volume_gid.hex) volume_rm_h5 = volume_rm_h5_class(volume_rm_h5_path) volume_rm_shape = volume_rm_h5.array_data.shape x, y, z = preprocess_space_parameters(x, y, z, volume_rm_shape[0], volume_rm_shape[1], volume_rm_shape[2]) idx_slices = slice(x, x + 1), slice(y, y + 1), slice(z, z + 1) idx = int(volume_rm_h5.array_data[idx_slices]) time_length = ts_h5.data.shape[0] var, mode = int(var), int(mode) voxel_slices = prepare_time_slice(time_length), slice(var, var + 1), slice(idx, idx + 1), slice(mode, mode + 1) connectivity_gid = volume_rm_h5.connectivity.load() connectivity_h5_class, connectivity_h5_path = self._load_h5_of_gid(connectivity_gid.hex) connectivity_h5 = connectivity_h5_class(connectivity_h5_path) label = connectivity_h5.region_labels.load()[idx] background, back_min, back_max = None, None, None if idx < 0: back_min, back_max = ts_h5.get_min_max_values() background = numpy.ones((time_length, 1)) * ts_h5.out_of_range(back_min) label = 'background' volume_rm_h5.close() connectivity_h5.close() result = postprocess_voxel_ts(ts_h5, voxel_slices, background, back_min, back_max, label) return result
def get_view_region(self, ts_h5, volume_rm_h5, from_idx, to_idx, x, y, z, var=0, mode=0): idx_slices = slice(x, x + 1), slice(y, y + 1), slice(z, z + 1) idx = int(volume_rm_h5.array_data[idx_slices]) time_length = ts_h5.data.shape[0] var, mode = int(var), int(mode) voxel_slices = prepare_time_slice(time_length), slice( var, var + 1), slice(idx, idx + 1), slice(mode, mode + 1) connectivity_gid = volume_rm_h5.connectivity.load() with h5.h5_file_for_gid(connectivity_gid) as connectivity_h5: label = connectivity_h5.region_labels.load()[idx] background, back_min, back_max = None, None, None if idx < 0: back_min, back_max = ts_h5.get_min_max_values() background = numpy.ones( (time_length, 1)) * ts_h5.out_of_range(back_min) label = 'background' result = postprocess_voxel_ts(ts_h5, voxel_slices, background, back_min, back_max, label) return result
def get_voxel_time_series(self, x, y, z, **kwargs): """ Retrieve for a given voxel (x,y,z) the entire timeline. :param x: int coordinate :param y: int coordinate :param z: int coordinate :return: A complex dictionary with information about current voxel. The main part will be a vector with all the values over time from the x,y,z coordinates. """ overall_shape = self.data.shape x, y, z = preprocess_space_parameters(x, y, z, overall_shape[1], overall_shape[2], overall_shape[3]) slices = prepare_time_slice(overall_shape[0]), slice(x, x + 1), slice(y, y + 1), slice(z, z + 1) result = postprocess_voxel_ts(self, slices) return result