Skip to content

Commit 1158685

Browse files
committed
Moves the executing script as a shell command accessible from anywhere
1 parent d426a8e commit 1158685

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ version = "0.1.0"
1010
packages = [
1111
"src/sagittal_average",
1212
]
13+
14+
[project.scripts]
15+
sagittal_average_run = "sagittal_average.command:process"

src/sagittal_average/command.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
2+
3+
from .sagittal_brain import run_averages
4+
5+
def process():
6+
parser = ArgumentParser(description="Calculates the average for each sagittal-horizontal plane.",
7+
formatter_class=ArgumentDefaultsHelpFormatter)
8+
parser.add_argument('file_input', nargs='?', default="brain_sample.csv",
9+
help="Input CSV file with the results from scikit-brain binning algorithm.")
10+
parser.add_argument('--file_output', '-o', default="brain_average.csv",
11+
help="Name of the output CSV file.")
12+
arguments = parser.parse_args()
13+
14+
run_averages(arguments.file_input, arguments.file_output)

src/sagittal_average/sagittal_brain.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,3 @@ def run_averages(file_input='brain_sample.csv', file_output='brain_average.csv')
2020

2121
# write it out on my file
2222
np.savetxt(file_output, averages, fmt='%.1f', delimiter=',')
23-
24-
25-
if __name__ == "__main__":
26-
parser = ArgumentParser(description="Calculates the average for each sagittal-horizontal plane.",
27-
formatter_class=ArgumentDefaultsHelpFormatter)
28-
parser.add_argument('file_input', nargs='?', default="brain_sample.csv",
29-
help="Input CSV file with the results from scikit-brain binning algorithm.")
30-
parser.add_argument('--file_output', '-o', default="brain_average.csv",
31-
help="Name of the output CSV file.")
32-
arguments = parser.parse_args()
33-
34-
run_averages(arguments.file_input, arguments.file_output)

0 commit comments

Comments
 (0)