| | 102 | |
| | 103 | def extract_intervals_from_SpikeTrain_arguments(self, t_start=None, t_stop=None, interval=None) : |
| | 104 | if interval is not None: |
| | 105 | # interval is fully defined by the user |
| | 106 | if interval.__class__.__name__ == 'Interval' : |
| | 107 | interval_out = interval |
| | 108 | else : |
| | 109 | interval_out = Interval(interval) |
| | 110 | else: |
| | 111 | if t_start == None and t_stop == None : |
| | 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]]) |
| | 128 | else : |
| | 129 | if t_start == None : |
| | 130 | try: |
| | 131 | t_start = min(self.spike_times) |
| | 132 | except Exception: |
| | 133 | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| | 134 | t_start = 0 |
| | 135 | interval_out = Interval([[t_start, t_stop]]) |
| | 136 | if t_stop == None : |
| | 137 | if t_start.__class__.__name__ == 'float' or t_start.__class__.__name__ == 'int' : |
| | 138 | try: |
| | 139 | t_stop = max(self.spike_times) |
| | 140 | except Exception: |
| | 141 | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| | 142 | t_stop = t_start+0.1 |
| | 143 | interval_out = Interval([[t_start, t_stop]]) |
| | 144 | else : |
| | 145 | if t_start.__class__.__name__ == 'Interval' : |
| | 146 | interval_out = t_start |
| | 147 | else : |
| | 148 | interval_out = Interval(t_start) |
| | 149 | return interval_out |
| 721 | | def extract_intervals_from_SpikeTrain_arguments(self, t_start=None, t_stop=None, interval=None) : |
| 722 | | if interval is not None: |
| 723 | | # interval is fully defined by the user |
| 724 | | if interval.__class__.__name__ == 'Interval' : |
| 725 | | interval_out = interval |
| 726 | | else : |
| 727 | | interval_out = Interval(interval) |
| 728 | | else: |
| 729 | | if t_start == None and t_stop == None and interval : |
| 730 | | # absolutely no information provided on interval, but |
| 731 | | # self has a well defined interval |
| 732 | | interval_out = interval |
| 733 | | else : |
| 734 | | # first analyse t_stop |
| 735 | | if t_stop == None : |
| 736 | | try: |
| 737 | | t_stop = max(self.spike_times) |
| 738 | | except Exception: |
| 739 | | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| 740 | | t_stop = 0.1 |
| 741 | | |
| 742 | | # then analyse t_start (ovewrite t_stop if t_start is actually an interval) |
| 743 | | if t_start == None : # no t_start |
| 744 | | t_start = min(self.spike_times) |
| 745 | | except Exception: |
| 746 | | print "Error in guessing t_start (first spike), spikes may be empty !" |
| 747 | | t_start = 0 |
| 748 | | interval_out = Interval([[t_start, t_stop]]) |
| 749 | | else : |
| 750 | | if t_start.__class__.__name == 'float' or t_start.__class__.__name == 'int' : |
| 751 | | # migrate the t_start/t_stop notation to an Interval |
| 752 | | interval_out = Interval([[t_start, t_stop]]) |
| 753 | | else : |
| 754 | | if t_start.__class__.__name__ == 'Interval' : |
| 755 | | interval_out = interval |
| 756 | | else : |
| 757 | | interval_out = Interval(interval) |
| 758 | | return interval_out |
| 855 | | if t_start == None and t_stop == None and interval : |
| 856 | | # absolutely no information provided on interval, but |
| 857 | | # self has a well defined interval |
| 858 | | interval_out = interval |
| 859 | | else : |
| 860 | | # first analyse t_stop |
| 861 | | if t_stop == None : |
| 862 | | try: |
| 863 | | stop_times = numpy.array([self.spiketrains[idx].interval.t_stop() for idx in self.id_list()], numpy.float32) |
| 864 | | t_stop = numpy.max(stop_times) |
| 865 | | logging.debug("Warning, t_stop is infered from the data : %f" %t_stop) |
| 866 | | except Exception: |
| 867 | | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| 868 | | t_stop = 0.1 |
| 869 | | |
| 870 | | # then analyse t_start (ovewrite t_stop if t_start is actually an interval) |
| 871 | | if t_start == None : # no t_start |
| | 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 : |
| 880 | | else : |
| 881 | | if t_start.__class__.__name == 'float' or t_start.__class__.__name == 'int' : |
| 882 | | # migrate the t_start/t_stop notation to an Interval |
| | 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 |
| | 913 | return interval_out |
| | 914 | |
| | 915 | |
| | 916 | def extract_intervals_from_SpikeTrain_arguments(self, t_start=None, t_stop=None, interval=None) : |
| | 917 | if interval is not None: |
| | 918 | # interval is fully defined by the user |
| | 919 | if interval.__class__.__name__ == 'Interval' : |
| | 920 | interval_out = interval |
| | 921 | else : |
| | 922 | interval_out = Interval(interval) |
| | 923 | else: |
| | 924 | if t_start == None and t_stop == None : |
| | 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]]) |
| | 941 | else : |
| | 942 | if t_start == None : |
| | 943 | try: |
| | 944 | t_stop = max(self.spike_times) |
| | 945 | except Exception: |
| | 946 | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| | 947 | t_stop = t_start+0.1 |
| | 948 | interval_out = Interval([[t_start, t_stop]]) |
| | 949 | if t_stop == None : |
| | 950 | if t_start.__class__.__name__ == 'float' or t_start.__class__.__name__ == 'int' : |
| | 951 | try: |
| | 952 | t_stop = max(self.spike_times) |
| | 953 | except Exception: |
| | 954 | print "Error in guessing t_stop (last spike), spikes may be empty !" |
| | 955 | t_stop = t_start+0.1 |
| | 956 | interval_out = Interval([[t_start, t_stop]]) |
| | 957 | else : |
| | 958 | if t_start.__class__.__name__ == 'Interval' : |
| | 959 | interval_out = t_start |
| | 960 | else : |
| | 961 | interval_out = Interval(t_start) |