Commit 8308bfa4 authored by Ronny Eichler's avatar Ronny Eichler
Browse files

Python 3 ready on Anaconda

parent c1fe1b74
......@@ -6,15 +6,15 @@ import sys
import cmd
import logging
from lib.constants import LOG_LEVEL_VERBOSE
import lib.tools
from dataman_cli import DataMan
from dataman.lib.constants import LOG_LEVEL_VERBOSE
from dataman.dataman_cli import DataMan
__version__ = 0.01
NO_EXIT_CONFIRMATION = True
LOG_LEVEL = logging.INFO
if __name__ == "__main__":
def main():
# Command line parsing
import argparse
parser = argparse.ArgumentParser(prog="DataMan")
......@@ -68,3 +68,7 @@ if __name__ == "__main__":
else:
DataMan().onecmd(' '.join(sys.argv[1:]))
if __name__ == "__main__":
main()
......@@ -5,15 +5,14 @@ from __future__ import print_function
import sys
import logging
import cmd
import lib.tools
from lib.constants import LOG_LEVEL_VERBOSE
from dataman.lib.constants import LOG_LEVEL_VERBOSE
class DataMan(cmd.Cmd):
"""Command line tool for quick data documentation."""
prompt = "dm> "
intro = "Data Manager\n --Ronny's way of avoiding having to stare at spreadsheets."
intro = "Data Manager\n"
def preloop(self):
self.log = logging.getLogger(__name__)
......@@ -32,17 +31,17 @@ class DataMan(cmd.Cmd):
def do_ls(self, path):
if not len(path):
path = '.'
import lib.dirstats as ds
import dataman.lib.dirstats as ds
ds.print_table(ds.gather(path))
def do_stats(self, path):
if not len(path):
path = '.'
import lib.dirstats as ds
import dataman.lib.dirstats as ds
ds.print_table(ds.gather(path))
def do_vis(self, path):
from vis import vis
from dataman.vis import vis
vis.run(target=path)
def do_exit(self, line):
......
......@@ -2,13 +2,11 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import tools
from tools import fext, dir_content
import os
import sys
from termcolor import colored
import open_ephys
import kwik
from . import tools, open_ephys, kwik
from .tools import fext, dir_content
EXT_VIDEO = ['.avi', '.mp4', '.mkv', '.wmv']
EXT_SOUND = ['.wav', '.mp3', '.snd', '.wma']
......
......@@ -4,7 +4,7 @@
from __future__ import print_function
import os
import xml.etree.ElementTree as etree
from tools import fext, dir_content
from .tools import fext, dir_content
def detect(root, dirs=None, files=None):
for f in files:
......
......@@ -4,7 +4,7 @@
from __future__ import print_function
import os
import xml.etree.ElementTree as etree
from tools import fext, dir_content
from .tools import fext, dir_content
def detect(root=None, dirs=None, files=None):
"""Checks for existence of an open ephys formatted data set in the root directory.
......
......@@ -3,7 +3,6 @@
from __future__ import print_function
import os
from os.path import join, getsize
from termcolor import colored
import re
......
......@@ -12,6 +12,7 @@ Inspired by https://github.com/belevtsoff/rdaclient.py
"""
from __future__ import print_function
from multiprocessing import Array
import ctypes as c
import logging
......@@ -98,7 +99,7 @@ class Buffer(object):
nptype = datatypes.get_type(hdr.dataType)
bufOffset = c.sizeof(hdr)
bufFlatSize = hdr.bufSizeBytes / np.dtype(nptype).itemsize
bufFlatSize = hdr.bufSizeBytes // np.dtype(nptype).itemsize
# create numpy view object pointing to the raw array
self.__raw = raw
......@@ -198,8 +199,7 @@ class datatypes():
ndtype : string
numpy datatype (e.g. 'float32')
"""
idx = cls.types.values().index(ndtype)
return cls.types.keys()[idx]
return next(key for key, value in cls.types.items() if value == ndtype)
@classmethod
def get_type(cls, code):
......@@ -273,11 +273,11 @@ if __name__ == '__main__':
buf1.put_data(np.array([[1, 2], [3, 4]]))
buf2.put_data(np.array([[5, 6], [7, 8]]), start=2)
print buf1
print buf2
print(buf1)
print(buf2)
dat = buf2.get_data(0, 4)
dat[0, 0] = 100
print buf1
print buf2
print(buf1)
print(buf2)
......@@ -8,6 +8,7 @@ Created on Sep 23, 2015 18:53
File reader
"""
from __future__ import print_function
import numpy as np
import re
......@@ -51,7 +52,7 @@ def read_header(filename):
def read_segment(filename, offset, count, dtype):
"""Read segment of a file from [offset] for [count]x[dtype]"""
with open(filename, 'rb') as fid:
fid.seek(offset)
fid.seek(int(offset))
segment = np.fromfile(fid, dtype=dtype, count=count)
return segment
......@@ -80,8 +81,9 @@ def read_record(filename, offset=0, count=30, dtype=DATA_DT):
if __name__ == "__main__":
print read_header('data/2014-10-30_16-07-29/106_CH1.continuous')
print read_segment('data/2014-10-30_16-07-29/106_CH1.continuous', offset=SIZE_HEADER)['samples'].ravel()[0]
pass
# print(read_header('data/2014-10-30_16-07-29/106_CH1.continuous'))
# print(read_segment('data/2014-10-30_16-07-29/106_CH1.continuous', offset=SIZE_HEADER)['samples'].ravel()[0])
......
......@@ -7,7 +7,8 @@
"""
Multiple real-time digital signals with GLSL-based clipping.
"""
from __future__ import division
from __future__ import division, print_function
import logging
import os
from vispy import gloo
......@@ -16,13 +17,13 @@ from vispy import util
import numpy as np
import math
from reader import read_record, read_header
from .reader import read_record, read_header
# Dimensions of plot segment/signals
n_rows = 16
n_cols = 4
n_signals = n_rows*n_cols
n_samples = 3e4
n_samples = int(3e4)
# Buffer to store all the pre-loaded signals
buf = np.zeros((n_signals, n_samples), dtype=np.float32)
......
......@@ -10,9 +10,10 @@ config = {
'download_url': '',
'author_email': 'ronny.eichler@gmail.com',
'version': '0.0.1',
'install_requires': ['nose', 'termcolor'],
'install_requires': ['nose', 'termcolor', 'vispy'],
'packages': ['dataman'],
'scripts': [],
'entry_points': """[console_scripts]
dm=dataman.dataman:main""",
'name': 'dataman'
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment