def _agg(objekt, runtime): outputs = Bunch(tissue_class_map=os.path.join( datadir, 'testFASTRPT-tissue_class_map.nii.gz'), tissue_class_files=[ os.path.join(datadir, 'testFASTRPT-tissue_class_files0.nii.gz'), os.path.join(datadir, 'testFASTRPT-tissue_class_files1.nii.gz'), os.path.join(datadir, 'testFASTRPT-tissue_class_files2.nii.gz')] ) return outputs
def _agg(objekt, runtime): outputs = Bunch(out_lta_file=os.path.join( datadir, 'testBBRegisterRPT-out_lta_file.lta'), ) return outputs
def _agg(objekt, runtime): outputs = Bunch(warped_image=os.path.join( datadir, 'testANTSRegistrationRPT-warped_image.nii.gz')) return outputs
def _agg(objekt, runtime): outputs = Bunch(warped_image=os.path.join( datadir, 'testRobustMNINormalizationRPTMovingWarpedImage.nii.gz')) return outputs
def upload_qc_metrics(in_iqms, loc, path='', scheme='http', port=None, email=None): """ Upload qc metrics to remote repository. :param str in_iqms: Path to the qc metric json file as a string :param str scheme: the protocol (either http or https) :param str email: email address to be included with the metric submission :param bool upload_strict: the client should fail if it's strict mode :return: either the response object if a response was successfully sent or it returns the string "No Response" :rtype: object """ from json import load, dumps import requests from io import open from copy import deepcopy if port is None: port = 443 if scheme == 'https' else 80 with open(in_iqms, 'r') as input_json: in_data = load(input_json) # Extract metadata and provenance meta = in_data.pop('bids_meta') prov = in_data.pop('provenance') # At this point, data should contain only IQMs data = deepcopy(in_data) # Check modality modality = meta.get('modality', 'None') if modality not in ('T1w', 'bold', 'T2w'): errmsg = ( 'Submitting to MRIQCWebAPI: image modality should be "bold", "T1w", or "T2w", ' '(found "%s")' % modality) return Bunch(status_code=1, text=errmsg) # Filter metadata values that aren't in whitelist data['bids_meta'] = {k: meta[k] for k in META_WHITELIST if k in meta} # Filter provenance values that aren't in whitelist data['provenance'] = {k: prov[k] for k in PROV_WHITELIST if k in prov} # Hash fields that may contain personal information data['bids_meta'] = _hashfields(data['bids_meta']) if email: data['provenance']['email'] = email if path and not path.endswith('/'): path += '/' if path.startswith('/'): path = path[1:] headers = {'Authorization': SECRET_KEY, "Content-Type": "application/json"} webapi_url = '{}://{}:{}/{}{}'.format(scheme, loc, port, path, modality) IFLOGGER.info('MRIQC Web API: submitting to <%s>', webapi_url) try: # if the modality is bold, call "bold" endpoint response = requests.post(webapi_url, headers=headers, data=dumps(data)) except requests.ConnectionError as err: errmsg = 'QC metrics failed to upload due to connection error shown below:\n%s' % err return Bunch(status_code=1, text=errmsg) return response
def _agg(objekt, runtime): outputs = Bunch(BrainExtractionMask=os.path.join( datadir, 'testBrainExtractionRPTBrainExtractionMask.nii.gz') ) return outputs