def get_voxel_time_series(self, x, y, z, var=0, mode=0): """ 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. """ if self.region_mapping_volume is None: raise exceptions.TVBException("Invalid method called for TS without Volume Mapping!") volume_rm = self.region_mapping_volume x, y, z = preprocess_space_parameters(x, y, z, volume_rm.length_1d, volume_rm.length_2d, volume_rm.length_3d) idx_slices = slice(x, x + 1), slice(y, y + 1), slice(z, z + 1) idx = int(volume_rm.get_data('array_data', idx_slices)) time_length = self.read_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) label = volume_rm.connectivity.region_labels[idx] background, back_min, back_max = None, None, None if idx < 0: back_min, back_max = self.get_min_max_values() background = numpy.ones((time_length, 1)) * self.out_of_range(back_min) label = 'background' result = postprocess_voxel_ts(self, voxel_slices, background, back_min, back_max, label) return result
def read_data_shape(self): """ Expose shape read on field data. """ try: return self.get_data_shape('data') except exceptions.TVBException: self.logger.exception("Could not read data shape for TS!") raise exceptions.TVBException("Invalid empty TimeSeries!")
def get_volume_view(self, from_idx, to_idx, x_plane, y_plane, z_plane, var=0, mode=0): """ Retrieve 3 slices through the Volume TS, at the given X, y and Z coordinates, and in time [from_idx .. to_idx]. :param from_idx: int This will be the limit on the first dimension (time) :param to_idx: int Also limit on the first Dimension (time) :param x_plane: int coordinate :param y_plane: int coordinate :param z_plane: int coordinate :return: An array of 3 Matrices 2D, each containing the values to display in planes xy, yz and xy. """ if self.region_mapping_volume is None: raise exceptions.TVBException( "Invalid method called for TS without Volume Mapping!") volume_rm = self.region_mapping_volume # Work with space inside Volume: x_plane, y_plane, z_plane = preprocess_space_parameters( x_plane, y_plane, z_plane, volume_rm.length_1d, volume_rm.length_2d, volume_rm.length_3d) slice_x, slice_y, slice_z = self.region_mapping_volume.get_volume_slice( x_plane, y_plane, z_plane) # Read from the current TS: from_idx, to_idx, current_time_length = preprocess_time_parameters( from_idx, to_idx, self.read_data_shape()[0]) no_of_regions = self.read_data_shape()[2] time_slices = slice(from_idx, to_idx), slice( var, var + 1), slice(no_of_regions), slice(mode, mode + 1) min_signal = self.get_min_max_values()[0] regions_ts = self.read_data_slice(time_slices)[:, 0, :, 0] regions_ts = numpy.hstack( (regions_ts, numpy.ones( (current_time_length, 1)) * self.out_of_range(min_signal))) # Index from TS with the space mapping: result_x, result_y, result_z = [], [], [] for i in range(0, current_time_length): result_x.append(regions_ts[i][slice_x].tolist()) result_y.append(regions_ts[i][slice_y].tolist()) result_z.append(regions_ts[i][slice_z].tolist()) return [result_x, result_y, result_z]