Skip to content

Conversation

@tstenner
Copy link
Contributor

As a precursor for the chunk7 reader, use the same format ordering as in lsl and read in the native datatype (line 293)

@tstenner tstenner requested a review from cboulay April 13, 2019 11:32
@cbrnr
Copy link
Contributor

cbrnr commented Apr 16, 2019

Does this also do what sccn/xdf#38 proposes? If not, it would be nice if you could integrate that into this PR.

@tstenner
Copy link
Contributor Author

Does this also do what sccn/xdf#38 proposes?

Yes, I didn't see that but it does everything sccn/xdf#38 does (and a tiny bit more). Plus, it's already in the correct repository :-)

@cbrnr
Copy link
Contributor

cbrnr commented Apr 16, 2019

OK great, that's what I wanted to know - so we can safely close sccn/xdf#38 once this gets merged.

values[k, :] = struct.unpack(temp[StreamId].structfmt, raw)
# no fromfile(), see
# https://github.com/numpy/numpy/issues/13319
values[k, :] = np.frombuffer(raw,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frombuffer doesn't need a character format string and is about 30% faster in one of my tests

@cbrnr
Copy link
Contributor

cbrnr commented Apr 18, 2019

We really need to set up a CI service. I don't have the time to verify if these changes (especially the switch from struct.unpack to np.frombuffer) did not introduce regressions, but by just looking at the code it LGTM. @cboulay feel free to do more checks and/or merge.

@tstenner
Copy link
Contributor Author

I created an example file repository with a tiny (2kB) example file.

It's not a replacement for a CI, but the most basic test (python -c "import pyxdf; print(pyxdf.load_xdf('../example-files/minimal.xdf'));") produces the sample output except for the changed dtype in the output time_series:

([{'info': defaultdict(<class 'list'>, {'name': ['SendDataC'], 'type': ['EEG'], 'channel_count': ['3'], 'nominal_srate': ['10'], 'channel_format': ['int16'], 'created_at': ['50942.723319709003'], 'desc': [None], 'uid': ['xdfwriter_11_int'], 'effective_srate': 10.000000000000021}), 'footer': {'info': defaultdict(<class 'list'>, {'writer': ['LabRecorder xdfwriter'], 'first_timestamp': ['5.1'], 'last_timestamp': ['5.9'], 'sample_count': ['9'], 'clock_offsets': [defaultdict(<class 'list'>, {'offset': [defaultdict(<class 'list'>, {'time': ['50979.76'], 'value': ['-.01']}), defaultdict(<class 'list'>, {'time': ['50979.86'], 'value': ['-.02']})]})]})}, 'time_series': array([[192, 255, 238],
       [ 12,  22,  32],
       [ 13,  23,  33],
       [ 14,  24,  34],
       [ 15,  25,  35],
       [ 12,  22,  32],
       [ 13,  23,  33],
       [ 14,  24,  34],
       [ 15,  25,  35]], dtype=int16), 'time_stamps': array([5. , 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8])}, {'info': defaultdict(<class 'list'>, {'name': ['SendDataString'], 'type': ['StringMarker'], 'channel_count': ['1'], 'nominal_srate': ['10'], 'channel_format': ['string'], 'created_at': ['50942.723319709003'], 'desc': [None], 'uid': ['xdfwriter_11_int'], 'effective_srate': 10.00000000000004}), 'footer': {'info': defaultdict(<class 'list'>, {'writer': ['LabRecorder xdfwriter'], 'first_timestamp': ['5.1'], 'last_timestamp': ['5.9'], 'sample_count': ['9'], 'clock_offsets': [defaultdict(<class 'list'>, {'offset': [defaultdict(<class 'list'>, {'time': ['50979.76'], 'value': ['-.01']}), defaultdict(<class 'list'>, {'time': ['50979.86'], 'value': ['-.02']})]})]})}, 'time_series': [['<?xml version="1.0"?><info><writer>LabRecorder xdfwriter</writer><first_timestamp>5.1</first_timestamp><last_timestamp>5.9</last_timestamp><sample_count>9</sample_count><clock_offsets><offset><time>50979.76</time><value>-.01</value></offset><offset><time>50979.86</time><value>-.02</value></offset></clock_offsets></info>'], ['Hello'], ['World'], ['from'], ['LSL'], ['Hello'], ['World'], ['from'], ['LSL']], 'time_stamps': array([5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9])}], {'info': defaultdict(<class 'list'>, {'version': ['1.0']})})

@cboulay cboulay merged commit 54ff31e into master Apr 18, 2019
@cbrnr cbrnr deleted the fmtindex branch September 24, 2019 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants