Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Empty file added __init__.py
Empty file.
16 changes: 16 additions & 0 deletions command.py
Original file line number Diff line number Diff line change
@@ -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()
16 changes: 1 addition & 15 deletions sagital_brain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter

import numpy as np


Expand All @@ -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)
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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'
]}
)
Empty file added tests/__init__.py
Empty file.
Empty file added tests/test_sagital_brain.py
Empty file.