Exemple #1
0
def compute_voxel_measures(args):
    bundle_filename, bundle_reference = args[0]
    tracking_mask = args[1]
    gs_binary_3d = args[2]

    bundle_sft = load_tractogram(bundle_filename, bundle_reference)
    bundle_sft.to_vox()
    bundle_sft.to_corner()
    bundle_streamlines = bundle_sft.streamlines
    _, bundle_dimensions, _, _ = bundle_sft.space_attributes

    if not bundle_streamlines:
        logging.info('{} is empty'.format(bundle_filename))
        return None

    binary_3d = compute_tract_counts_map(bundle_streamlines, bundle_dimensions)
    binary_3d[binary_3d > 0] = 1

    binary_3d_indices = np.where(binary_3d.flatten() > 0)[0]
    gs_binary_3d_indices = np.where(gs_binary_3d.flatten() > 0)[0]

    voxels_binary = binary_classification(
        binary_3d_indices,
        gs_binary_3d_indices,
        int(np.prod(tracking_mask.shape)),
        mask_count=np.count_nonzero(tracking_mask))

    return dict(
        zip([
            'sensitivity_voxels', 'specificity_voxels', 'precision_voxels',
            'accuracy_voxels', 'dice_voxels', 'kappa_voxels', 'youden_voxels'
        ], voxels_binary))
Exemple #2
0
def compute_streamlines_measures(args):
    bundle_filename, bundle_reference = args[0]
    wb_streamlines = args[1]
    gs_streamlines_indices = args[2]

    if not os.path.isfile(bundle_filename):
        logging.info('{} does not exist'.format(bundle_filename))
        return None

    bundle_sft = load_tractogram(bundle_filename, bundle_reference)
    bundle_sft.to_vox()
    bundle_sft.to_corner()
    bundle_streamlines = bundle_sft.streamlines
    _, bundle_dimensions, _, _ = bundle_sft.space_attributes

    if not bundle_streamlines:
        logging.info('{} is empty'.format(bundle_filename))
        return None

    _, streamlines_indices = perform_streamlines_operation(
        intersection, [wb_streamlines, bundle_streamlines], precision=0)

    streamlines_binary = binary_classification(streamlines_indices,
                                               gs_streamlines_indices,
                                               len(wb_streamlines))

    return dict(
        zip([
            'sensitivity_streamlines', 'specificity_streamlines',
            'precision_streamlines', 'accuracy_streamlines',
            'dice_streamlines', 'kappa_streamlines', 'youden_streamlines'
        ], streamlines_binary))