Exemple #1
0
def test_spatial_rate_map_size_error():
    import quantities as pq
    from exana.tracking.fields import spatial_rate_map
    import neo
    # raise error if box length smaller than path
    with pytest.raises(ValueError):
        N = 20
        binsize = 0.2 * pq.m
        box_xlen = 1.0 * pq.m
        box_ylen = 1.0 * pq.m
        x = np.linspace(0., box_xlen.magnitude + 1, N) * pq.m
        y = np.linspace(0., box_ylen.magnitude, N) * pq.m
        t = np.linspace(0, 10., N) * pq.s
        sptr = neo.SpikeTrain(times=np.linspace(0, 10., N * 2) * pq.s,
                              t_stop=max(t))
        ratemap, xbins, ybins = spatial_rate_map(x,
                                                 y,
                                                 t,
                                                 sptr,
                                                 binsize=binsize,
                                                 box_xlen=box_xlen,
                                                 box_ylen=box_ylen,
                                                 mask_unvisited=False,
                                                 convolve=False,
                                                 return_bins=True)
Exemple #2
0
def test_spatial_rate_map_rate_convolve():
    import quantities as pq
    from exana.tracking.fields import spatial_rate_map
    import neo
    N = 20
    binsize = 0.2 * pq.m
    box_xlen = 1.0 * pq.m
    box_ylen = 1.0 * pq.m
    x = np.linspace(0., box_xlen.magnitude, N) * pq.m
    y = np.linspace(0., box_ylen.magnitude, N) * pq.m
    t = np.linspace(0, 10., N) * pq.s
    sptr = neo.SpikeTrain(times=np.linspace(0, 10., N * 2) * pq.s,
                          t_stop=max(t))
    ratemap2 = spatial_rate_map(x,
                                y,
                                t,
                                sptr,
                                binsize=binsize,
                                box_xlen=1.0 * pq.m,
                                box_ylen=1.0 * pq.m,
                                mask_unvisited=False,
                                convolve=True,
                                return_bins=False,
                                smoothing=0.02)
    assert all(np.diff(np.diag(ratemap2)) < 0.02)
Exemple #3
0
def test_spatial_rate_map_rate_shape():
    import quantities as pq
    from exana.tracking.fields import spatial_rate_map
    import neo
    N = 20
    binsize = 0.2 * pq.m
    box_xlen = 1.0 * pq.m
    box_ylen = 1.0 * pq.m
    x = np.linspace(0., box_xlen.magnitude, N) * pq.m
    y = np.linspace(0., box_ylen.magnitude, N) * pq.m
    t = np.linspace(0, 10., N) * pq.s
    sptr = neo.SpikeTrain(times=np.linspace(0, 10., N * 2) * pq.s,
                          t_stop=max(t))
    ratemap, xbins, ybins = spatial_rate_map(x,
                                             y,
                                             t,
                                             sptr,
                                             binsize=binsize,
                                             box_xlen=box_xlen,
                                             box_ylen=box_ylen,
                                             mask_unvisited=False,
                                             convolve=False,
                                             return_bins=True)
    assert all(np.diff(np.diag(ratemap)) < 1e-10)
    assert ratemap.shape == (int(box_xlen / binsize), int(box_ylen / binsize))
    ratemap1 = spatial_rate_map(x,
                                y,
                                t,
                                sptr,
                                binsize=binsize,
                                box_xlen=1.0 * pq.m,
                                box_ylen=1.0 * pq.m,
                                mask_unvisited=False,
                                convolve=False,
                                return_bins=False)
    assert all(np.diag(ratemap - ratemap1) < 1e-10)