diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba95694 --- /dev/null +++ b/.gitignore @@ -0,0 +1,153 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/python,vscode +# Edit at https://www.toptal.com/developers/gitignore?templates=python,vscode + +### 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 +*.py,cover +.hypothesis/ +.pytest_cache/ +pytestdebug.log + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ +doc/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# 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 + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +pythonenv* + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# profiling data +.prof + +### vscode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# End of https://www.toptal.com/developers/gitignore/api/python,vscode \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/command.py b/command.py new file mode 100644 index 0000000..1bd2e22 --- /dev/null +++ b/command.py @@ -0,0 +1,16 @@ +from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter +from sagital_brain import run_averages + +def process(): + parser = ArgumentParser(description="Calculates the average for each sagital-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) + +if __name__ == "__main__": + process() \ No newline at end of file diff --git a/sagital_brain.py b/sagital_brain.py index 9c5ed19..c5d3b6d 100644 --- a/sagital_brain.py +++ b/sagital_brain.py @@ -1,5 +1,3 @@ -from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter - import numpy as np @@ -16,19 +14,7 @@ def run_averages(file_input='brain_sample.csv', file_output='brain_average.csv') # Calculates the averages through the sagital/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=',') - - -if __name__ == "__main__": - parser = ArgumentParser(description="Calculates the average for each sagital-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 new file mode 100644 index 0000000..65e6b36 --- /dev/null +++ b/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup, find_packages + +setup( + name = "sagital_average", + version = "0.1.0", + packages=find_packages(exclude=['*test']), + install_requires=['numpy'], + entry_points={ + 'console_scripts': [ + 'run_averages = command:main' + ]} +) \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_sagital_brain.py b/tests/test_sagital_brain.py new file mode 100644 index 0000000..e69de29