def process(self, obj_data):
'''
Perform component analysis on data:
Results are added to the data wrapper as a dictionary with
results['CA'] = Eigenvenctors
results['Projection'] = Projection on to the eigenvectors
@param obj_data: Data wrapper containing the data
'''
num_components = self.ap_paramList[0]()
component_type = self.ap_paramList[1]()
start_time = self.ap_paramList[2]()
end_time = self.ap_paramList[3]()
results = dict()
results['start_date'] = start_time
results['end_date'] = end_time
if len(self.ap_paramList) >= 5:
label_names = self.ap_paramList[4]()
else:
label_names = None
cut_data = []
for label, data, err in obj_data.getIterator():
if label_names == None or label in label_names:
cut_data.append(data[start_time:end_time])
cut_data = np.array(cut_data)
if len(cut_data) > 0:
if component_type == 'ICA' :
ca = FastICA(n_components = num_components)
else:
ca = PCA(n_components = num_components)
time_projection = ca.fit_transform(cut_data.T)
results['CA'] = ca
results['Projection'] = time_projection
else:
results['CA'] = None
results['Projection'] = None
obj_data.addResult(self.str_description, results)
评论列表
文章目录