Beispiel #1
0
def get_sessionmaker(dbpath, echo=True, autocommit=True, **kw):
    from sqlalchemy import create_engine
    from sqlalchemy.orm import sessionmaker
    path = Path(dbpath)
    engine = create_engine('sqlite:///{}'.format(dbpath),
        echo=echo, **kw) if path.is_file() else recreate('', echo=echo)
    return sessionmaker(engine, autocommit=autocommit)
Beispiel #2
0
def import_ephys(filepath):
    """
    filepath = '/Volumes/Users/ht/dev/current/pacu/tmp/Jack/jzg1/day1/day1_000_007.txt'
    risings = import_ephys(filepath)
    """
    path = Path(filepath)
    if not path.is_file():
        raise NoRawDataError('Can not find raw data {!r}'.format(path.name))
    try:
        raw = np.genfromtxt(path.str,
                            delimiter=' ',
                            names=['TTL', 'ON'],
                            dtype='b')
        first_frame = find_nth_rising(raw['TTL'])
        data = raw[first_frame:]
        data['ON'][data['ON'] == 60] = 1
        edges = np.diff(data['TTL']) > 0
        ed_indices = np.where(edges)[0] + 1
        on_chunks = np.split(data['ON'], ed_indices)
        return np.array([chunk.any() for chunk in on_chunks])
    except Exception as e:
        raise RawDataParseError(e)
Beispiel #3
0
 def from_metadata_filename(cls, filename, meta):
     sbxpath = Path(filename).with_suffix('.sbx')
     if sbxpath.is_file():
         return cls(sbxpath.str, meta)