diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..90f8fbb --- /dev/null +++ b/.gitignore @@ -0,0 +1,176 @@ +# Created by https://www.toptal.com/developers/gitignore/api/python +# Edit at https://www.toptal.com/developers/gitignore?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/ +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/ +cover/ + +# 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/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .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 + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# 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/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +# End of https://www.toptal.com/developers/gitignore/api/python \ No newline at end of file diff --git a/brain_average.csv b/brain_average.csv deleted file mode 100644 index d30573e..0000000 --- a/brain_average.csv +++ /dev/null @@ -1 +0,0 @@ -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 diff --git a/brain_sample.csv b/brain_sample.csv deleted file mode 100644 index 7b809c6..0000000 --- a/brain_sample.csv +++ /dev/null @@ -1,20 +0,0 @@ -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 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b32f98d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,12 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "sagittal_average" +version = "0.1.0" + +[tool.hatch.build.targets.wheel] +packages = [ + "src/sagittal_average", +] \ No newline at end of file diff --git a/sagittal_brain.py b/src/sagittal_average/sagittal_brain.py similarity index 96% rename from sagittal_brain.py rename to src/sagittal_average/sagittal_brain.py index c257fc9..27a4120 100644 --- a/sagittal_brain.py +++ b/src/sagittal_average/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=',') diff --git a/tests/brain_average.csv b/tests/brain_average.csv new file mode 100644 index 0000000..af02e18 --- /dev/null +++ b/tests/brain_average.csv @@ -0,0 +1 @@ +0.0,0.0,0.0,0.0,0.0,0.0,0.0,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/tests/brain_sample.csv b/tests/brain_sample.csv new file mode 100644 index 0000000..d0b9035 --- /dev/null +++ b/tests/brain_sample.csv @@ -0,0 +1,20 @@ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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/tests/test_sagittal_brain.py b/tests/test_sagittal_brain.py new file mode 100644 index 0000000..397151e --- /dev/null +++ b/tests/test_sagittal_brain.py @@ -0,0 +1,23 @@ +import numpy as np +from sagittal_average.sagittal_brain import run_averages +from pathlib import Path + +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) \ No newline at end of file