示例#1
0
def denoise_masks(options):
    """
    Denoise input masks to reduce noise.
    Using anisotropic Diffusion (Perona and Malik)

    """

    for mod in options['modalities']:

        current_image = mod + '.nii.gz' if mod == 'T1'\
                        else 'r' + mod + '.nii.gz'

        tmp_scan = nib.load(os.path.join(options['tmp_folder'], current_image))

        tmp_scan.get_data()[:] = ans_dif(tmp_scan.get_data(),
                                         niter=options['denoise_iter'])

        tmp_scan.to_filename(
            os.path.join(options['tmp_folder'], 'd' + current_image))
        if options['debug']:
            print "> DEBUG: Denoising ", current_image
示例#2
0
def denoise_masks(options):
    """
    Denoise input masks to reduce noise.
    Using anisotropic Diffusion (Perona and Malik)

    """
    # if options['register_modalities_kind'] != 'FlairtoT1' and  options['register_modalities_kind'] != 'T1toFlair':
    #     print("registration must be either FlairtoT1 or T1toFlair and not", options['register_modalities_kind'])
    #     print("> ERROR:", "quiting program.")
    #     sys.stdout.flush()
    #     time.sleep(1)
    #     os.kill(os.getpid(), signal.SIGTERM)

    for mod in options['modalities']:

        # current_image = mod + '.nii.gz' if mod == 'T1'\
        #                 else 'r' + mod + '.nii.gz'

        if options['reg_space'] == 'T1toFlair':
            current_image = mod + '.nii.gz' if mod == 'FLAIR' \
                else 'r' + mod + '.nii.gz'

        if options['reg_space'] == 'FlairtoT1':
            current_image = mod + '.nii.gz' if mod == 'T1' \
                else 'r' + mod + '.nii.gz'
        if options['reg_space'] != 'FlairtoT1' and options[
                'reg_space'] != 'T1toFlair':
            current_image = 'r' + mod + '.nii.gz'

        tmp_scan = nib.load(os.path.join(options['tmp_folder'], current_image))

        tmp_scan.get_data()[:] = ans_dif(tmp_scan.get_data(),
                                         niter=options['denoise_iter'])

        tmp_scan.to_filename(
            os.path.join(options['tmp_folder'], 'd' + current_image))
        if options['debug']:
            print("> DEBUG: Denoising ", current_image)