def compute_error_map(data_path):
    error_map_sum = None
    error_map_abs_sum = None
    first = True
    n_slices = 0
    os.chdir(data_path)
    for file_name in os.listdir('.'):
        if os.path.isdir(file_name) and file_name != 'dictionary':
            os.chdir(file_name)

            res = ''
            ref_wm_seg = ''

            for slice_file in os.listdir('.'):
                if slice_file in 'graymatterseg':
                    res = slice_file
                elif 'inv_to_wm' in slice_file:
                    ref_wm_seg = slice_file
            res_im = Image(res)
            ref_wm_seg_im = Image(ref_wm_seg)

            if first:
                error_map_sum = np.zeros(ref_wm_seg_im.data.shape)
                error_map_abs_sum = np.zeros(ref_wm_seg_im.data.shape)
                first = False

            error_3d = (ref_wm_seg_im.data - res_im.data) + 1
            error_3d_abs = abs(ref_wm_seg_im.data - res_im.data)

            error_map_sum += error_3d
            error_map_abs_sum += error_3d_abs
            n_slices += 1
            os.chdir('..')

    Image(param=(error_map_sum/n_slices) - 1, absolutepath='error_map.nii.gz').save()
    Image(param=error_map_abs_sum/n_slices, absolutepath='error_map_abs.nii.gz').save()


# ------------------------------------------------------------------------------------------------------------------
dataset/ETHPy150Open neuropoly/spinalcordtoolbox/scripts/msct_gmseg_utils.py/compute_error_map/swapped operands of `in`