def METHOD_NAME(D):
    Y, C, S, A, centers, dims, shifts = gen_data(D)
    fname = 'testMovie.tif'
    cm.movie(Y).save(fname)
    params_dict = {'max_shifts': (4, 4),   # maximum allowed rigid shifts (in pixels)
                   'pw_rigid': False,      # flag for performing non-rigid motion correction
                   'border_nan': True,
                   'is3D': D == 3}
    opts = cm.source_extraction.cnmf.params.CNMFParams(params_dict=params_dict)
    mc = MotionCorrect(fname, dview=None, **opts.get_group('motion'))
    mc.motion_correct(save_movie=True)
    npt.assert_(np.corrcoef(shifts.T, np.transpose(mc.shifts_rig))[:D, D:].diagonal().mean() > .8)
    Y_cor = cm.load(mc.mmap_file, is3D=(D == 3))
    nans = np.isnan(Y_cor)
    npt.assert_(np.corrcoef(Y_cor[~nans], Y[~nans])[0, 1] > .8)