rdm sorting added
@@ -304,7 +304,6 @@ class RDMs:
elif file_type == 'pkl':
write_dict_pkl(filename, rdm_dict)
-
def to_dict(self):
""" converts the object into a dictionary, which can be saved to disk
@@ -320,6 +319,28 @@ class RDMs:
rdm_dict['dissimilarity_measure'] = self.dissimilarity_measure
return rdm_dict
+ def sort_by(self, by):
+ """ resorts the rdm patterns
+
+ 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 subsampled RDMs
+
+ """
+ desc = self.pattern_descriptors[by]
+ order = np.argsort(desc)
+ self.measurements = self.measurements[order]
+ self.pattern_descriptors = subset_descriptor(
+ self.pattern_descriptors, order)
+ dissimilarities = self.get_matrices()
+ dissimilarities = dissimilarities[:, order][:, :, order]
+ self.dissimilarities = batch_to_vectors(dissimilarities)
+
def rdms_from_dict(rdm_dict):
""" creates a RDMs object from a dictionary
