From 2e51bf61b696461d5eae42768034869b586eb6bc Mon Sep 17 00:00:00 2001 From: oesteban Date: Fri, 26 May 2017 14:05:34 -0700 Subject: [PATCH 1/3] [ENH] Update schema Some fields were wrong or missing --- dockereve-master/eve-app/settings.py | 984 +++++++++++++++------------ 1 file changed, 538 insertions(+), 446 deletions(-) diff --git a/dockereve-master/eve-app/settings.py b/dockereve-master/eve-app/settings.py index 0d251d1..69a5609 100644 --- a/dockereve-master/eve-app/settings.py +++ b/dockereve-master/eve-app/settings.py @@ -2,176 +2,515 @@ import re get_mongo_host = re.match('tcp://(.*):(.*)', os.environ['MONGODB_PORT']) +bids_schema = { + 'modality': { + 'type': 'string', + 'required': True + }, + 'subject_id': { + 'type': 'string', + 'required': True + }, + 'run_id': {'type': 'string'}, + 'acq_id': {'type': 'string'}, + 'task_id': {'type': 'string'}, + 'run_id': {'type': 'string'}, +} + +settings_schema = { + 'version': { + 'type': 'string', + 'required': True + }, + 'md5sum': { + 'type': 'string', + 'required': True + }, + 'software': { + 'type': 'string', + 'required': True + }, +} + +bold_iqms_schema = { + 'aor': { + 'type': 'float', + 'required': True + }, + 'aqi': { + 'type': 'float', + 'required': True + + }, + 'dvars_nstd': { + 'type': 'float', + 'required': True + + }, + 'dvars_std': { + 'type': 'float', + 'required': True + }, + 'dvars_vstd': { + 'type': 'float', + 'required': True + }, + 'efc': { + 'type': 'float', + 'required': True + }, + 'fber': { + 'type': 'float', + 'required': True + }, + 'fd_mean': { + 'type': 'float', + 'required': True + }, + 'fd_num': { + 'type': 'float', + 'required': True + }, + 'fd_perc': { + 'type': 'float', + 'required': True + }, + 'fwhm_avg': { + 'type': 'float', + 'required': True + }, + 'fwhm_x': { + 'type': 'float', + 'required': True + }, + 'fwhm_y': { + 'type': 'float', + 'required': True + }, + 'fwhm_z': { + 'type': 'float', + 'required': True + }, + 'gcor': { + 'type': 'float', + 'required': True + }, + 'gsr_x': { + 'type': 'float', + 'required': True + }, + 'gsr_y': { + 'type': 'float', + 'required': True + }, + 'task_id': { + 'type': 'string', + 'required': True + }, + 'size_t': { + 'type': 'float', + 'required': True + }, + 'size_x': { + 'type': 'float', + 'required': True + }, + 'size_y': { + 'type': 'float', + 'required': True + }, + 'size_z': { + 'type': 'float', + 'required': True + }, + 'snr': { + 'type': 'float', + 'required': True + }, + 'spacing_tr': { + 'type': 'float', + 'required': True + }, + 'spacing_x': { + 'type': 'float', + 'required': True + }, + 'spacing_y': { + 'type': 'float', + 'required': True + }, + 'spacing_z': { + 'type': 'float', + 'required': True + }, + 'summary_bg_k': { + 'type': 'float', + 'required': True + }, + 'summary_bg_mean': { + 'type': 'float', + 'required': True + }, + 'summary_bg_median': { + 'type': 'float', + 'required': True + }, + 'summary_bg_mad': { + 'type': 'float', + 'required': True + }, + 'summary_bg_p05': { + 'type': 'float', + 'required': True + }, + 'summary_bg_p95': { + 'type': 'float', + 'required': True + }, + 'summary_bg_stdv': { + 'type': 'float', + 'required': True + }, + 'summary_bg_n': { + 'type': 'float', + 'required': True + }, + 'summary_fg_k': { + 'type': 'float', + 'required': True + }, + 'summary_fg_mean': { + 'type': 'float', + 'required': True + }, + 'summary_fg_median': { + 'type': 'float', + 'required': True + }, + 'summary_fg_mad': { + 'type': 'float', + 'required': True + }, + 'summary_fg_p05': { + 'type': 'float', + 'required': True + }, + 'summary_fg_p95': { + 'type': 'float', + 'required': True + }, + 'summary_fg_stdv': { + 'type': 'float', + 'required': True + }, + 'summary_fg_n': { + 'type': 'float', + 'required': True + }, + 'tsnr': { + 'type': 'float', + 'required': True + }, + +} + +t1w_iqms_schema = { + 'cjv': { + 'type': 'float', + 'required': True + }, + 'cnr': { + 'type': 'float', + 'required': True + }, + 'efc': { + 'type': 'float', + 'required': True + }, + 'fber': { + 'type': 'float', + 'required': True + + }, + 'fwhm_avg': { + 'type': 'float', + 'required': True + }, + 'fwhm_x': { + 'type': 'float', + 'required': True + }, + 'fwhm_y': { + 'type': 'float', + 'required': True + }, + 'fwhm_z': { + 'type': 'float', + 'required': True + }, + 'icvs_csf': { + 'type': 'float', + 'required': True + }, + 'icvs_gm': { + 'type': 'float', + 'required': True + }, + 'icvs_wm': { + 'type': 'float', + 'required': True + }, + 'inu_med': { + 'type': 'float', + 'required': True + }, + 'inu_range': { + 'type': 'float', + 'required': True + }, + 'mriqc_pred': { + 'type': 'integer', + 'required': True + }, + 'qi_1': { + 'type': 'float', + 'required': True + }, + 'qi_2': { + 'type': 'float', + 'required': True + }, + 'rpve_csf': { + 'type': 'float', + 'required': True + }, + 'rpve_gm': { + 'type': 'float', + 'required': True + }, + 'rpve_wm': { + 'type': 'float', + 'required': True + }, + 'size_x': { + 'type': 'integer', + 'required': True + }, + 'size_y': { + 'type': 'integer', + 'required': True + }, + 'size_z': { + 'type': 'integer', + 'required': True + }, + 'snr_csf': { + 'type': 'float', + 'required': True + }, + 'snr_gm': { + 'type': 'float', + 'required': True + }, + 'snr_total': { + 'type': 'float', + 'required': True + }, + 'snr_wm': { + 'type': 'float', + 'required': True + }, + 'snrd_csf': { + 'type': 'float', + 'required': True + }, + 'snrd_gm': { + 'type': 'float', + 'required': True + }, + 'snrd_total': { + 'type': 'float', + 'required': True + }, + 'snrd_wm': { + 'type': 'float', + 'required': True + }, + 'spacing_x': { + 'type': 'float', + 'required': True + }, + 'spacing_y': { + 'type': 'float', + 'required': True + }, + 'spacing_z': { + 'type': 'float', + 'required': True + }, + 'summary_bg_k': { + 'type': 'float', + 'required': True + }, + 'summary_bg_mean': { + 'type': 'float', + 'required': True + }, + 'summary_bg_median': { + 'type': 'float', + 'required': True + }, + 'summary_bg_mad': { + 'type': 'float', + 'required': True + }, + 'summary_bg_p05': { + 'type': 'float', + 'required': True + }, + 'summary_bg_p95': { + 'type': 'float', + 'required': True + }, + 'summary_bg_stdv': { + 'type': 'float', + 'required': True + }, + 'summary_bg_n': { + 'type': 'float', + 'required': True + }, + 'summary_csf_k': { + 'type': 'float', + 'required': True + }, + 'summary_csf_mean': { + 'type': 'float', + 'required': True + }, + 'summary_csf_median': { + 'type': 'float', + 'required': True + }, + 'summary_csf_mad': { + 'type': 'float', + 'required': True + }, + 'summary_csf_p05': { + 'type': 'float', + 'required': True + }, + 'summary_csf_p95': { + 'type': 'float', + 'required': True + }, + 'summary_csf_stdv': { + 'type': 'float', + 'required': True + }, + 'summary_csf_n': { + 'type': 'float', + 'required': True + }, + 'summary_gm_k': { + 'type': 'float', + 'required': True + }, + 'summary_gm_mean': { + 'type': 'float', + 'required': True + }, + 'summary_gm_median': { + 'type': 'float', + 'required': True + }, + 'summary_gm_mad': { + 'type': 'float', + 'required': True + }, + 'summary_gm_p05': { + 'type': 'float', + 'required': True + }, + 'summary_gm_p95': { + 'type': 'float', + 'required': True + }, + 'summary_gm_stdv': { + 'type': 'float', + 'required': True + }, + 'summary_gm_n': { + 'type': 'float', + 'required': True + }, + 'summary_wm_k': { + 'type': 'float', + 'required': True + }, + 'summary_wm_mean': { + 'type': 'float', + 'required': True + }, + 'summary_wm_median': { + 'type': 'float', + 'required': True + }, + 'summary_wm_mad': { + 'type': 'float', + 'required': True + }, + 'summary_wm_p05': { + 'type': 'float', + 'required': True + }, + 'summary_wm_p95': { + 'type': 'float', + 'required': True + }, + 'summary_wm_stdv': { + 'type': 'float', + 'required': True + }, + 'summary_wm_n': { + 'type': 'float', + 'required': True + }, + 'tpm_overlap_csf': { + 'type': 'float', + 'required': True + }, + 'tpm_overlap_gm': { + 'type': 'float', + 'required': True + }, + 'tpm_overlap_wm': { + 'type': 'float', + 'required': True + }, + 'wm2max': { + 'type': 'float', + 'required': True + }, +} + + my_settings = { 'MONGO_HOST': get_mongo_host.group(1), 'MONGO_PORT': get_mongo_host.group(2), 'MONGO_DBNAME': 'scenarios', 'X_DOMAINS': '*', 'DOMAIN': { - 'bold': { + 'bold': { 'item_title': 'bold', 'resource_methods': ['GET', 'POST'], 'item_methods': ['GET', 'PATCH', 'PUT', 'DELETE'], 'schema': { - #if modality == bold, the fields below are required - 'modality': { - 'type': 'string', - 'required': True - }, - 'aor': { - 'type': 'float', - 'required': True - }, - 'aqi': { - 'type': 'float', - 'required': True - - }, - 'dvars_nstd': { - 'type': 'float', - 'required': True - - }, - 'dvars_std': { - 'type': 'float', - 'required': True - }, - 'dvars_vstd': { - 'type': 'float', - 'required': True - }, - 'efc': { - 'type': 'float', - 'required': True - }, - 'fber': { - 'type': 'float', - 'required': True - }, - 'fd_mean': { - 'type': 'float', - 'required': True - }, - 'fd_num': { - 'type': 'float', - 'required': True - }, - 'fd_perc': { - 'type': 'float', - 'required': True - }, - 'fwhm_avg': { - 'type': 'float', - 'required': True - }, - 'fwhm_x': { - 'type': 'float', - 'required': True - }, - 'fwhm_y': { - 'type': 'float', - 'required': True - }, - 'fwhm_z': { - 'type': 'float', - 'required': True - }, - 'gcor': { - 'type': 'float', - 'required': True - }, - 'gsr_x': { - 'type': 'float', - 'required': True - }, - 'gsr_y': { - 'type': 'float', - 'required': True - }, - 'task_id': { + # if modality == bold, the fields below are required + 'TaskName': { 'type': 'string', 'required': True }, - 'size_t': { - 'type': 'float', - 'required': True - }, - 'size_x': { - 'type': 'float', - 'required': True - }, - 'size_y': { - 'type': 'float', - 'required': True - }, - 'size_z': { - 'type': 'float', - 'required': True - }, - 'snr': { - 'type': 'float', - 'required': True - }, - 'spacing_tr': { - 'type': 'float', - 'required': True - }, - 'spacing_x': { - 'type': 'float', - 'required': True - }, - 'spacing_y': { - 'type': 'float', - 'required': True - }, - 'spacing_z': { - 'type': 'float', - 'required': True - }, - 'summary_bg_k': { - 'type': 'float', - 'required': True - }, - 'summary_bg_mean': { - 'type': 'float', - 'required': True - }, - 'summary_bg_p05': { - 'type': 'float', - 'required': True - }, - 'summary_bg_p95': { - 'type': 'float', - 'required': True - }, - 'summary_bg_stdv': { - 'type': 'float', - 'required': True - }, - 'summary_fg_k': { - 'type': 'float', - 'required': True - }, - 'summary_fg_mean': { - 'type': 'float', - 'required': True - }, - 'summary_fg_p05': { - 'type': 'float', - 'required': True - }, - 'summary_fg_p95': { - 'type': 'float', - 'required': True - }, - 'summary_fg_stdv': { - 'type': 'float', - 'required': True - }, - 'tsnr': { - 'type': 'float', - 'required': True - }, 'AccelNumReferenceLines': {'type': 'integer'}, 'AccelerationFactorPE': {'type': 'integer'}, 'AcquisitionMatrix': {'type': 'string'}, @@ -185,7 +524,7 @@ 'InversionTime': {'type': 'float'}, 'MRAcquisitionType': {'type': 'string'}, 'MagneticFieldStrength': {'type': 'integer'}, - 'ManufacturerModelName': {'type': 'string'}, + 'ManufacturersModelName': {'type': 'string'}, 'NumberOfAverages': {'type': 'integer'}, 'NumberOfPhaseEncodingSteps': {'type': 'integer'}, 'PatientPosition': {'type': 'string'}, @@ -204,298 +543,43 @@ 'TotalScanTimeSec': {'type': 'integer'}, 'TransmitCoilName': {'type': 'string'}, 'VariableFlipAngleFlag': {'type': 'string'}, - 'ContrastBolusIngredient': {'type': 'string'}, 'Manufacturer': {'type': 'string'}, 'HardcopyDeviceSoftwareVersion': {'type': 'string'}, 'GradientSetType': {'type': 'string'}, - 'MRTransmitCoilSequence':{'type': 'string'}, + 'MRTransmitCoilSequence': {'type': 'string'}, 'MatrixCoilMode': {'type': 'string'}, 'CoilCombinationMethod': {'type': 'string'}, 'PulseSequenceType': {'type': 'string'}, 'PulseSequenceDetails': {'type': 'string'}, - 'NumberShots' :{'type': 'integer'}, - 'ParallelReductionFactorInPlane':{'type': 'float'}, + 'NumberShots': {'type': 'integer'}, + 'ParallelReductionFactorInPlane': {'type': 'float'}, 'ParallelAcquisitionTechnique': {'type': 'string'}, - 'PartialFourier' :{'type': 'boolean'}, - 'PartialFourierDirection':{'type': 'string'}, - 'EffectiveEchoSpacing' :{'type': 'float'}, - 'TotalReadoutTime':{'type': 'float'}, + 'PartialFourier': {'type': 'boolean'}, + 'PartialFourierDirection': {'type': 'string'}, + 'EffectiveEchoSpacing': {'type': 'float'}, + 'TotalReadoutTime': {'type': 'float'}, 'SliceEncodingDirection': {'type': 'string'}, - 'NumberOfVolumesDiscardedByScanner':{'type': 'float'}, - 'NumberOfVolumesDiscardedByUser':{'type': 'float'}, - 'DelayTime':{'type': 'float'}, - 'MultibandAccelerationFactor':{'type': 'float'}, + 'NumberOfVolumesDiscardedByScanner': {'type': 'float'}, + 'NumberOfVolumesDiscardedByUser': {'type': 'float'}, + 'DelayTime': {'type': 'float'}, + 'MultibandAccelerationFactor': {'type': 'float'}, 'Instructions': {'type': 'string'}, 'TaskDescription': {'type': 'string'}, - 'CogAtlasID' : {'type': 'string'}, + 'CogAtlasID': {'type': 'string'}, 'CogPOID': {'type': 'string'}, 'InstitutionName': {'type': 'string'}, 'InstitutionAddress': {'type': 'string'}, 'ConversionSoftware': {'type': 'string'}, 'ConversionSoftwareVersion': {'type': 'string'}, - } #end of schema - },#end of bold - 'T1w': { + } # end of schema + }, # end of bold + 'T1w': { 'item_title': 'T1w', 'resource_methods': ['GET', 'POST'], 'item_methods': ['GET', 'PATCH', 'PUT', 'DELETE'], 'schema': { - 'modality': { - 'type': 'string', - 'required': True - }, - #if modality == T1w, the fields below are required - 'cjv':{ - 'type': 'float', - 'required': True - }, - 'cnr':{ - 'type':'float', - 'required': True - }, - 'efc':{ - 'type':'float', - 'required': True - }, - 'fber': { - 'type': 'float', - 'required': True - - }, - 'fwhm_avg': { - 'type': 'float', - 'required': True - }, - 'fwhm_x':{ - 'type': 'float', - 'required': True - }, - 'fwhm_y': { - 'type': 'float', - 'required': True - }, - 'fwhm_z': { - 'type': 'float', - 'required': True - }, - 'icvs_csf': { - 'type': 'float', - 'required': True - }, - 'icvs_gm': { - 'type': 'float', - 'required': True - }, - 'icvs_wm': { - 'type': 'float', - 'required': True - }, - 'inu_med': { - 'type': 'float', - 'required': True - }, - 'inu_range': { - 'type': 'float', - 'required': True - }, - 'md5sum': { - 'type': 'string', - 'required': True - }, - 'modality': { - 'type': 'string', - 'required': True - - }, - 'mriqc_pred': { - 'type': 'integer', - 'required': True - }, - 'software': { - 'type': 'string', - 'required': True - }, - 'subject_id': { - 'type': 'string', - 'required': True - }, - 'version': { - 'type': 'string', - 'required': True - }, - 'qi_1': { - 'type': 'float', - 'required': True - }, - 'qi_2': { - 'type': 'float', - 'required': True - }, - 'rpve_csf': { - 'type': 'float', - 'required': True - }, - 'rpve_gm': { - 'type': 'float', - 'required': True - }, - 'rpve_wm': { - 'type': 'float', - 'required': True - }, - 'size_x': { - 'type': 'integer', - 'required': True - }, - 'size_y': { - 'type': 'integer', - 'required': True - }, - 'size_z': { - 'type': 'integer', - 'required': True - }, - 'snr_csf': { - 'type': 'float', - 'required': True - }, - 'snr_gm': { - 'type': 'float', - 'required': True - }, - 'snr_total':{ - 'type': 'float', - 'required': True - }, - 'snr_wm': { - 'type': 'float', - 'required': True - }, - 'snrd_csf': { - 'type': 'float', - 'required': True - }, - 'snrd_gm': { - 'type': 'float', - 'required': True - }, - 'snrd_total': { - 'type': 'float', - 'required': True - }, - 'snrd_wm': { - 'type': 'float', - 'required': True - }, - 'spacing_x': { - 'type': 'float', - 'required': True - }, - 'spacing_y': { - 'type': 'float', - 'required': True - }, - 'spacing_z': { - 'type': 'float', - 'required': True - }, - 'summary_bg_k': { - 'type': 'float', - 'required': True - }, - 'summary_bg_mean': { - 'type': 'float', - 'required': True - }, - 'summary_bg_p05': { - 'type': 'float', - 'required': True - }, - 'summary_bg_p95': { - 'type': 'float', - 'required': True - }, - 'summary_bg_stdv': { - 'type': 'float', - 'required': True - }, - 'summary_csf_k': { - 'type': 'float', - 'required': True - }, - 'summary_csf_mean': { - 'type': 'float', - 'required': True - }, - 'summary_csf_p05': { - 'type': 'float', - 'required': True - }, - 'summary_csf_p95': { - 'type': 'float', - 'required': True - }, - 'summary_csf_stdv': { - 'type': 'float', - 'required': True - }, - 'summary_gm_k': { - 'type': 'float', - 'required': True - }, - 'summary_gm_mean': { - 'type': 'float', - 'required': True - }, - 'summary_gm_p05': { - 'type': 'float', - 'required': True - }, - 'summary_gm_p95': { - 'type': 'float', - 'required': True - }, - 'summary_gm_stdv': { - 'type': 'float', - 'required': True - }, - 'summary_wm_k': { - 'type': 'float', - 'required': True - }, - 'summary_wm_mean':{ - 'type': 'float', - 'required': True - }, - 'summary_wm_p05': { - 'type': 'float', - 'required': True - }, - 'summary_wm_p95': { - 'type': 'float', - 'required': True - }, - 'summary_wm_stdv': { - 'type': 'float', - 'required': True - }, - 'tpm_overlap_csf':{ - 'type': 'float', - 'required': True - }, - 'tpm_overlap_gm': { - 'type': 'float', - 'required': True - }, - 'tpm_overlap_wm': { - 'type': 'float', - 'required': True - }, - 'wm2max':{ - 'type': 'float', - 'required': True - }, + # if modality == T1w, the fields below are required 'AccelNumReferenceLines': {'type': 'integer'}, 'AccelerationFactorPE': {'type': 'integer'}, 'AcquisitionMatrix': {'type': 'string'}, @@ -528,38 +612,46 @@ 'TotalScanTimeSec': {'type': 'integer'}, 'TransmitCoilName': {'type': 'string'}, 'VariableFlipAngleFlag': {'type': 'string'}, - 'ContrastBolusIngredient': {'type': 'string'}, 'Manufacturer': {'type': 'string'}, 'HardcopyDeviceSoftwareVersion': {'type': 'string'}, 'GradientSetType': {'type': 'string'}, - 'MRTransmitCoilSequence':{'type': 'string'}, + 'MRTransmitCoilSequence': {'type': 'string'}, 'MatrixCoilMode': {'type': 'string'}, 'CoilCombinationMethod': {'type': 'string'}, 'PulseSequenceType': {'type': 'string'}, 'PulseSequenceDetails': {'type': 'string'}, - 'NumberShots' :{'type': 'integer'}, - 'ParallelReductionFactorInPlane':{'type': 'float'}, + 'NumberShots': {'type': 'integer'}, + 'ParallelReductionFactorInPlane': {'type': 'float'}, 'ParallelAcquisitionTechnique': {'type': 'string'}, - 'PartialFourier' :{'type': 'boolean'}, - 'PartialFourierDirection':{'type': 'string'}, - 'EffectiveEchoSpacing' :{'type': 'float'}, - 'TotalReadoutTime':{'type': 'float'}, + 'PartialFourier': {'type': 'boolean'}, + 'PartialFourierDirection': {'type': 'string'}, + 'EffectiveEchoSpacing': {'type': 'float'}, + 'TotalReadoutTime': {'type': 'float'}, 'SliceEncodingDirection': {'type': 'string'}, - 'NumberOfVolumesDiscardedByScanner':{'type': 'float'}, - 'NumberOfVolumesDiscardedByUser':{'type': 'float'}, - 'DelayTime':{'type': 'float'}, - 'MultibandAccelerationFactor':{'type': 'float'}, + 'NumberOfVolumesDiscardedByScanner': {'type': 'float'}, + 'NumberOfVolumesDiscardedByUser': {'type': 'float'}, + 'DelayTime': {'type': 'float'}, + 'MultibandAccelerationFactor': {'type': 'float'}, 'Instructions': {'type': 'string'}, 'TaskDescription': {'type': 'string'}, - 'CogAtlasID' : {'type': 'string'}, + 'CogAtlasID': {'type': 'string'}, 'CogPOID': {'type': 'string'}, 'InstitutionName': {'type': 'string'}, 'InstitutionAddress': {'type': 'string'}, 'ConversionSoftware': {'type': 'string'}, 'ConversionSoftwareVersion': {'type': 'string'}, - }#end of schema - } # end of T1w - + } # end of schema + } # end of T1w + } -} \ No newline at end of file +} + + +my_settings['DOMAIN']['bold']['schema'].update(bids_schema) +my_settings['DOMAIN']['bold']['schema'].update(settings_schema) +my_settings['DOMAIN']['bold']['schema'].update(bold_iqms_schema) + +my_settings['DOMAIN']['T1w']['schema'].update(bids_schema) +my_settings['DOMAIN']['T1w']['schema'].update(settings_schema) +my_settings['DOMAIN']['T1w']['schema'].update(t1w_iqms_schema) From 67b3461add44f8858b1a23313be4a91205e9fa71 Mon Sep 17 00:00:00 2001 From: oesteban Date: Fri, 26 May 2017 14:20:19 -0700 Subject: [PATCH 2/3] fix typo --- dockereve-master/eve-app/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockereve-master/eve-app/settings.py b/dockereve-master/eve-app/settings.py index 69a5609..ab20890 100644 --- a/dockereve-master/eve-app/settings.py +++ b/dockereve-master/eve-app/settings.py @@ -524,7 +524,7 @@ 'InversionTime': {'type': 'float'}, 'MRAcquisitionType': {'type': 'string'}, 'MagneticFieldStrength': {'type': 'integer'}, - 'ManufacturersModelName': {'type': 'string'}, + 'ManufacturerModelName': {'type': 'string'}, 'NumberOfAverages': {'type': 'integer'}, 'NumberOfPhaseEncodingSteps': {'type': 'integer'}, 'PatientPosition': {'type': 'string'}, From d33c0b7fffd0efea11f1eb22bde91e6ca7af2819 Mon Sep 17 00:00:00 2001 From: oesteban Date: Fri, 26 May 2017 15:46:10 -0700 Subject: [PATCH 3/3] fix examples, do not set required for new iqms, code cleanup in tests --- dockereve-master/eve-app/settings.py | 40 ++---- test/bold/validData/image_bold.json | 17 ++- test/testGetPost.py | 201 +++++++++++++++------------ 3 files changed, 135 insertions(+), 123 deletions(-) diff --git a/dockereve-master/eve-app/settings.py b/dockereve-master/eve-app/settings.py index ab20890..713f938 100644 --- a/dockereve-master/eve-app/settings.py +++ b/dockereve-master/eve-app/settings.py @@ -103,10 +103,6 @@ 'type': 'float', 'required': True }, - 'task_id': { - 'type': 'string', - 'required': True - }, 'size_t': { 'type': 'float', 'required': True @@ -357,12 +353,10 @@ 'required': True }, 'summary_bg_median': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_bg_mad': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_bg_p05': { 'type': 'float', @@ -377,8 +371,7 @@ 'required': True }, 'summary_bg_n': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_csf_k': { 'type': 'float', @@ -389,12 +382,10 @@ 'required': True }, 'summary_csf_median': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_csf_mad': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_csf_p05': { 'type': 'float', @@ -409,8 +400,7 @@ 'required': True }, 'summary_csf_n': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_gm_k': { 'type': 'float', @@ -421,12 +411,10 @@ 'required': True }, 'summary_gm_median': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_gm_mad': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_gm_p05': { 'type': 'float', @@ -441,8 +429,7 @@ 'required': True }, 'summary_gm_n': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_wm_k': { 'type': 'float', @@ -453,12 +440,10 @@ 'required': True }, 'summary_wm_median': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_wm_mad': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'summary_wm_p05': { 'type': 'float', @@ -473,8 +458,7 @@ 'required': True }, 'summary_wm_n': { - 'type': 'float', - 'required': True + 'type': 'float' }, 'tpm_overlap_csf': { 'type': 'float', diff --git a/test/bold/validData/image_bold.json b/test/bold/validData/image_bold.json index afe6683..0431ce1 100755 --- a/test/bold/validData/image_bold.json +++ b/test/bold/validData/image_bold.json @@ -1,5 +1,4 @@ { - "modality" : "bold", "aor": 0.034428499999999994, "aqi": 0.0005224403999999999, "dvars_nstd": 10.191722418947368, @@ -17,7 +16,6 @@ "gcor": 0.2162099838256836, "gsr_x": -0.004743137396872044, "gsr_y": 0.02154964953660965, - "task_id": "rhymejudgment", "size_t": 20, "size_x": 16, "size_y": 16, @@ -29,13 +27,26 @@ "spacing_z": 16, "summary_bg_k": 10.199746320897564, "summary_bg_mean": 10.67599868774414, + "summary_bg_median": 10.67599868774414, "summary_bg_p05": 3.4488043785095215, "summary_bg_p95": 21.972539520263666, "summary_bg_stdv": 5.769111156463623, + "summary_bg_mad": 5.769111156463623, + "summary_bg_n": 5000000, "summary_fg_k": -1.6145134278870812, "summary_fg_mean": 290.6355895996094, + "summary_fg_median": 290.6355895996094, "summary_fg_p05": 13.376275062561035, "summary_fg_p95": 631.4849853515625, "summary_fg_stdv": 238.1324462890625, - "tsnr": 108.249267578125 + "summary_fg_mad": 238.1324462890625, + "summary_fg_n": 2000000, + "tsnr": 108.249267578125, + "modality" : "bold", + "subject_id": "203902", + "task_id": "rhymejudgment", + "TaskName": "Rhyme Judgment", + "version": "0.9.4", + "md5sum": "75cab8005361c2504ba5a7f02ecbacd7", + "software": "mriqc" } \ No newline at end of file diff --git a/test/testGetPost.py b/test/testGetPost.py index d0830fd..c8d6b9a 100644 --- a/test/testGetPost.py +++ b/test/testGetPost.py @@ -1,164 +1,181 @@ -import requests, json, unittest, os.path, logging, sys +import requests +import json +import unittest +import os.path +import logging +import sys from glob import glob # test data directory boldPattern = os.path.join('test/bold/validData', '*.json') -T1wPattern = os.path.join('test/T1w/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') +T1wMissingPattern = os.path.join('test/T1w/missingField', '*.json') # url for GET -def getURL(postResponse, url): - dirID = postResponse.json()["_id"] +def getURL(post_resp, url): + dirID = post_resp.json()["_id"] resURL = url + "/" + dirID - return resURL + return resURL -def getRequest(postResponse, url): + +def getRequest(post_resp, url): # GET - getResponse = requests.get(getURL(postResponse, url)) - return getResponse.json() + get_resp = requests.get(getURL(post_resp, url)) + return get_resp.json() ###### MAIN ###### header = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8'} numOfTestData = 84 urlBold = "http://localhost:80/bold" -urlT1w = "http://localhost:80/T1w" +urlT1w = "http://localhost:80/T1w" codeForInvalid = 422 + class TestCase(unittest.TestCase): + def test_00_GETAllData(self): - log= logging.getLogger( "SomeTest.testSomething" ) + log = logging.getLogger("SomeTest.testSomething") - inputCount = 0 - for fileName in glob(T1wPattern): - with open(fileName) as fp: - inputCount += 1 - inputData = json.load(fp) - # POST request - postResponse = requests.post(urlT1w, data = json.dumps(inputData), headers = header) + input_count = 0 + for file_name in glob(T1wPattern): + with open(file_name) as fp: + input_data = json.load(fp) + + input_count += 1 + # POST request + requests.post( + urlT1w, data=json.dumps(input_data), headers=header) # GET request # print requests.get(urlT1w) - getResponse = requests.get(urlT1w).json() - log.debug( "total: %r", getResponse['_meta']['total'] ) - self.assertTrue( inputCount == getResponse['_meta']['total'] ) + get_resp = requests.get(urlT1w).json() + log.debug("total: %d (input_count=%d)", get_resp['_meta']['total'], input_count) + self.assertTrue(input_count == get_resp['_meta']['total']) ########## 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 ) + log = logging.getLogger("SomeTest.testSomething") + + for file_name in glob(boldPattern): + with open(file_name) as fp: + input_data = json.load(fp) + + # POST request + post_resp = requests.post( + urlBold, data=json.dumps(input_data), headers=header) + self.assertTrue(post_resp.raise_for_status() is None) + # GET request + get_resp = requests.get(getURL(post_resp, urlBold)) + self.assertTrue(get_resp.raise_for_status() is 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) + log = logging.getLogger("SomeTest.testSomething") + + for file_name in glob(boldMissingPattern): + with open(file_name) as fp: + input_data = 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 ) + post_resp = requests.post( + urlBold, data=json.dumps(input_data), headers=header) + # print post_resp.status_code + self.assertTrue(post_resp.status_code == codeForInvalid) ########## Testing T1w ############ def test_03_ConnectionStatus(self): - log= logging.getLogger( "SomeTest.testSomething" ) - - for fileName in glob(T1wPattern): - with open(fileName) as fp: - inputData = json.load(fp) - # print inputData + log = logging.getLogger("SomeTest.testSomething") + + for file_name in glob(T1wPattern): + with open(file_name) as fp: + input_data = json.load(fp) + # print input_data # POST request - postResponse = requests.post(urlT1w, data = json.dumps(inputData), headers = header) - self.assertTrue( postResponse.raise_for_status() == None ) + post_resp = requests.post( + urlT1w, data=json.dumps(input_data), headers=header) + self.assertTrue(post_resp.raise_for_status() is None) # GET request - getResponse = requests.get( getURL(postResponse, urlT1w) ) - self.assertTrue( getResponse.raise_for_status() == None ) + get_resp = requests.get(getURL(post_resp, urlT1w)) + self.assertTrue(get_resp.raise_for_status() is None) def test_04_MissingFieldInput(self): - log= logging.getLogger( "SomeTest.testSomething" ) - - for fileName in glob(T1wMissingPattern): - with open(fileName) as fp: - inputData = json.load(fp) + log = logging.getLogger("SomeTest.testSomething") + + for file_name in glob(T1wMissingPattern): + with open(file_name) as fp: + input_data = 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 ) + post_resp = requests.post( + urlT1w, data=json.dumps(input_data), headers=header) + # print post_resp.status_code + self.assertTrue(post_resp.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) + log = logging.getLogger("SomeTest.testSomething") + + for file_name in glob(boldPattern): + with open(file_name) as fp: + input_data = json.load(fp) # POST request - postResponse = requests.post(urlT1w, data = json.dumps(inputData), headers = header) - self.assertTrue( postResponse.status_code == codeForInvalid ) + post_resp = requests.post( + urlT1w, data=json.dumps(input_data), headers=header) + self.assertTrue(post_resp.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) + log = logging.getLogger("SomeTest.testSomething") + + for file_name in glob(T1wPattern): + with open(file_name) as fp: + input_data = json.load(fp) # POST request - postResponse = requests.post(urlBold, data = json.dumps(inputData), headers = header) - self.assertTrue( postResponse.status_code == codeForInvalid ) + post_resp = requests.post( + urlBold, data=json.dumps(input_data), headers=header) + self.assertTrue(post_resp.status_code == codeForInvalid) def test_07_T1wDataValid(self): - for fileName in glob(T1wPattern): - with open(fileName) as fp: - inputData = json.load(fp) + for file_name in glob(T1wPattern): + with open(file_name) as fp: + input_data = json.load(fp) # 2. POST request - postResponse = requests.post(urlT1w, data = json.dumps(inputData), headers = header) + post_resp = requests.post( + urlT1w, data=json.dumps(input_data), headers=header) # 3. GET request - queriedData = getRequest(postResponse, urlT1w) + queried_data = getRequest(post_resp, urlT1w) # 4. validate input data and queried data - for key in inputData: + for key in input_data: # check missing key - self.assertTrue(key in queriedData) + self.assertTrue(key in queried_data) # check key-value pair match - self.assertTrue( inputData[key] == queriedData[key] ) - + self.assertTrue(input_data[key] == queried_data[key]) def test_08_boldDataValid(self): - for fileName in glob(boldPattern): - with open(fileName) as fp: - inputData = json.load(fp) + for file_name in glob(boldPattern): + with open(file_name) as fp: + input_data = json.load(fp) # 2. POST request - postResponse = requests.post(urlBold, data = json.dumps(inputData), headers = header) + post_resp = requests.post( + urlBold, data=json.dumps(input_data), headers=header) # 3. GET request - queriedData = getRequest(postResponse, urlBold) + queried_data = getRequest(post_resp, urlBold) # 4. validate input data and queried data - for key in inputData: + for key in input_data: # check missing key - self.assertTrue(key in queriedData) + self.assertTrue(key in queried_data) # check key-value pair match - self.assertTrue( inputData[key] == queriedData[key] ) + self.assertTrue(input_data[key] == queried_data[key]) # **************** if __name__ == '__main__': - logging.basicConfig( stream=sys.stderr ) - logging.getLogger( "SomeTest.testSomething" ).setLevel( logging.DEBUG ) + logging.basicConfig(stream=sys.stderr) + logging.getLogger("SomeTest.testSomething").setLevel(logging.DEBUG) unittest.main()