From 7c55d9c10115544bc4aaea6da0b707c24d37f1e2 Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 15:05:33 +0000 Subject: [PATCH 01/13] Fixes the ugly bug that was making that our restults were wrong --- brain_average.csv | 2 +- brain_sample.csv | 40 ++++++++++++++++++++-------------------- sagittal_brain.py | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/brain_average.csv b/brain_average.csv index d30573e..af02e18 100644 --- a/brain_average.csv +++ b/brain_average.csv @@ -1 +1 @@ -10.5,11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,21.5,22.5,23.5,24.5,25.5,26.5,27.5,28.5,29.5 +0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0 diff --git a/brain_sample.csv b/brain_sample.csv index 7b809c6..d0b9035 100644 --- a/brain_sample.csv +++ b/brain_sample.csv @@ -1,20 +1,20 @@ -1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 -2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 -3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 -4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 -5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24 -6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25 -7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 -8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27 -9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28 -10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 -11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 -12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 -13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32 -14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33 -15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34 -16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35 -17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36 -18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37 -19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38 -20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 diff --git a/sagittal_brain.py b/sagittal_brain.py index c257fc9..27a4120 100644 --- a/sagittal_brain.py +++ b/sagittal_brain.py @@ -16,7 +16,7 @@ def run_averages(file_input='brain_sample.csv', file_output='brain_average.csv') # Calculates the averages through the sagittal/horizontal planes # and makes it as a row vector - averages = planes.mean(axis=0)[np.newaxis, :] + averages = planes.mean(axis=1)[np.newaxis, :] # write it out on my file np.savetxt(file_output, averages, fmt='%.1f', delimiter=',') From ffddc726f9f27cd3c97972dd218c0468b6cb80d4 Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 15:11:37 +0000 Subject: [PATCH 02/13] Adds a gitignore file for python artefacts Created from https://gitignore.io --- .gitignore | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e19e61 --- /dev/null +++ b/.gitignore @@ -0,0 +1,109 @@ +# Created by https://www.gitignore.io/api/python +# Edit at https://www.gitignore.io/?templates=python + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# End of https://www.gitignore.io/api/python From afc83f12f0fc3c7bc37bdc8e8421935f80eaf5dd Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 15:14:58 +0000 Subject: [PATCH 03/13] Adds the test we used during `git bisect` as a test function --- tests/test_sagital_brain.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test_sagital_brain.py diff --git a/tests/test_sagital_brain.py b/tests/test_sagital_brain.py new file mode 100644 index 0000000..55034a0 --- /dev/null +++ b/tests/test_sagital_brain.py @@ -0,0 +1,20 @@ +import numpy as np +import subprocess + + +def test_average(): + # Creates input file + data_input = np.zeros((20, 20)) + data_input[-1, :] = 1 + # The expeted result is all zeros, except the last one, it should be 1 + expected = np.zeros(20) + expected[-1] = 1 + + np.savetxt("brain_sample.csv", data_input, fmt='%d', delimiter=',') + + # run python program + subprocess.run(["python", "sagital_brain.py"]) + + # Check result + result = np.loadtxt("brain_average.csv", delimiter=',') + np.testing.assert_array_equal(result, expected) From 6662d8ab31ed6ccee3d9cffc571127f68580ebae Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 15:21:52 +0000 Subject: [PATCH 04/13] Moved files in a "package like" structure. Note, subprocess line needs to change, otherwise you may not see if it's failing unless you add `check=True`. --- .../sagital_brain.py | 0 sagittal_average/__init__.py | 0 sagittal_average/sagittal_brain.py | 34 +++++++++++++++++++ sagittal_average/tests/__init__.py | 0 .../tests}/test_sagital_brain.py | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) rename sagittal_brain.py => sagital_average/sagital_brain.py (100%) create mode 100644 sagittal_average/__init__.py create mode 100644 sagittal_average/sagittal_brain.py create mode 100644 sagittal_average/tests/__init__.py rename {tests => sagittal_average/tests}/test_sagital_brain.py (86%) diff --git a/sagittal_brain.py b/sagital_average/sagital_brain.py similarity index 100% rename from sagittal_brain.py rename to sagital_average/sagital_brain.py diff --git a/sagittal_average/__init__.py b/sagittal_average/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sagittal_average/sagittal_brain.py b/sagittal_average/sagittal_brain.py new file mode 100644 index 0000000..27a4120 --- /dev/null +++ b/sagittal_average/sagittal_brain.py @@ -0,0 +1,34 @@ +from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter + +import numpy as np + + +def run_averages(file_input='brain_sample.csv', file_output='brain_average.csv'): + """ + Calculates the average through the coronal planes + The input file should has as many columns as coronal planes + The rows are intersections of the sagittal/horizontal planes + + The result is the average for each sagittal/horizontal plane (rows) + """ + # Open the file to analyse + planes = np.loadtxt(file_input, dtype=int, delimiter=',') + + # Calculates the averages through the sagittal/horizontal planes + # and makes it as a row vector + averages = planes.mean(axis=1)[np.newaxis, :] + + # write it out on my file + np.savetxt(file_output, averages, fmt='%.1f', delimiter=',') + + +if __name__ == "__main__": + parser = ArgumentParser(description="Calculates the average for each sagittal-horizontal plane.", + formatter_class=ArgumentDefaultsHelpFormatter) + parser.add_argument('file_input', nargs='?', default="brain_sample.csv", + help="Input CSV file with the results from scikit-brain binning algorithm.") + parser.add_argument('--file_output', '-o', default="brain_average.csv", + help="Name of the output CSV file.") + arguments = parser.parse_args() + + run_averages(arguments.file_input, arguments.file_output) diff --git a/sagittal_average/tests/__init__.py b/sagittal_average/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_sagital_brain.py b/sagittal_average/tests/test_sagital_brain.py similarity index 86% rename from tests/test_sagital_brain.py rename to sagittal_average/tests/test_sagital_brain.py index 55034a0..70bc09e 100644 --- a/tests/test_sagital_brain.py +++ b/sagittal_average/tests/test_sagital_brain.py @@ -13,7 +13,7 @@ def test_average(): np.savetxt("brain_sample.csv", data_input, fmt='%d', delimiter=',') # run python program - subprocess.run(["python", "sagital_brain.py"]) + subprocess.run(["python", "sagital_average/sagital_brain.py"], check=True) # Check result result = np.loadtxt("brain_average.csv", delimiter=',') From 893cac9e853e01d472fb30fad59b23ae5d60a6fb Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 15:32:59 +0000 Subject: [PATCH 05/13] Moves the test data to the test directory and changes the test to call the function --- .../tests/brain_average.csv | 0 .../tests/brain_sample.csv | 0 sagittal_average/tests/test_sagital_brain.py | 20 ---------------- sagittal_average/tests/test_sagittal_brain.py | 24 +++++++++++++++++++ 4 files changed, 24 insertions(+), 20 deletions(-) rename brain_average.csv => sagittal_average/tests/brain_average.csv (100%) rename brain_sample.csv => sagittal_average/tests/brain_sample.csv (100%) delete mode 100644 sagittal_average/tests/test_sagital_brain.py create mode 100644 sagittal_average/tests/test_sagittal_brain.py diff --git a/brain_average.csv b/sagittal_average/tests/brain_average.csv similarity index 100% rename from brain_average.csv rename to sagittal_average/tests/brain_average.csv diff --git a/brain_sample.csv b/sagittal_average/tests/brain_sample.csv similarity index 100% rename from brain_sample.csv rename to sagittal_average/tests/brain_sample.csv diff --git a/sagittal_average/tests/test_sagital_brain.py b/sagittal_average/tests/test_sagital_brain.py deleted file mode 100644 index 70bc09e..0000000 --- a/sagittal_average/tests/test_sagital_brain.py +++ /dev/null @@ -1,20 +0,0 @@ -import numpy as np -import subprocess - - -def test_average(): - # Creates input file - data_input = np.zeros((20, 20)) - data_input[-1, :] = 1 - # The expeted result is all zeros, except the last one, it should be 1 - expected = np.zeros(20) - expected[-1] = 1 - - np.savetxt("brain_sample.csv", data_input, fmt='%d', delimiter=',') - - # run python program - subprocess.run(["python", "sagital_average/sagital_brain.py"], check=True) - - # Check result - result = np.loadtxt("brain_average.csv", delimiter=',') - np.testing.assert_array_equal(result, expected) diff --git a/sagittal_average/tests/test_sagittal_brain.py b/sagittal_average/tests/test_sagittal_brain.py new file mode 100644 index 0000000..2f27811 --- /dev/null +++ b/sagittal_average/tests/test_sagittal_brain.py @@ -0,0 +1,24 @@ + +from pathlib import Path +import numpy as np +from ..sagittal_brain import run_averages + +TEST_DIR = Path(__file__).parent + +def test_average(): + # Creates input file + data_input = np.zeros((20, 20)) + data_input[-1, :] = 1 + # The expeted result is all zeros, except the last one, it should be 1 + expected = np.zeros(20) + expected[-1] = 1 + + np.savetxt(TEST_DIR / "brain_sample.csv", data_input, fmt='%d', delimiter=',') + + # run python program + run_averages(file_input=TEST_DIR / "brain_sample.csv", + file_output=TEST_DIR / "brain_average.csv") + + # Check result + result = np.loadtxt(TEST_DIR / "brain_average.csv", delimiter=',') + np.testing.assert_array_equal(result, expected) From 8d300809e1ebb327abff5876d9b702dc345ab695 Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 15:36:09 +0000 Subject: [PATCH 06/13] Adds a setup file to enable installation of the package --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..528e634 --- /dev/null +++ b/setup.py @@ -0,0 +1,7 @@ +from setuptools import setup, find_packages + +setup( + name="sagital_average", + version="0.1.0", + packages=find_packages(exclude=['*tests']), +) From c47caa023adc8bd00c842fc7c951034fe7aac4ff Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 15:45:04 +0000 Subject: [PATCH 07/13] Moves the executing script as a shell command accessible from anywhere --- sagital_average/sagital_brain.py | 34 ------------------------------ sagittal_average/command.py | 14 ++++++++++++ sagittal_average/sagittal_brain.py | 12 ----------- setup.py | 6 +++++- 4 files changed, 19 insertions(+), 47 deletions(-) delete mode 100644 sagital_average/sagital_brain.py create mode 100644 sagittal_average/command.py diff --git a/sagital_average/sagital_brain.py b/sagital_average/sagital_brain.py deleted file mode 100644 index 27a4120..0000000 --- a/sagital_average/sagital_brain.py +++ /dev/null @@ -1,34 +0,0 @@ -from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter - -import numpy as np - - -def run_averages(file_input='brain_sample.csv', file_output='brain_average.csv'): - """ - Calculates the average through the coronal planes - The input file should has as many columns as coronal planes - The rows are intersections of the sagittal/horizontal planes - - The result is the average for each sagittal/horizontal plane (rows) - """ - # Open the file to analyse - planes = np.loadtxt(file_input, dtype=int, delimiter=',') - - # Calculates the averages through the sagittal/horizontal planes - # and makes it as a row vector - averages = planes.mean(axis=1)[np.newaxis, :] - - # write it out on my file - np.savetxt(file_output, averages, fmt='%.1f', delimiter=',') - - -if __name__ == "__main__": - parser = ArgumentParser(description="Calculates the average for each sagittal-horizontal plane.", - formatter_class=ArgumentDefaultsHelpFormatter) - parser.add_argument('file_input', nargs='?', default="brain_sample.csv", - help="Input CSV file with the results from scikit-brain binning algorithm.") - parser.add_argument('--file_output', '-o', default="brain_average.csv", - help="Name of the output CSV file.") - arguments = parser.parse_args() - - run_averages(arguments.file_input, arguments.file_output) diff --git a/sagittal_average/command.py b/sagittal_average/command.py new file mode 100644 index 0000000..7beb25d --- /dev/null +++ b/sagittal_average/command.py @@ -0,0 +1,14 @@ +from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter + +from .sagittal_brain import run_averages + +def process(): + parser = ArgumentParser(description="Calculates the average for each sagittal-horizontal plane.", + formatter_class=ArgumentDefaultsHelpFormatter) + parser.add_argument('file_input', nargs='?', default="brain_sample.csv", + help="Input CSV file with the results from scikit-brain binning algorithm.") + parser.add_argument('--file_output', '-o', default="brain_average.csv", + help="Name of the output CSV file.") + arguments = parser.parse_args() + + run_averages(arguments.file_input, arguments.file_output) diff --git a/sagittal_average/sagittal_brain.py b/sagittal_average/sagittal_brain.py index 27a4120..981e7f6 100644 --- a/sagittal_average/sagittal_brain.py +++ b/sagittal_average/sagittal_brain.py @@ -20,15 +20,3 @@ def run_averages(file_input='brain_sample.csv', file_output='brain_average.csv') # write it out on my file np.savetxt(file_output, averages, fmt='%.1f', delimiter=',') - - -if __name__ == "__main__": - parser = ArgumentParser(description="Calculates the average for each sagittal-horizontal plane.", - formatter_class=ArgumentDefaultsHelpFormatter) - parser.add_argument('file_input', nargs='?', default="brain_sample.csv", - help="Input CSV file with the results from scikit-brain binning algorithm.") - parser.add_argument('--file_output', '-o', default="brain_average.csv", - help="Name of the output CSV file.") - arguments = parser.parse_args() - - run_averages(arguments.file_input, arguments.file_output) diff --git a/setup.py b/setup.py index 528e634..492141f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,11 @@ from setuptools import setup, find_packages setup( - name="sagital_average", + name="sagittal_average", version="0.1.0", packages=find_packages(exclude=['*tests']), + entry_points={ + 'console_scripts': [ + 'sagverage = sagittal_average.command:process' + ]}, ) From 3d273d8fabe05cdb4e9c9bae6fd8177eda86f8d7 Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 15:46:46 +0000 Subject: [PATCH 08/13] Adds dependencies for this library --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 492141f..440d750 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ name="sagittal_average", version="0.1.0", packages=find_packages(exclude=['*tests']), + install_requires=['numpy'], entry_points={ 'console_scripts': [ 'sagverage = sagittal_average.command:process' From 1c2d9bda376ff56c3611aedcfe09cdccb86577b9 Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 18:28:32 +0000 Subject: [PATCH 09/13] Adds the three important files --- CITATION.md | 18 ++++++++++++++++ LICENSE | 29 ++++++++++++++++++++++++++ README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 CITATION.md create mode 100644 LICENSE create mode 100644 README.md diff --git a/CITATION.md b/CITATION.md new file mode 100644 index 0000000..ee26767 --- /dev/null +++ b/CITATION.md @@ -0,0 +1,18 @@ + +To acknowledge this repository please cite our paper + +```bibtex +@article{Charlene2019, + title = {Reproducible {{Brain}}}, + volume = {12}, + number = {5}, + journal = {Brain Technologies \& Signals}, + doi = {10/v5dar2}, + author = {{Charlene Bultoc {and} Fulanito Shrug}}, + month = sep, + year = {2019}, + pages = {8-13}, + note = {00000} +} +``` + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b1cbc4e --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2019, Charlene Bultoc and others +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2d8effa --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +# sagittal average + +This is a library that calculate the averages through a sagittal plane. + +## Installation + +Browse to the directory where this file lives, and run: +```bash +pip install . +``` +That command will download any dependencies we have + + +## Usage + +Right now we have only one function, you can use it as shown below: + + +```python +from sagittal_averages import sagittal_brain + +sagittal_brain.run_averages("input_file.csv", "ouput_file.csv") +``` + +Or alternativaly you can run it from the terminal as: + +```bash +$ sagverage input_file.csv -o output_file.csv +``` + +## Contributing + +We accept contributions via GitHub!! + +To install the development version, clone this repository and install it on +a virtual environment + +```bash +git clone git@github.com:UCL-MPHY0021-21-22/sagittal_average.git +python -m venv brain +soruce brain/bin/activate +cd sagittal_average +pip install -e . +... code code code ... +deactivate +``` + +or using a conda environment as + +```bash +git clone git@github.com:UCL-MPHY0021-21-22/sagittal_average.git +conda create -n brain python=3.8 +conda activate brain +cd sagittal_average +pip install -e . +... code code code ... +conda deactivate +``` + + From 789631ab257caa448407be16712edf02d933b5ae Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 19:32:04 +0000 Subject: [PATCH 10/13] Adds GH actions configuration file --- .github/workflows/pytest.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/pytest.yml diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..99e9bee --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,32 @@ +name: Installation, test and coverage +on: [push] + +jobs: + test: + # Multiple platforms have been disabled because Windows and OSx needs more credits than what we have. + # Don't use them during class or the assignment + name: py${{ matrix.python-version }} # ${{ matrix.platform }} + runs-on: ubuntu-latest # ${{ matrix.platform }} + strategy: + matrix: + # platform: [ubuntu-latest, windows-latest, macos-latest] + python-version: [3.9, 3.11] + + steps: + # Checkout the repository and setups the machine to use python + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install testing dependencies + run: | + pip install pytest pytest-cov + + - name: Install package + run: | + pip install . + + - name: Run tests + run: pytest --cov=./ From 30a8a75845fe80d37acd395aa40480d6a056e100 Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 19:43:56 +0000 Subject: [PATCH 11/13] [docs] Default run from sphinx-quickstart Answered: > Separate source and build directories (y/n) [n]: > Project name: sagital-average > Author name(s): Charlene Bultoc > Project release []: 0.1 > Project language [en]: --- docs/Makefile | 20 ++++++++++++++++++ docs/conf.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 20 ++++++++++++++++++ docs/make.bat | 35 ++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..12e88f3 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,55 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'sagittal-average' +copyright = '2019, Charlene Bultoc' +author = 'Charlene Bultoc' + +# The full version, including alpha/beta/rc tags +release = '0.1' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..1344452 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +.. sagittal-average documentation master file, created by + sphinx-quickstart on Thu Nov 21 19:42:38 2019. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to sagittal-average's documentation! +=========================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..2119f51 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd From eb01f994873414cf20212778687b210da50a24bd Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 21 Nov 2019 19:48:39 +0000 Subject: [PATCH 12/13] [docs] Adds sphinx extensions Steps to build the docs ```bash cd docs sphinx-apidoc -o . ../sagital_average make html python -m http.server -d _build/html# to load the automatically built documentation ``` --- docs/conf.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 12e88f3..c33aeff 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,6 +31,10 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ + 'sphinx.ext.autodoc', # Support automatic documentation + 'sphinx.ext.coverage', # Automatically check if functions are documented + 'sphinx.ext.mathjax', # Allow support for algebra + 'sphinx.ext.viewcode', # Include the source code in documentation ] # Add any paths that contain templates here, relative to this directory. From 6e4a883fdea3804fb5db098f3263e98b68beaa09 Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 1 Dec 2022 10:25:11 +0000 Subject: [PATCH 13/13] Adds `setup.cfg` to set package installation parameters It simplifies the `setup.py` maintenance --- setup.cfg | 28 ++++++++++++++++++++++++++++ setup.py | 13 ++----------- 2 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..4b2aa25 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,28 @@ +[metadata] +name = sagittal_average +version = 0.1.0 +author = Charlene Bultoc +author_email = c.bultoc@neurolab.ac.uk +license = BSD 3-Clause License +description = Calculate the averages through a sagittal plane. +long_description = file: README.md, LICENSE.rst +long_description_content_type = text/markdown +classifiers = + Programming Language :: Python :: 3.9 + Operating System :: OS Independent + License :: OSI Approved :: BSD License + +[options] +packages = find: +python_requires = >=3.9 +# add your package requirements here +install_requires = + numpy + +[options.entry_points] +console_scripts = + sagverage = sagittal_average.command:process + +[options.packages.find] +exclude = + *tests diff --git a/setup.py b/setup.py index 440d750..6068493 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,3 @@ -from setuptools import setup, find_packages +from setuptools import setup -setup( - name="sagittal_average", - version="0.1.0", - packages=find_packages(exclude=['*tests']), - install_requires=['numpy'], - entry_points={ - 'console_scripts': [ - 'sagverage = sagittal_average.command:process' - ]}, -) +setup()