Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces the ability to select which eigenvalue to work with in app.py, with a default of second eigenvalue. This change gives flexibility to the application while maintaining the existing functionality of the vb_index code. Also it helps users to have control over which eigenvalue they work with, enhancing the capacity of the application of VB index.
Chnages that are made in the code:
APP.PY
parser.add_argument('-e', '--eigenvalue-index', metavar='INDEX', type=int, nargs=1, default=1, help="""Index of the eigenvalue to use. Default is the second smallest eigenvalue (index 1).""")
eigenvalue_index = args.eigenvalue_index
vb_index.compute_vb_metrics(internal_loop_func="vb_vol", n_cpus=n_cpus, data=data, affine=affine, header=header, norm=L_norm, cort_index=cort_index, brain_mask=brain_mask, residual_tolerance=args.tol[0], max_num_iter=args.maxiter[0], eigenvalue_index=eigenvalue_index, output_name=args.output[0] + "." + L_norm, reho=args.reho)
VB_INDEX.PY
def compute_vb_metrics(internal_loop_func, n_cpus, data, norm, residual_tolerance, max_num_iter, eigenvalue_index, header=None, brain_mask=None, surf_vertices=None, surf_faces=None, output_name=None, nib_surf=None, k=None, cluster_index=None, cort_index=None, affine=None, reho=False, full_brain=False, debug=False):
results = run_multiprocessing(pool, internal_loop_func, n_items, dn, surf_vertices, surf_faces, data, norm, residual_tolerance, max_num_iter, eigenvalue_index, cluster_index, cort_index, affine, k, reho, full_brain, brain_mask, debug)
def run_multiprocessing(pool, internal_loop_func, n_items, dn, surf_vertices, surf_faces, data, norm, residual_tolerance, max_num_iter, eigenvalue_index, cluster_index, cort_index, affine, k, reho, full_brain, brain_mask, debug):
threads = np.append(threads, (pool.apply_async(vb_vol_internal_loop, (i0, iN, data, norm, brain_mask, residual_tolerance, max_num_iter, eigenvalue_index, reho, debug), error_callback=pool_callback)))
def vb_vol_internal_loop(i0, iN, data, norm, brain_mask, residual_tolerance, max_num_iter, eigenvalue_index, reho, debug=False):
compute_vol(neighborhood, i, idx, loc_result, affinity, vox_coords, residual_tolerance, max_num_iter, eigenvalue_index, norm)
def compute_vol(neighborhood, i, idx, loc_result, affinity, vox_coords, residual_tolerance, max_num_iter, eigenvalue_index, norm):
_, _, eigenvalue, _ = spectral_reorder(False, affinity, residual_tolerance, max_num_iter, eigenvalue_index, norm)
def get_fiedler_eigenpair(eigenvalue_index, method, full_brain, Q, D=None, is_symmetric=True, tol='def_tol', maxiter=50):
def spectral_reorder(full_brain, B, residual_tolerance, max_num_iter, eigenvalue_index, method='unnorm'):
vbi_value, eigenvector = get_fiedler_eigenpair(eigenvalue_index, method, full_brain, Q, tol=residual_tolerance, maxiter=max_num_iter)