# Path: neurotools/spike2/sonpy/son.py
# def _get_block_headers(fhead, chanInfo):
# 	def __init__(self, filename):
# 	def __del__(self):
# 	def chan_list(self):
# 	def return_chan_list(self):
# 	def _ticks_to_seconds(self, timestamp, timeunits):
# 	def __repr__(self):
# 	def __init__(self, fhead, channel):
# 	def type(self):
# 	def __repr__(self):
# 	def __init__(self, channel, filename):
# 	def __repr__(self):
# 	def data(self, start=None, stop=None, timeunits='seconds', as_float=True):
# 	def type(self):
# 	def __del__(self):
# 	def _time_to_blocks(self,start, stop):
# 	def __init__(self, filename):
# 	def __repr__(self):
# 	def get_channel(self, channel):
# 	def chan_list(self):
# class FileHeader:
# class _ChannelInfo:
# class Channel:
# class File:


import numpy
import neurotools.signals as signals
from neurotools.spike2.sonpy import son

"""
Jens Kremkow
INCM-CNRS, Marseille, France
ALUF, Freiburg, Germany
2008
"""


def load(filename,channels=None,start=None,stop=None):
    if channels is None:
        fileheader = son.FileHeader(filename)
        channels = fileheader.return_chan_list()
        
    if len(channels) is 1:
        return load_channel(filename,channel=channels[0],start=None,stop=None)
    
    channel_obj = {}
    for chan in channels:
        try:
            channel_obj[chan] = load_channel(filename,channel=chan,start=None,stop=None)
        except ValueError:
            print 'channel ',chan,' could not be read'
    return channel_obj

def load_channel(filename,channel=1,start=None,stop=None):

# Path: neurotools/spike2/sonpy/son.py
# def _get_block_headers(fhead, chanInfo):
# 	def __init__(self, filename):
# 	def __del__(self):
# 	def chan_list(self):
# 	def return_chan_list(self):
# 	def _ticks_to_seconds(self, timestamp, timeunits):
# 	def __repr__(self):
# 	def __init__(self, fhead, channel):
# 	def type(self):
# 	def __repr__(self):
# 	def __init__(self, channel, filename):
# 	def __repr__(self):
# 	def data(self, start=None, stop=None, timeunits='seconds', as_float=True):
# 	def type(self):
# 	def __del__(self):
# 	def _time_to_blocks(self,start, stop):
# 	def __init__(self, filename):
# 	def __repr__(self):
# 	def get_channel(self, channel):
# 	def chan_list(self):
# class FileHeader:
# class _ChannelInfo:
# class Channel:
# class File:


# Path: neurotools/spike2/spike2channels.py
import numpy
import neurotools.signals as signals
from neurotools.spike2.sonpy import son


"""
Jens Kremkow
INCM-CNRS, Marseille, France
ALUF, Freiburg, Germany
2008
"""


def load(filename,channels=None,start=None,stop=None):
    if channels is None:
        fileheader = son.FileHeader(filename)
        channels = fileheader.return_chan_list()
        
    if len(channels) is 1:
        return load_channel(filename,channel=channels[0],start=None,stop=None)
    
    channel_obj = {}
    for chan in channels:
        try:
            channel_obj[chan] = load_channel(filename,channel=chan,start=None,stop=None)
        except ValueError:
            print 'channel ',chan,' could not be read'
    return channel_obj

def load_channel(filename,channel=1,start=None,stop=None):

    chan = son.Channel(channel,filename)