def subset_time(self, by, t_from, t_to): """ Returns a subsetted TemporalDataset with time between t_from to t_to Args: by(String): the descriptor by which the subset selection is made from channel dimension t_from: time-point from which onwards data should be subsetted t_to: time-point until which data should be subsetted Returns: TemporalDataset, with subset defined by the selected time_descriptor """ time = get_unique_unsorted(self.time_descriptors[by]) sel_time = [t for t in time if t <= t_to and t>=t_from] selection = bool_index(self.time_descriptors[by], sel_time) measurements = self.measurements[:, :, selection] descriptors = self.descriptors obs_descriptors = self.obs_descriptors channel_descriptors = self.channel_descriptors time_descriptors = subset_descriptor( self.time_descriptors, selection) dataset = TemporalDataset(measurements=measurements, descriptors=descriptors, obs_descriptors=obs_descriptors, channel_descriptors=channel_descriptors, time_descriptors=time_descriptors) return dataset
def subset(self, by, value): """ Returns a set of fewer RDMs matching descriptor values Args: by(String): the descriptor by which the subset selection is made from descriptors value: the value by which the subset selection is made from descriptors Returns: RDMs object, with fewer RDMs """ if by is None: by = 'index' selection = bool_index(self.rdm_descriptors[by], value) dissimilarities = self.dissimilarities[selection, :] descriptors = self.descriptors pattern_descriptors = self.pattern_descriptors rdm_descriptors = extract_dict(self.rdm_descriptors, selection) dissimilarity_measure = self.dissimilarity_measure rdms = RDMs(dissimilarities=dissimilarities, descriptors=descriptors, rdm_descriptors=rdm_descriptors, pattern_descriptors=pattern_descriptors, dissimilarity_measure=dissimilarity_measure) return rdms
def subset_channel(self, by, value): """ Returns a subsetted TemporalDataset defined by certain channel value Args: by(String): the descriptor by which the subset selection is made from channel dimension value: the value by which the subset selection is made from channel dimension Returns: TemporalDataset, with subset defined by the selected channel_descriptor """ selection = bool_index(self.channel_descriptors[by], value) measurements = self.measurements[:, selection] descriptors = self.descriptors obs_descriptors = self.obs_descriptors channel_descriptors = subset_descriptor( self.channel_descriptors, selection) time_descriptors = self.time_descriptors dataset = TemporalDataset(measurements=measurements, descriptors=descriptors, obs_descriptors=obs_descriptors, channel_descriptors=channel_descriptors, time_descriptors=time_descriptors) return dataset
def subset_pattern(self, by, value): """ Returns a smaller RDMs with patterns with certain descriptor values Args: by(String): the descriptor by which the subset selection is made from pattern_descriptors value: the value by which the subset selection is made from pattern_descriptors Returns: RDMs object, with fewer patterns """ if by is None: by = 'index' selection = bool_index(self.pattern_descriptors[by], value) dissimilarities = self.get_matrices()[:, selection][:, :, selection] descriptors = self.descriptors pattern_descriptors = extract_dict( self.pattern_descriptors, selection) rdm_descriptors = self.rdm_descriptors dissimilarity_measure = self.dissimilarity_measure rdms = RDMs(dissimilarities=dissimilarities, descriptors=descriptors, rdm_descriptors=rdm_descriptors, pattern_descriptors=pattern_descriptors, dissimilarity_measure=dissimilarity_measure) return rdms
def subset_obs(self, by, value): """ Returns a subsetted Dataset defined by certain obs value Args: by(String): the descriptor by which the subset selection is made from obs dimension value: the value by which the subset selection is made from obs dimension Returns: Dataset, with subset defined by the selected obs_descriptor """ selection = bool_index(self.obs_descriptors[by], value) measurements = self.measurements[selection, :] descriptors = self.descriptors obs_descriptors = extract_dict(self.obs_descriptors, selection) channel_descriptors = self.channel_descriptors dataset = Dataset(measurements=measurements, descriptors=descriptors, obs_descriptors=obs_descriptors, channel_descriptors=channel_descriptors) return dataset