Skip to content

Commit

Permalink
Merge pull request #1 from SilverLabUCL/initial-import
Browse files Browse the repository at this point in the history
Initial import of code from old repository
  • Loading branch information
pgleeson authored Apr 5, 2018
2 parents edb1300 + 0f3dd10 commit 22e7eac
Show file tree
Hide file tree
Showing 53 changed files with 14,774 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Project-specific ignore patterns
nwb_api_python/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -45,6 +48,7 @@ nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
Expand Down
Binary file added HDFView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017-2018 University College London

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
36 changes: 36 additions & 0 deletions MATLAB/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Matlab API for NWB use in the Silver Lab

Quick usage example:

``` matlab
nwb = NwbFile('Data/161215_15_34_21.nwb');
gui = DisplayVideos(nwb);
```

For examples of using the API from Matlab analysis scripts, see
https://github.com/SilverLabUCL/Data-Analysis-Hana/blob/hdf5-experiment/RunUsingNwb.m


## Automated Matlab testing

Tests are stored in the [tests](./tests) folder.
New tests are written as classes named like `TestSomething` within this folder.
It's probably easiest to start by copying the structure of an existing test.

Tests may be run locally,
and are also run automatically when pushing to the `master` branch or creating/updating pull requests.

### Local test running

Within Matlab, change to the `MATLAB/tests` folder (or add it to your path) then run
```
TestRunner()
```

### Automated tests

Results are displayed at http://jenkins.rc.ucl.ac.uk/ - ask Jonathan Cooper to give your GitHub account permissions to see this.
Tests of the master branch are at http://jenkins.rc.ucl.ac.uk/job/SilverLab-main/ and for pull requests under http://jenkins.rc.ucl.ac.uk/job/SilverLab-pull-request/.

You can also see results of specific builds linked from the pull requests / [commits](https://github.com/SilverLabUCL/SilverLab_NWBv1/commits/master) themselves.
Click on 'Console output' to see the actual test output (scrolling past a lot of test environment setup output!).
42 changes: 42 additions & 0 deletions MATLAB/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# A little Python script to set the Matlab paths correctly for using NWB

import argparse
import os
import re
import sys


def munge_path(path):
"""Convert `path` to a native system path so Matlab understands it."""
if sys.platform.startswith('win32'):
if re.match(r'/\s/.*', path):
path = os.path.realpath('{}:{}'.format(path[1], path[2:]))
elif sys.platform.startswith('cygwin'):
if re.match(r'/cygdrive/\s/.*', path):
path = os.path.realpath('{}:{}'.format(path[10], path[11:]))
return path


def setup_matlab(silverlab_path, nwb_api_path):
silverlab_path = munge_path(silverlab_path)
nwb_api_path = munge_path(os.path.join(nwb_api_path, 'matlab_bridge', 'matlab_bridge_api'))
print('Setting up Matlab with paths:')
print(' NWB API folder: {}'.format(nwb_api_path))
print(' Our Matlab folder: {}'.format(silverlab_path))
matlab_commands = [
"pyversion '{}';".format(sys.executable),
"addpath('{}');".format(nwb_api_path),
"addpath(genpath('{}'));".format(silverlab_path),
"success = savepath();",
"if success == 1; error('Failed to save Matlab path - set manually'); else quit; end;"
]
os.system('matlab -nosplash -nodesktop -r "{}"'.format(' '.join(matlab_commands)))


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Setup Matlab for NWB use.')
parser.add_argument('nwb_api_path',
help='path to the NWB API sources')
args = parser.parse_args()
our_matlab_path = os.path.join(os.path.dirname(__file__), 'source')
setup_matlab(our_matlab_path, args.nwb_api_path)
Loading

0 comments on commit 22e7eac

Please sign in to comment.