Commit 61ebfa09 authored by nicholst's avatar nicholst
Browse files

A version that doesn't work; about to back track

parent c6867b14
"""TNutils - My first python package, random utilities"""
from . import imstats
from .imstats import *
__version__ = '0.1.0'
__author__ = 'TE Nichols <thomas.nichols@bdi.ox.ac.uk>'
......
......@@ -7,6 +7,9 @@ import nibabel as nib
def immax(Fns):
"""Find max of some images."""
if isinstance(Fns, str):
Fns=[Fns]
Max=[]
for i in range(len(Fns)):
fn = Fns[i]
......@@ -16,13 +19,16 @@ def immax(Fns):
except Exception as e:
print("ERROR: "+str(e))
exit()
print('Max {}'.format(Max))
return(Max)
def immean(Fns):
"""Find mean of some images."""
if isinstance(Fns, str):
Fns=[Fns]
Mean=[]
for i in range(len(Fns)):
fn = Fns[i]
......@@ -33,6 +39,7 @@ def immean(Fns):
print("ERROR: "+str(e))
exit()
print('Mean {}'.format(Mean))
return(Mean)
......@@ -40,40 +47,44 @@ def PrintResults(Fns,Vals):
print('\n'.join(['{:40s} : {:8.4f}'.format(nm,mx) for (nm,mx) in zip(Fns,Vals)]))
def main_immax():
"""Script wrapper for immax."""
if len(sys.argv)==1:
print("""
def main_ShowRes(Usage):
def Decorator(func):
def Wrapper(*args):
if len(sys.argv)==1:
print(Usage)
sys.exit(1)
else:
retval = func(sys.argv[1:])
print(retval)
PrintResults(sys.argv[1:],retval)
return(retval)
return(Wrapper)
return(Decorator)
@main_ShowRes("""
Usage: immax.py img1 [img2 ...]
Print the maximum of one or more images.
_________________________________________________________________________
T. Nichols
""")
sys.exit(1)
def main_immax(Imgs):
"""Script wrapper for immax."""
Fns=sys.argv[1:]
PrintResults(Fns,immax(Fns))
mx=immax(Imgs)
def main_immean():
"""Script wrapper for immean."""
if len(sys.argv)==1:
print("""
@main_ShowRes("""
Usage: immean.py img1 [img2 ...]
Print the mean of one or more images.
_________________________________________________________________________
T. Nichols
""")
sys.exit(1)
Fns=sys.argv[1:]
PrintResults(Fns,immean(Fns))
if __name__ == '__main__':
main_immax()
def main_immean(Imgs):
"""Script wrapper for immean."""
mn=immean(Imgs)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment