def test_invalid_nbins(): with raises(ValueError): ew = graynet.extract(subject_id_list, fs_dir, num_bins=np.NaN) with raises(ValueError): ew = graynet.extract(subject_id_list, fs_dir, num_bins=np.Inf) with raises(ValueError): ew = graynet.extract(subject_id_list, fs_dir, num_bins=2)
def test_atlas_parcel_subdivision(): wm = 'manhattan' # much slower: zip(cfg.allowed_mvpp, cfg.mvpp_to_total_num_patches) for mvpp, tot_patch_count in zip((1000, 10000), (273, 68)): edge_weights_all = extract(subject_id_list, example_dir, base_feature=base_feature, weight_method_list=[ wm, ], atlas='fsaverage', node_size=mvpp, smoothing_param=fwhm, out_dir=out_dir, return_results=True, num_procs=1) num_combinations = len(list(edge_weights_all)) if num_combinations != len(subject_id_list): raise ValueError('mvpp: invalid count : # subjects') num_links = tot_patch_count * (tot_patch_count - 1) / 2 for sub in subject_id_list: if edge_weights_all[(wm, sub)].size != num_links: raise ValueError('mvpp: invalid count : # links')
def test_run_API_on_original_features(): for base_feature in base_feature_list: for atlas in feature_to_atlas_list[base_feature]: sud_id_list = feature_to_subject_id_list[base_feature] edge_weights_all = extract( sud_id_list, feature_to_in_dir[base_feature], base_feature=base_feature, weight_method_list=weight_methods_orig_feat_subset, atlas=atlas, smoothing_param=fwhm, out_dir=out_dir, return_results=True, num_procs=1) num_combinations = len(list(edge_weights_all)) if num_combinations != len(sud_id_list) * len( weight_methods_orig_feat_subset): raise ValueError('invalid results : # subjects') num_roi_wholebrain = num_roi_atlas[atlas] num_links = num_roi_wholebrain * (num_roi_wholebrain - 1) / 2 for wm in weight_methods_orig_feat_subset: for sub in sud_id_list: if edge_weights_all[(wm, sub)].size != num_links: raise ValueError('invalid results : # links')
def test_run_no_IO(): for base_feature in base_feature_list: for atlas in feature_to_atlas_list[base_feature]: try: sud_id_list = feature_to_subject_id_list[base_feature] edge_weights_all = graynet.extract( sud_id_list, feature_to_in_dir[base_feature], base_feature=base_feature, weight_method_list=weight_methods, atlas=atlas, smoothing_param=fwhm, out_dir=out_dir, return_results=True, num_procs=1) num_combinations = len(list(edge_weights_all)) if num_combinations != len(sud_id_list) * len(weight_methods): raise ValueError('invalid results : # subjects') num_roi_wholebrain = num_roi_atlas[atlas] num_links = num_roi_wholebrain * (num_roi_wholebrain - 1) / 2 for wm in weight_methods: for sub in sud_id_list: if edge_weights_all[(wm, sub)].size != num_links: raise ValueError('invalid results : # links') except: traceback.print_exc() raise
def test_empty_subject_list(): # API with raises(ValueError): ew = graynet.extract([], fs_dir) # in CLI, only non-Freesurfer lead to an error for feat in cfg.features_volumetric: # invalid list with raises(ValueError): sys.argv = shlex.split('graynet -i {} -f {}'.format(fs_dir, feat)) run_cli()
def test_run_no_IO(): edge_weights_all = graynet.extract(subject_id_list, fs_dir, base_feature=base_feature, weight_method_list=weight_methods, atlas=atlas, smoothing_param=fwhm, out_dir=out_dir, return_results=True, num_procs=4) num_combinations = len(list(edge_weights_all)) if num_combinations != len(subject_id_list) * len(weight_methods): raise ValueError('invalid results : # subjects') for wm in weight_methods: for sub in subject_id_list: if edge_weights_all[(wm, sub)].size != num_links: raise ValueError('invalid results : # links')
def test_invalid_edge_range(): with raises(ValueError): ew = graynet.extract(subject_id_list, fs_dir, edge_range=-1) with raises(ValueError): ew = graynet.extract(subject_id_list, fs_dir, edge_range=[]) with raises(ValueError): ew = graynet.extract(subject_id_list, fs_dir, edge_range=[ 1, ]) with raises(ValueError): ew = graynet.extract(subject_id_list, fs_dir, edge_range=[1, 2, 3]) with raises(ValueError): ew = graynet.extract(subject_id_list, fs_dir, edge_range=(1, np.NaN)) with raises(ValueError): ew = graynet.extract(subject_id_list, fs_dir, edge_range=(2, 1))
def test_empty_subject_list(): with raises(ValueError): ew = graynet.extract([], fs_dir)