diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..eb9bfe6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 INCF-NIDASH + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5826074 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# nidmresults +A Python library to read and write [NIDM-Results](http://nidm.nidash.org/specs/nidm-results.html) packs. + +You are free to copy, modify, and distribute nidmresults with attribution under the terms of the MIT license. See the [LICENSE file](LICENSE.md) for details. + +## Install +nidmresults is distributed with [PyPI](https://pypi.org/project/nidmresults/), to install the latest relase you can use: +``` +pip install nidmresults +``` + +To work with the current developement version we recommend cloning this repository locally and then install using +``` +python setup.py install +``` + +## Example of usage + +Examples are available in the [examples](examples) folder. + +## Contributing +Thanks for your interest in contributing to nidmresults. All contributions are very welcome! If you experience difficulties using the library, please [open an issue](https://github.com/incf-nidash/nidmresults/issues/new) describing the problem. See the list of [current issues](https://github.com/incf-nidash/nidmresults/issues). + + diff --git a/examples/ex_read_nidm.py b/examples/ex_read_nidm.py new file mode 100644 index 0000000..5bebc4a --- /dev/null +++ b/examples/ex_read_nidm.py @@ -0,0 +1,26 @@ +# Example: reading a NIDM pack available on NeuroVault +import os +import json +import shutil +import tempfile +import nidmresults as nidm +import urllib.request + +# Download the NIDM pack locally +nidm_url = 'https://neurovault.org/collections/2210/fsl_default_130.nidm.zip' +nidmpack = "2210_fsl_default_130.nidm.zip" + +if not os.path.isfile(nidmpack): + print('Downloading ' + nidmpack) + urllib.request.urlretrieve(nidm_url, nidmpack) + +# Known issues with NIDM packs in collection 2210 +to_replace = { + ' \\ntask': '\\\\n task', + ';\n nidm_coordinateVectorInVoxels: "null"^^xsd:string .': + '.'} + +# Read the NIDM pack +nres = nidm.load(nidmpack, to_replace=to_replace) + +print(json.dumps(nres.get_info(), indent=4)) diff --git a/nidmresults/load.py b/nidmresults/load.py index b08778b..8969073 100644 --- a/nidmresults/load.py +++ b/nidmresults/load.py @@ -24,5 +24,7 @@ def load(filename, to_replace=dict()): raise Exception('Minimal json file: not handled yet') elif filename.endswith('.nidm.zip'): nidm = NIDMResults.load_from_pack(filename, to_replace=to_replace) + else: + raise Exception('Unhandled format ' + filename) return nidm diff --git a/setup.py b/setup.py index b2e771a..cff4386 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="nidmresults", - version="2.0.0", + version="2.0.1-dev1", author="Camille Maumet", author_email="c.m.j.maumet@warwick.ac.uk", description=(