<commit_before>"""
Execute the following steps before you attempt to run this pipeline

make grunt 
make demo
make ants
make machinelearn
you might need to use sudo (this is attributed to the way docker is designed)

To run the docker webapps use
sudo docker run -d -p 9917:9901 pesscara/machinelearn
sudo docker run -d -p 9916:9901 pesscara/ants

For instance the ports for the webapps offered by pesscara/ants are accessible at port 9916 of you local service 

If you have added custom docker based webapps please initialize. 

This file is depended on the request python library (http://docs.python-requests.org/en/master/user/install/#install). Please see requirements.txt

Example of a curl command 

curl -v -X POST --form clusternumber=6 --form imageA=@T1c.nii.gz --form imageB=@1.nii.gz --form output=cluster.nii.gz ril-gpu10:9913/rest/service/kmeansseg

curl -v -X POST --form fixed=@T1c.nii.gz --form registered=1.nii.gz ril-gpu10:9919/rest/service/n4


"""
from _grunt import *

g = grunt("http://ril-gpu10:9919")
# Syntax 1
j=g.n4
j.fixed="/Users/m112447/Documents/TestData/T2.nii.gz"
j.registered="T2N4.nii.gz"
job =j()
job.wait()
# Write some output
job.save_output("registered", "/Users/m112447/Downloads/")


# Syntax 2

j = g.n4(fixed="/Users/m112447/Documents/TestData/T1c.nii.gz",registered="T1cN4.nii.gz")
print dir(j)
j.wait()
j.save_output("registered", "/Users/m112447/Downloads/")
# # # Register T1 and T2
# But the code 
# Create an affine registration proxy for the grunt service
affine = g.affine
# Set parameters
affine.moving="/Users/m112447/Downloads/T2N4.nii.gz"
affine.fixed="/Users/m112447/Downloads/T1cN4.nii.gz"
affine.registered="T2reg.nii.gz"
# Don't need this
# affine = g.affine()
# Call the method
job = affine()
job.wait()
# Write some output
job.save_output("registered", "/Users/m112447/Downloads/")
# # Kmeans
g = grunt("http://ril-gpu10:9916")
print dir(g.services.get('kmeansseg'))
Info=g.services.get('kmeansseg')
print Info.inputs()
print Info.outputs()
print Info.parameters()
j = g.kmeansseg(imageA="/Users/m112447/Downloads/T1cN4.nii.gz",imageB='/Users/m112447/Downloads/T1cN4.nii.gz',clusternumber=6,output="Cluster.nii.gz")
print dir(j)
j.wait()
j.save_output("output", "/Users/m112447/Downloads/")

<commit_msg>correct for web address (demo)<commit_after>"""
Execute the following steps before you attempt to run this pipeline

make grunt 
make demo
make ants
make machinelearn
you might need to use sudo (this is attributed to the way docker is designed)

To run the docker webapps use
sudo docker run -d -p 9917:9901 pesscara/machinelearn
sudo docker run -d -p 9916:9901 pesscara/ants

For instance the ports for the webapps offered by pesscara/ants are accessible at port 9916 of you local service 

If you have added custom docker based webapps please initialize. 

This file is depended on the request python library (http://docs.python-requests.org/en/master/user/install/#install). Please see requirements.txt

Example of a curl command 

curl -v -X POST --form clusternumber=6 --form imageA=@T1c.nii.gz --form imageB=@1.nii.gz --form output=cluster.nii.gz ril-gpu10:9913/rest/service/kmeansseg

curl -v -X POST --form fixed=@T1c.nii.gz --form registered=1.nii.gz ril-gpu10:9919/rest/service/n4


"""
from _grunt import *

g = grunt("http://192.168.99.100:9918")
# Syntax 1
j=g.n4
j.fixed="/Users/m112447/Documents/TestData/T2.nii.gz"
j.registered="T2N4.nii.gz"
job =j()
job.wait()
# Write some output
job.save_output("registered", "/Users/m112447/Downloads/")


# Syntax 2

j = g.n4(fixed="/Users/m112447/Documents/TestData/T1c.nii.gz",registered="T1cN4.nii.gz")
print dir(j)
j.wait()
j.save_output("registered", "/Users/m112447/Downloads/")
# # # Register T1 and T2
# But the code 
# Create an affine registration proxy for the grunt service
affine = g.affine
# Set parameters
affine.moving="/Users/m112447/Downloads/T2N4.nii.gz"
affine.fixed="/Users/m112447/Downloads/T1cN4.nii.gz"
affine.registered="T2reg.nii.gz"
# Don't need this
# affine = g.affine()
# Call the method
job = affine()
job.wait()
# Write some output
job.save_output("registered", "/Users/m112447/Downloads/")
# # Kmeans
g = grunt("http://192.168.99.100:9919")
print dir(g.services.get('kmeansseg'))
Info=g.services.get('kmeansseg')
print Info.inputs()
print Info.outputs()
print Info.parameters()
j = g.kmeansseg(imageA="/Users/m112447/Downloads/T1cN4.nii.gz",imageB='/Users/m112447/Downloads/T1cN4.nii.gz',clusternumber=6,output="Cluster.nii.gz")
print dir(j)
j.wait()
j.save_output("output", "/Users/m112447/Downloads/")


{'fraction_non_alphanumeric': 0.13956550362080317, 'fraction_numerical': 0.06188281764318631, 'mean_word_length': 4.634116192830655, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2447110', 'n_tokens_mistral': 1891, 'n_tokens_neox': 1660, 'n_words': 422}