| 112 | | if self.interval : |
| 113 | | # absolutely no information provided on interval argument, nor t_start or t_stop, but |
| 114 | | # self has a well defined interval |
| 115 | | interval_out = self.interval |
| 116 | | else : |
| 117 | | try: |
| 118 | | t_start = min(self.spike_times) |
| 119 | | except Exception: |
| 120 | | print "Error in guessing t_start (first spike), spikes may be empty !" |
| 121 | | t_start = 0 |
| 122 | | try: |
| 123 | | t_stop = max(self.spike_times) |
| 124 | | except Exception: |
| 125 | | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| 126 | | t_stop = t_start+0.1 |
| 127 | | interval_out = Interval([[t_start, t_stop]]) |
| | 112 | try: |
| | 113 | t_start = min(self.spike_times) |
| | 114 | except Exception: |
| | 115 | print "Error in guessing t_start (first spike), spikes may be empty !" |
| | 116 | t_start = 0 |
| | 117 | try: |
| | 118 | t_stop = max(self.spike_times) |
| | 119 | except Exception: |
| | 120 | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| | 121 | t_stop = t_start+0.1 |
| | 122 | interval_out = Interval([[t_start, t_stop]]) |
| 856 | | def extract_intervals_from_SpikeList_arguments(self, t_start=None, t_stop=None, interval=None) : |
| 857 | | if len(self) > 0: |
| 858 | | if interval is not None: |
| 859 | | # interval is fully defined by the user |
| 860 | | if interval.__class__.__name__ == 'Interval' : |
| 861 | | interval_out = interval |
| 862 | | else : |
| 863 | | interval_out = Interval(interval) |
| 864 | | else: |
| 865 | | if t_start == None and t_stop == None : |
| 866 | | if self.interval : |
| 867 | | # absolutely no information provided on interval argument, nor t_start or t_stop, but |
| 868 | | # self has a well defined interval |
| 869 | | interval_out = self.interval |
| 870 | | else : |
| 871 | | try: |
| 872 | | start_times = numpy.array([self.spiketrains[idx].interval.t_start() for idx in self.id_list()], numpy.float32) |
| 873 | | t_start = numpy.min(start_times) |
| 874 | | logging.debug("Warning, t_start is infered from the data : %f" %t_start) |
| 875 | | except Exception: |
| 876 | | print "Error in guessing t_start (first spike), spikes may be empty !" |
| 877 | | t_start = 0 |
| 878 | | try: |
| 879 | | stop_times = numpy.array([self.spiketrains[idx].interval.t_stop() for idx in self.id_list()], numpy.float32) |
| 880 | | t_stop = numpy.max(stop_times) |
| 881 | | logging.debug("Warning, t_stop is infered from the data : %f" %t_stop) |
| 882 | | except Exception: |
| 883 | | t_stop = t_start + 0.1 |
| 884 | | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| 885 | | interval_out = Interval([[t_start, t_stop]]) |
| 886 | | else : |
| 887 | | if t_start == None : |
| 888 | | try: |
| 889 | | start_times = numpy.array([self.spiketrains[idx].interval.t_start() for idx in self.id_list()], numpy.float32) |
| 890 | | t_start = numpy.min(start_times) |
| 891 | | logging.debug("Warning, t_start is infered from the data : %f" %t_start) |
| 892 | | except Exception: |
| 893 | | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| 894 | | t_start = 0 |
| 895 | | interval_out = Interval([[t_start, t_stop]]) |
| 896 | | if t_stop == None : |
| 897 | | if t_start.__class__.__name__ == 'float' or t_start.__class__.__name__ == 'int' : |
| 898 | | try: |
| 899 | | stop_times = numpy.array([self.spiketrains[idx].interval.t_stop() for idx in self.id_list()], numpy.float32) |
| 900 | | t_stop = numpy.max(stop_times) |
| 901 | | logging.debug("Warning, t_stop is infered from the data : %f" %t_stop) |
| 902 | | except Exception: |
| 903 | | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| 904 | | t_stop = t_start+0.1 |
| 905 | | interval_out = Interval([[t_start, t_stop]]) |
| 906 | | else : |
| 907 | | if t_start.__class__.__name__ == 'Interval' : |
| 908 | | interval_out = t_start |
| 909 | | else : |
| 910 | | interval_out = Interval(t_start) |
| 911 | | else: |
| 912 | | raise Exception("No SpikeTrains") |
| 913 | | return interval_out |
| 914 | | |
| 915 | | |
| 916 | | def extract_intervals_from_SpikeTrain_arguments(self, t_start=None, t_stop=None, interval=None) : |
| | 853 | def extract_intervals_from_SpikeList_arguments(self, t_start, t_stop, interval) : |
| 925 | | if self.interval : |
| 926 | | # absolutely no information provided on interval argument, nor t_start or t_stop, but |
| 927 | | # self has a well defined interval |
| 928 | | interval_out = self.interval |
| 929 | | else : |
| 930 | | try: |
| 931 | | t_start = min(self.spike_times) |
| 932 | | except Exception: |
| 933 | | print "Error in guessing t_start (first spike), spikes may be empty !" |
| 934 | | t_start = 0 |
| 935 | | try: |
| 936 | | t_stop = max(self.spike_times) |
| 937 | | except Exception: |
| 938 | | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| 939 | | t_stop = t_start+0.1 |
| 940 | | interval_out = Interval([[t_start, t_stop]]) |
| | 862 | try: |
| | 863 | start_times = numpy.array([self.spiketrains[idx].interval.t_start() for idx in self.id_list()], numpy.float32) |
| | 864 | t_start = numpy.min(start_times) |
| | 865 | logging.debug("Warning, t_start is infered from the data : %f" %t_start) |
| | 866 | except Exception: |
| | 867 | print "Error in guessing t_start (first spike), spikes may be empty !" |
| | 868 | t_start = 0 |
| | 869 | try: |
| | 870 | stop_times = numpy.array([self.spiketrains[idx].interval.t_stop() for idx in self.id_list()], numpy.float32) |
| | 871 | t_stop = numpy.max(stop_times) |
| | 872 | logging.debug("Warning, t_stop is infered from the data : %f" %t_stop) |
| | 873 | except Exception: |
| | 874 | t_stop = t_start + 0.1 |
| | 875 | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| | 876 | interval_out = Interval([[t_start, t_stop]]) |