Skip to content

Commit

Permalink
master: Merge branch 'release-0.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamltaylor committed Oct 13, 2017
2 parents 86d3f4d + a0e5375 commit 78eca9c
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .coverage
Original file line number Diff line number Diff line change
@@ -1 +1 @@
!coverage.py: This is a private format, don't read it directly!{"lines":{"C:\\Users\\taylora\\Dropbox\\janelia\\wavesurfer\\pywavesurfer\\pywavesurfer\\__init__.py":[1],"C:\\Users\\taylora\\Dropbox\\janelia\\wavesurfer\\pywavesurfer\\pywavesurfer\\test_ws.py":[1,2,3,4,5,6,9,30,44,54,64,80,96,112,127,148,168,185,203,219,240,258,274,292,313,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,31,32,33,34,35,36,38,39,40,41,45,46,47,48,49,50,51,55,56,57,58,59,60,61,65,66,67,68,72,73,74,75,76,77,81,82,83,84,88,89,90,91,92,93,97,98,99,100,104,105,106,107,108,109,113,114,115,116,119,120,121,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,169,170,171,172,173,174,175,176,177,178,179,181,186,187,188,189,190,191,192,193,194,195,196,197,199,204,205,206,207,208,209,211,212,213,214,215,216,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,259,260,261,262,263,264,265,266,267,268,269,270,271,275,276,277,278,279,280,281,282,283,285,287,288,289,293,294,295,296,297,298,299,300,301,304,305,306,307,308,309,310,314,315,316,317,318,319,320,321,322,325,326,327,328,329,330,331],"C:\\Users\\taylora\\Dropbox\\janelia\\wavesurfer\\pywavesurfer\\pywavesurfer\\ws.py":[1,2,3,4,7,117,136,156,180,15,19,20,24,25,118,120,122,123,124,125,139,141,148,151,153,126,127,128,129,133,29,30,31,32,36,57,58,67,68,69,71,77,78,80,86,89,90,91,97,98,100,103,104,109,110,111,171,172,173,174,175,176,177,112,114,16,21,105,106,107,181,182,38,39,40,41,42,43,44,45,47,48,49,50,51,52,53,60,61,62,66,35,65,74,83,93],"C:\\Users\\taylora\\Dropbox\\janelia\\wavesurfer\\pywavesurfer\\pywavesurfer\\run_tests.py":[]}}
!coverage.py: This is a private format, don't read it directly!{"lines":{"C:\\Users\\moharb\\Documents\\Repos\\PyWaveSurfer\\pywavesurfer\\__init__.py":[1],"C:\\Users\\moharb\\Documents\\Repos\\PyWaveSurfer\\pywavesurfer\\test_ws.py":[1,2,3,4,5,6,9,30,44,54,64,80,96,112,127,148,168,185,203,219,240,258,274,292,313,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,31,32,33,34,35,36,38,39,40,41,45,46,47,48,49,50,51,55,56,57,58,59,60,61,65,66,67,68,72,73,74,75,76,77,81,82,83,84,88,89,90,91,92,93,97,98,99,100,104,105,106,107,108,109,113,114,115,116,119,120,121,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,169,170,171,172,173,174,175,176,177,178,179,181,186,187,188,189,190,191,192,193,194,195,196,197,199,204,205,206,207,208,209,211,212,213,214,215,216,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,259,260,261,262,263,264,265,266,267,268,269,270,271,275,276,277,278,279,280,281,282,283,285,287,288,289,293,294,295,296,297,298,299,300,301,304,305,306,307,308,309,310,314,315,316,317,318,319,320,321,322,325,326,327,328,329,330,331],"C:\\Users\\moharb\\Documents\\Repos\\PyWaveSurfer\\pywavesurfer\\ws.py":[1,2,3,4,7,117,136,156,180,15,19,20,24,25,118,120,122,123,124,125,139,141,148,151,153,126,127,128,129,133,29,30,31,32,36,57,58,67,68,69,71,77,78,80,86,89,90,91,97,98,100,103,104,109,110,111,171,172,173,174,175,176,177,112,114,16,21,105,106,107,181,182,38,39,40,41,42,43,44,45,47,48,49,50,51,52,53,60,61,62,66,35,65,74,83,93],"C:\\Users\\moharb\\Documents\\Repos\\PyWaveSurfer\\pywavesurfer\\run_tests.py":[]}}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ launch_satellite_engine/bin/launch_satellite_engine.exe
*.lib
*.cache
*.pyc

\.coverage

\.idea/


build/
dist/
pywavesurfer.egg-info/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ install:
- pip install -r requirements-dev.txt

script:
- py.test -s -v --cov=pywavesurfer --pep8
- py.test -s -v --cov-config .coveragerc --cov=pywavesurfer --pep8

after_success:
- coveralls
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include *.txt
include *.rst
23 changes: 21 additions & 2 deletions README.txt → README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
PyWaveSurfer
============

PyWaveSurfer is a Python package for reading WaveSurfer data into
Python.
PyWaveSurfer is a Python package for reading data acquired using WaveSurfer.


See the `official site <http://wavesurfer.janelia.org/>`_ for more information about WaveSurfer.


Example usage
-------------

.. code-block:: python
from pywavesurfer import ws
# to get analog channels scaled in float64 :
data_as_dict = ws.loadDataFile(filename='path/to/file.h5', format_string='double' )
# to get analog channels scaled in float32:
data_as_dict = ws.loadDataFile(filename='path/to/file.h5', format_string='single' )
# to get the raw analog channels in int16:
data_as_dict = ws.loadDataFile(filename='path/to/file.h5', format_string='raw' )
Description of the content can be found in the documentation
`here <http://wavesurfer.janelia.org/manual/index.html#reading-acquired-data>`_.

Copyright
---------

Expand Down
File renamed without changes.
4 changes: 0 additions & 4 deletions pywavesurfer/run_tests.py

This file was deleted.

18 changes: 9 additions & 9 deletions pywavesurfer/ws.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import math
import numpy
import numpy as np
import h5py


Expand Down Expand Up @@ -41,15 +41,15 @@ def loadDataFile(filename, format_string='double'):
nominal_n_timebase_ticks_per_sample): # should use the python round, not numpy round
actual_acquisition_sample_rate = 100.0e6 / math.floor(
nominal_n_timebase_ticks_per_sample) # sic: the boards floor() for acq, but round() for stim
header["Acquisition"]["SampleRate"] = numpy.array(actual_acquisition_sample_rate)
header["Acquisition"]["SampleRate"] = np.array(actual_acquisition_sample_rate)
data_file_as_dict["header"] = header
# Fix the stimulation sample rate, if needed
nominal_stimulation_sample_rate = float(header["Stimulation"]["SampleRate"])
nominal_n_timebase_ticks_per_sample = 100.0e6 / nominal_stimulation_sample_rate
if nominal_n_timebase_ticks_per_sample != round(nominal_n_timebase_ticks_per_sample):
actual_stimulation_sample_rate = 100.0e6 / round(
nominal_n_timebase_ticks_per_sample) # sic: the boards floor() for acq, but round() for stim
header["Stimulation"]["SampleRate"] = numpy.array(actual_stimulation_sample_rate)
header["Stimulation"]["SampleRate"] = np.array(actual_stimulation_sample_rate)
data_file_as_dict["header"] = header

# If needed, use the analog scaling coefficients and scales to convert the
Expand Down Expand Up @@ -170,13 +170,13 @@ def scaled_double_analog_data_from_raw(data_as_ADC_counts, channel_scales, scali

inverse_channel_scales = 1.0 / channel_scales # if some channel scales are zero, this will lead to nans and/or infs
n_channels = channel_scales.size
scaled_data = numpy.empty(data_as_ADC_counts.shape)
scaled_data = np.empty(data_as_ADC_counts.shape)
for i in range(0, n_channels):
scaled_data[i, :] = inverse_channel_scales[i] * numpy.polyval(numpy.flipud(scaling_coefficients[i, :]),
data_as_ADC_counts[i, :])
scaled_data[i, :] = inverse_channel_scales[i] * np.polyval(np.flipud(scaling_coefficients[i, :]),
data_as_ADC_counts[i, :])
return scaled_data


def scaled_single_analog_data_from_raw(dataAsADCCounts, channelScales, scalingCoefficients):
scaledData = scaled_double_analog_data_from_raw(dataAsADCCounts, channelScales, scalingCoefficients)
return scaledData.astype('single')
def scaled_single_analog_data_from_raw(data_as_ADC_counts, channel_scales, scaling_coefficients):
scaled_data = scaled_double_analog_data_from_raw(data_as_ADC_counts, channel_scales, scaling_coefficients)
return scaled_data.astype('single')
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from setuptools import setup, find_packages
from setuptools import setup
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))


with open(path.join(here, 'README.txt'), encoding='utf-8') as f:
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()

with open(path.join(here, 'requirements.txt'), encoding='utf-8') as f:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added tests/no_h5.h6
Empty file.
4 changes: 4 additions & 0 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import pytest


pytest.main(['--pep8'])
File renamed without changes.
2 changes: 1 addition & 1 deletion pywavesurfer/test_ws.py → tests/test_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import math
import numpy as np
import pytest
from . import ws
from pywavesurfer import ws


def test_loading_file():
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 78eca9c

Please sign in to comment.