Changeset 358
- Timestamp:
- 11/19/08 17:35:05 (2 months ago)
- Files:
-
- trunk/src/__init__.py (modified) (4 diffs)
- trunk/src/plotting.py (modified) (1 diff)
- trunk/src/signals.py (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/__init__.py
r334 r358 46 46 # messages and the check 47 47 dependencies = {'pylab' : {'website' : 'http://matplotlib.sourceforge.net/', 'is_present' : False, 'check':False}, 48 'matplotlib': {'website' : 'http://matplotlib.sourceforge.net/', 'is_present' : False, 'check':False}, 48 49 'tables': {'website' : 'http://www.pytables.org/moin' , 'is_present' : False, 'check':False}, 49 50 'psyco' : {'website' : 'http://psyco.sourceforge.net/', 'is_present' : False, 'check':False}, … … 63 64 ######################################################### 64 65 65 def get_ warning(name):66 def get_import_warning(name): 66 67 return ''' ----------------- Dependency Warning --------------------- 67 68 ** %s ** package is not installed. … … 69 70 website : %s 70 71 ''' %(name, name, dependencies[name]['website']) 72 73 def get_runtime_warning(name, errmsg): 74 return ''' ----------------- Dependency Warning --------------------- 75 ** %s ** package is installed but cannot be imported. The error message is: %s 76 ''' %(name, errmsg) 71 77 72 78 def check_numpy_version(): … … 92 98 dependencies[name]['is_present'] = True 93 99 except ImportError: 94 print get_warning(name) 100 print get_import_warning(name) 101 except RuntimeError, errmsg: 102 print get_runtime_warning(name, errmsg) 95 103 dependencies[name]['check'] = True 96 104 return dependencies[name]['is_present'] trunk/src/plotting.py
r319 r358 34 34 if check_dependency('pylab'): 35 35 import pylab 36 if check_dependency('matplotlib'): 36 37 from matplotlib.figure import Figure 37 38 from matplotlib.lines import Line2D trunk/src/signals.py
r357 r358 51 51 newnum = check_numpy_version() 52 52 53 ENABLE_PLOTS = check_dependency('pylab') 54 if ENABLE_PLOTS: 53 HAVE_PYLAB = check_dependency('pylab') 54 HAVE_MATPLOTLIB = check_dependency('matplotlib') 55 if HAVE_PYLAB: 55 56 import pylab 56 57 else: 57 MATPLOTLIB_ERROR = "The pylab package was not detected" 58 58 PYLAB_ERROR = "The pylab package was not detected" 59 if not HAVE_MATPLOTLIB: 60 MATPLOTLIB_ERROR = "The matplotlib package was not detected" 59 61 60 62 class SpikeTrain(object): … … 427 429 spikes = numpy.extract((self.spike_times >= t_start) & (self.spike_times <= t_stop), self.spike_times) 428 430 subplot = get_display(display) 429 if not subplot or not ENABLE_PLOTS:430 print MATPLOTLIB_ERROR431 if not subplot or not HAVE_PYLAB: 432 print PYLAB_ERROR 431 433 return 432 434 else: … … 1171 1173 values, xaxis = numpy.histogram(isis, bins=bins, normed=True) 1172 1174 subplot = get_display(display) 1173 if not subplot or not ENABLE_PLOTS:1175 if not subplot or not HAVE_PYLAB: 1174 1176 return values, xaxis 1175 1177 else: … … 1265 1267 values, xaxis = numpy.histogram(cvs, bins=bins, normed=True) 1266 1268 subplot = get_display(display) 1267 if not subplot or not ENABLE_PLOTS:1269 if not subplot or not HAVE_PYLAB: 1268 1270 return values, xaxis 1269 1271 else: … … 1405 1407 rates = self.mean_rates() 1406 1408 subplot = get_display(display) 1407 if not subplot or not ENABLE_PLOTS:1409 if not subplot or not HAVE_PYLAB: 1408 1410 return rates 1409 1411 else: … … 1447 1449 for idx,id in enumerate(self.id_list()): 1448 1450 spike_hist[idx,:] = self.spiketrains[id].time_histogram(time_bin, normalized) 1449 if not subplot or not ENABLE_PLOTS:1451 if not subplot or not HAVE_PYLAB: 1450 1452 return spike_hist 1451 1453 else: … … 1589 1591 position = spklist.id2position(id) 1590 1592 activity_map[position] = rates[count] 1591 if not subplot or not ENABLE_PLOTS:1593 if not subplot or not HAVE_PYLAB: 1592 1594 return activity_map 1593 1595 else: … … 1599 1601 raise Exception("Error, the number of flotting positions does not match the number of cells in the SpikeList") 1600 1602 rates = spklist.mean_rates() 1601 if not subplot or not ENABLE_PLOTS:1603 if not subplot or not HAVE_PYLAB: 1602 1604 return rates 1603 1605 else: … … 1667 1669 else: 1668 1670 results += analysis.ccf(hist_1,hist_2) 1669 if not subplot or not ENABLE_PLOTS:1671 if not subplot or not HAVE_PYLAB: 1670 1672 if not averaged: 1671 1673 return results … … 1765 1767 cc_time[s_min] = (Z-X*Y)/numpy.sqrt((X*(1-X))*(Y*(1-Y))) 1766 1768 xaxis[s_min] = time_bin*idx 1767 if not subplot or not ENABLE_PLOTS:1769 if not subplot or not HAVE_PYLAB: 1768 1770 return cc_time 1769 1771 else: … … 1910 1912 spk = spk.time_slice(t_start, t_stop) 1911 1913 1912 if not subplot or not ENABLE_PLOTS:1913 print MATPLOTLIB_ERROR1914 if not subplot or not HAVE_PYLAB: 1915 print PYLAB_ERROR 1914 1916 else: 1915 1917 ids, spike_times = spk.convert(format="[ids, times]") … … 1964 1966 if t_start is None: t_start = self.t_start 1965 1967 if t_stop is None: t_stop = self.t_stop 1966 if not subplot or not ENABLE_PLOTS:1967 print MATPLOTLIB_ERROR1968 if not subplot or not HAVE_PYLAB: 1969 print PYLAB_ERROR 1968 1970 else: 1969 1971 files = [] … … 2274 2276 subplot = get_display(display) 2275 2277 time_axis = self.time_axis() 2276 if not subplot or not ENABLE_PLOTS:2277 print MATPLOTLIB_ERROR2278 if not subplot or not HAVE_PYLAB: 2279 print PYLAB_ERROR 2278 2280 else: 2279 2281 xlabel = "Time (ms)" … … 2403 2405 result = numpy.array(result) 2404 2406 2405 if not subplot or not ENABLE_PLOTS:2407 if not subplot or not HAVE_PYLAB: 2406 2408 if with_time: 2407 2409 return result, time_axis … … 2851 2853 subplotcount_all += 1 2852 2854 2853 if not figure or not ENABLE_PLOTS:2855 if not figure or not HAVE_PYLAB: 2854 2856 return results 2855 2857 … … 2877 2879 id_list = self._AnalogSignalList__sub_id_list(id_list) 2878 2880 time_axis = self.time_axis() 2879 if not subplot or not ENABLE_PLOTS:2881 if not subplot or not HAVE_MATPLOTLIB: 2880 2882 print MATPLOTLIB_ERROR 2881 2883 else: … … 2912 2914 id_list = self._AnalogSignalList__sub_id_list(id_list) 2913 2915 time_axis = self.time_axis() 2914 if not subplot or not ENABLE_PLOTS:2915 print MATPLOTLIB_ERROR2916 if not subplot or not HAVE_PYLAB: 2917 print PYLAB_ERROR 2916 2918 else: 2917 2919 xlabel = "Time (ms)" … … 2943 2945 id_list = self._AnalogSignalList__sub_id_list(id_list) 2944 2946 time_axis = self.time_axis() 2945 if not subplot or not ENABLE_PLOTS:2946 print MATPLOTLIB_ERROR2947 if not subplot or not HAVE_PYLAB: 2948 print PYLAB_ERROR 2947 2949 else: 2948 2950 xlabel = "Time (ms)"

