From 916fc4c0461d97a99a39adb3381ad8cd659e58ca Mon Sep 17 00:00:00 2001 From: flatberg Date: Tue, 7 Aug 2007 11:42:07 +0000 Subject: [PATCH] Added scaling to navigator menu, moved transformations to a separate sub menu --- fluents/navigator.py | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/fluents/navigator.py b/fluents/navigator.py index 1ab6a8e..e42b5d4 100644 --- a/fluents/navigator.py +++ b/fluents/navigator.py @@ -5,6 +5,7 @@ import plots import time import fluents import dataset, logger, plots, project, workflow, main +import scipy class NavigatorView (gtk.TreeView): def __init__(self): @@ -187,7 +188,7 @@ class NavigatorMenu(gtk.Menu): self.dataset = None self.tree_iter = None - # Populate menu + # Populate main menu self.load_item = gtk.MenuItem('Load dataset') self.load_item.connect('activate', self.on_load_dataset, navigator) self.append(self.load_item) @@ -198,12 +199,30 @@ class NavigatorMenu(gtk.Menu): self.append(self.save_item) self.save_item.show() - self.trans_item = gtk.MenuItem('Transpose') - self.trans_item.connect('activate', self.on_transpose, navigator) + # Build transform sub menu + self.trans_menu = gtk.Menu() + + self.trans_tr_item = gtk.MenuItem('Transpose') + self.trans_tr_item.connect('activate', self.on_transpose, navigator) + self.trans_menu.append(self.trans_tr_item) + self.trans_tr_item.show() + + self.trans_stdr_item = gtk.MenuItem('Std. rows') + self.trans_stdr_item.connect('activate', self.on_standardise_rows, navigator) + self.trans_menu.append(self.trans_stdr_item) + self.trans_stdr_item.show() + + self.trans_stdc_item = gtk.MenuItem('Std. cols') + self.trans_stdc_item.connect('activate', self.on_standardise_cols, navigator) + self.trans_menu.append(self.trans_stdc_item) + self.trans_stdc_item.show() + + self.trans_item = gtk.MenuItem("Transformation") self.append(self.trans_item) + self.trans_item.set_submenu(self.trans_menu) self.trans_item.show() - # Build plot menu + # Build plot sub menu self.plot_menu = gtk.Menu() self.plot_image_item = gtk.MenuItem('Image Plot') @@ -297,3 +316,20 @@ class NavigatorMenu(gtk.Menu): ds = self.dataset.transpose() icon = fluents.icon_factory.get("dataset") project.data_tree_insert(self.tree_iter, self.dataset.get_name()+".T", ds, None, "black", icon) + + def on_standardise_rows(self, item, navigator): + project = main.project + ds = self.dataset.copy() + axis = 1 + ds._array = ds._array/scipy.expand_dims(ds._array.std(axis), axis) + icon = fluents.icon_factory.get("dataset") + project.data_tree_insert(self.tree_iter, self.dataset.get_name()+".rsc", ds, None, "black", icon) + + def on_standardise_cols(self, item, navigator): + project = main.project + ds = self.dataset.copy() + axis = 0 + ds._array = ds._array/scipy.expand_dims(ds._array.std(axis), axis) + icon = fluents.icon_factory.get("dataset") + project.data_tree_insert(self.tree_iter, self.dataset.get_name()+".csc", ds, None, "black", icon) +