Skip to content

Commit

Permalink
Merge pull request #13 from frank-24/master
Browse files Browse the repository at this point in the history
Conrad updated the API, Frank updated the test
  • Loading branch information
frank-24 authored May 24, 2017
2 parents 33f21e2 + f4bd951 commit 6cd4904
Show file tree
Hide file tree
Showing 90 changed files with 563 additions and 106 deletions.
355 changes: 284 additions & 71 deletions dockereve-master/eve-app/settings.py

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions test/T1w/missingField/sub-10159_T1w.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"snr_wm": 11.248504688892124,
"summary_bg_p95": 12.0,
"InversionTime": 1.1,
"fber": 26.33627700805664,
"DeviceSerialNumber": "35343",
"snrd_csf": 26.613233468186966,
"InPlanePhaseEncodingDirection": "ROW",
"summary_csf_stdv": 32.83399963378906,
"snrd_gm": 44.12607332564048,
"size_x": 176,
"size_y": 256,
"size_z": 256,
"AcquisitionMatrix": "0/256/256/0",
"ProtocolName": "MPRAGE - BWM",
"summary_csf_p05": 68.0,
"icvs_wm": 0.3610708502595193,
"RepetitionTime": 2.53,
"summary_wm_stdv": 35.2022590637207,
"snrd_wm": 60.80321593566894,
"MagneticFieldStrength": 3,
"TotalScanTimeSec": 363,
"MRAcquisitionType": "3D",
"snr_total": 7.911386668025524,
"icvs_gm": 0.3959101040697155,
"summary_gm_mean": 211.44973754882812,
"rpve_csf": 83261.9375,
"tpm_overlap_wm": 0.5890556573867798,
"snrd_total": 43.8475075764988,
"PixelBandwidth": 200,
"ScanningSequence": "GR/IR",
"summary_csf_p95": 170.0,
"spacing_x": 1.0,
"FlipAngle": 7,
"summary_gm_k": -0.6324611944326,
"snr_gm": 8.794440881363833,
"icvs_csf": 0.2430190456707652,
"PatientPosition": "HFS",
"SequenceName": "*tfl3d1_ns",
"summary_bg_p05": 0.0,
"ImageType": "ORIGINAL/PRIMARY/M/ND/NORM",
"qi_2": 0.0042996791690604694,
"qi_1": 5.289201412128623e-06,
"ImagingFrequency": 123249959,
"AccelerationFactorPE": 2,
"md5sum": "75cab8005361c2504ba5a7f02ecbacd7",
"ScanOptions": "IR",
"summary_csf_k": 2.800222210830917,
"wm2max": 0.6761487964989059,
"fwhm_z": 3.22984,
"fwhm_y": 3.70268,
"fwhm_x": 3.50783,
"summary_gm_p05": 167.0,
"inu_range": 0.35875076055526733,
"spacing_z": 1.0,
"spacing_y": 1.0,
"rpve_gm": 152862.53125,
"NumberOfAverages": 1,
"summary_wm_p05": 255.0,
"PhaseEncodingDirection": "i-",
"TransmitCoilName": "Body",
"modality": "T1w",
"AccelNumReferenceLines": 32,
"PercentPhaseFieldOfView": 100,
"cnr": 11.335847854614258,
"subject_id": "10159",
"inu_med": 1.2151005268096924,
"EchoTrainLength": 1,
"version": "99.99.99",
"VariableFlipAngleFlag": "N",
"efc": 0.47647998100292316,
"summary_wm_mean": 309.4393005371094,
"summary_bg_stdv": 4.799960136413574,
"summary_bg_k": 177.84711440664685,
"mriqc_pred": 1,
"ReceiveCoilName": "HeadMatrix",
"PercentSampling": 100,
"ManufacturerModelName": "TrioTim",
"summary_gm_p95": 260.0,
"EchoTime": 0.00331,
"fwhm_avg": 3.47466,
"rpve_wm": 82412.921875,
"SequenceVariant": "SP/MP",
"tpm_overlap_gm": 0.479917049407959,
"summary_csf_mean": 126.74657440185547,
"summary_bg_mean": 4.691673278808594,
"summary_wm_p95": 368.0,
"snr_csf": 3.691214433820612,
"NumberOfPhaseEncodingSteps": 255,
"summary_gm_stdv": 28.741302490234375,
"SoftwareVersions": "syngo MR B15",
"tpm_overlap_csf": 0.21703721582889557,
"summary_wm_k": -0.15745795522916461,
"software": "mriqc"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions test/bold/missingField/image_bold.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"modality" : "bold",
"aqi": 0.0005224403999999999,
"dvars_nstd": 10.191722418947368,
"dvars_std": 1.0800233642105264,
"dvars_vstd": 1.6403423489473683,
"efc": 0.5638485423014671,
"fber": 958.6884765625,
"fd_mean": 0.16413075091049215,
"fd_num": 4,
"fd_perc": 20,
"fwhm_avg": 40.5562,
"fwhm_x": 37.569,
"fwhm_y": 43.0101,
"fwhm_z": 41.283,
"gcor": 0.2162099838256836,
"gsr_x": -0.004743137396872044,
"gsr_y": 0.02154964953660965,
"task_id": "rhymejudgment",
"size_t": 20,
"size_x": 16,
"size_y": 16,
"size_z": 9,
"snr": 1.1260140530360272,
"spacing_tr": 2,
"spacing_x": 12.5,
"spacing_y": 12.5,
"spacing_z": 16,
"summary_bg_k": 10.199746320897564,
"summary_bg_mean": 10.67599868774414,
"summary_bg_p05": 3.4488043785095215,
"summary_bg_p95": 21.972539520263666,
"summary_bg_stdv": 5.769111156463623,
"summary_fg_k": -1.6145134278870812,
"summary_fg_mean": 290.6355895996094,
"summary_fg_p05": 13.376275062561035,
"summary_fg_p95": 631.4849853515625,
"summary_fg_stdv": 238.1324462890625,
"tsnr": 108.249267578125
}
41 changes: 41 additions & 0 deletions test/bold/validData/image_bold.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"modality" : "bold",
"aor": 0.034428499999999994,
"aqi": 0.0005224403999999999,
"dvars_nstd": 10.191722418947368,
"dvars_std": 1.0800233642105264,
"dvars_vstd": 1.6403423489473683,
"efc": 0.5638485423014671,
"fber": 958.6884765625,
"fd_mean": 0.16413075091049215,
"fd_num": 4,
"fd_perc": 20,
"fwhm_avg": 40.5562,
"fwhm_x": 37.569,
"fwhm_y": 43.0101,
"fwhm_z": 41.283,
"gcor": 0.2162099838256836,
"gsr_x": -0.004743137396872044,
"gsr_y": 0.02154964953660965,
"task_id": "rhymejudgment",
"size_t": 20,
"size_x": 16,
"size_y": 16,
"size_z": 9,
"snr": 1.1260140530360272,
"spacing_tr": 2,
"spacing_x": 12.5,
"spacing_y": 12.5,
"spacing_z": 16,
"summary_bg_k": 10.199746320897564,
"summary_bg_mean": 10.67599868774414,
"summary_bg_p05": 3.4488043785095215,
"summary_bg_p95": 21.972539520263666,
"summary_bg_stdv": 5.769111156463623,
"summary_fg_k": -1.6145134278870812,
"summary_fg_mean": 290.6355895996094,
"summary_fg_p05": 13.376275062561035,
"summary_fg_p95": 631.4849853515625,
"summary_fg_stdv": 238.1324462890625,
"tsnr": 108.249267578125
}
138 changes: 103 additions & 35 deletions test/testGetPost.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
from glob import glob

# test data directory
pattern = os.path.join('test/derivatives/', '*.json')
boldPattern = os.path.join('test/bold/validData', '*.json')
T1wPattern = os.path.join('test/T1w/validData', '*.json')

# missing field data directory
boldMissingPattern = os.path.join('test/bold/missingField', '*.json')
T1wMissingPattern = os.path.join('test/T1w/missingField', '*.json')


# url for GET
def getURL(postResponse, url):
Expand All @@ -18,68 +24,128 @@ def getRequest(postResponse, url):
###### MAIN ######
header = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8'}
numOfTestData = 84
urlBold = "http://localhost:80/bold"
urlT1w = "http://localhost:80/T1w"
codeForInvalid = 422

class TestCase(unittest.TestCase):

def test_00_CountFiles(self):
# 1. initialize param. change to others for later use
url = "http://localhost:80/scenarios"
log= logging.getLogger( "SomeTest.testSomething" )

count = 0

self.assertTrue( count == 0 )

count = len(glob(pattern))

self.assertTrue( count == numOfTestData )

def test_01_GETAllData(self):
# 1. initialize param. change to others for later use
url = "http://localhost:80/scenarios"
def test_00_GETAllData(self):
log= logging.getLogger( "SomeTest.testSomething" )

inputCount = 0
for fileName in glob(pattern):
for fileName in glob(T1wPattern):
with open(fileName) as fp:
inputCount += 1
inputData = json.load(fp)
# POST request
postResponse = requests.post(url, data = json.dumps(inputData), headers = header)
postResponse = requests.post(urlT1w, data = json.dumps(inputData), headers = header)
# GET request
getResponse = requests.get(url).json()
# print requests.get(urlT1w)
getResponse = requests.get(urlT1w).json()
log.debug( "total: %r", getResponse['_meta']['total'] )
self.assertTrue( inputCount == getResponse['_meta']['total'] )

def test_02_ConnectionStatus(self):
# 1. initialize param. change to others for later use
url = "http://localhost:80/scenarios"
########## Testing Bold ############
def test_01_ConnectionStatus(self):
log= logging.getLogger( "SomeTest.testSomething" )

for fileName in glob(boldPattern):
with open(fileName) as fp:
inputData = json.load(fp)
# print inputData
# POST request
postResponse = requests.post(urlBold, data = json.dumps(inputData), headers = header)
self.assertTrue( postResponse.raise_for_status() == None )
# GET request
getResponse = requests.get( getURL(postResponse, urlBold) )
self.assertTrue( getResponse.raise_for_status() == None )

def test_02_MissingFieldInput(self):
log= logging.getLogger( "SomeTest.testSomething" )

for fileName in glob(boldMissingPattern):
with open(fileName) as fp:
inputData = json.load(fp)
# POST request
postResponse = requests.post(urlBold, data = json.dumps(inputData), headers = header)
# print postResponse.status_code
self.assertTrue( postResponse.status_code == codeForInvalid )

########## Testing T1w ############
def test_03_ConnectionStatus(self):
log= logging.getLogger( "SomeTest.testSomething" )

for fileName in glob(pattern):
for fileName in glob(T1wPattern):
with open(fileName) as fp:
inputData = json.load(fp)
# print inputData
# POST request
postResponse = requests.post(url, data = json.dumps(inputData), headers = header)
postResponse = requests.post(urlT1w, data = json.dumps(inputData), headers = header)
self.assertTrue( postResponse.raise_for_status() == None )
# GET request
getResponse = requests.get( getURL(postResponse, url) )
getResponse = requests.get( getURL(postResponse, urlT1w) )
self.assertTrue( getResponse.raise_for_status() == None )

def test_03_DataValid(self):
# 1. initialize param. change to others for later use
url = "http://localhost:80/scenarios"

for fileName in glob(pattern):
def test_04_MissingFieldInput(self):
log= logging.getLogger( "SomeTest.testSomething" )

for fileName in glob(T1wMissingPattern):
with open(fileName) as fp:
inputData = json.load(fp)
# POST request
postResponse = requests.post(urlT1w, data = json.dumps(inputData), headers = header)
# print postResponse.status_code
self.assertTrue( postResponse.status_code == codeForInvalid )

########## Cross Testing: send data to wrong end point ############
def test_05_boldDataToT1wEndPoint(self):
log= logging.getLogger( "SomeTest.testSomething" )

for fileName in glob(boldPattern):
with open(fileName) as fp:
inputData = json.load(fp)
# POST request
postResponse = requests.post(urlT1w, data = json.dumps(inputData), headers = header)
self.assertTrue( postResponse.status_code == codeForInvalid )

def test_06_T1wDataToBoldEndPoint(self):
log= logging.getLogger( "SomeTest.testSomething" )

for fileName in glob(T1wPattern):
with open(fileName) as fp:
inputData = json.load(fp)
# POST request
postResponse = requests.post(urlBold, data = json.dumps(inputData), headers = header)
self.assertTrue( postResponse.status_code == codeForInvalid )

def test_07_T1wDataValid(self):

for fileName in glob(T1wPattern):
with open(fileName) as fp:
inputData = json.load(fp)
# 2. POST request
postResponse = requests.post(urlT1w, data = json.dumps(inputData), headers = header)

# 3. GET request
queriedData = getRequest(postResponse, urlT1w)
# 4. validate input data and queried data
for key in inputData:
# check missing key
self.assertTrue(key in queriedData)
# check key-value pair match
self.assertTrue( inputData[key] == queriedData[key] )


def test_08_boldDataValid(self):

for fileName in glob(boldPattern):
with open(fileName) as fp:
inputData = json.load(fp)
# 2. POST request
postResponse = requests.post(url, data = json.dumps(inputData), headers = header)
postResponse = requests.post(urlBold, data = json.dumps(inputData), headers = header)

# 3. GET request
queriedData = getRequest(postResponse, url)

queriedData = getRequest(postResponse, urlBold)
# 4. validate input data and queried data
for key in inputData:
# check missing key
Expand All @@ -88,6 +154,8 @@ def test_03_DataValid(self):
self.assertTrue( inputData[key] == queriedData[key] )


# ****************


if __name__ == '__main__':
logging.basicConfig( stream=sys.stderr )
Expand Down
Binary file removed test/testing data.zip
Binary file not shown.

0 comments on commit 6cd4904

Please sign in to comment.