Exemple #1
0
    def compute_coverage(self, all_channels):

        start = time.time()
        cvol = np.zeros(self.ba.image.shape, dtype=np.float)
        val, counts = np.unique(self.ba._lookup(all_channels), return_counts=True)
        #cvol[np.unravel_index(val, cvol.shape)] = counts
        cvol[np.unravel_index(val, cvol.shape)] = 1

        DIST_FCN = np.array([100, 150]) / 1e6
        dx = self.ba.bc.dx
        template = np.arange(- np.max(DIST_FCN) - dx, np.max(DIST_FCN) + 2 * dx, dx) ** 2
        kernel = sum(np.meshgrid(template, template, template))
        kernel = 1 - fcn_cosine(DIST_FCN)(np.sqrt(kernel))
        #
        cvol = fftconvolve(cvol, kernel, mode='same')
        end = time.time()
        print(end-start)
        self.cvol = cvol
        self.cvol_flat = cvol.flatten()

        return cvol
Exemple #2
0
 def test_dsp_cosine_func(self):
     x = np.linspace(0, 40)
     fcn = fcn_cosine(bounds=[20, 30])
     y = fcn(x)
     self.assertTrue(y[0] == 0 and y[-1] == 1 and np.all(np.diff(y) >= 0))
Exemple #3
0
import numpy as np

from ibllib.dsp import fcn_cosine
import ibllib.atlas as atlas
from ibllib.pipes.histology import coverage

from oneibl.one import ONE
one = ONE()

ba = atlas.AllenAtlas()
# trajs = one.alyx.rest('trajectories', 'list', provenance='Ephys aligned histology track')

trajs = one.alyx.rest('trajectories', 'list', provenance='Micro-manipulator',
                      django='probe_insertion__session__project__name__icontains,'
                             'ibl_neuropixel_brainwide_01,'
                             'probe_insertion__session__qc__lt,40')

full_coverage = coverage(trajs)

fig, axs = plt.subplots(2, 2)
ax = ba.plot_hslice(-4000 * 1e-6, volume=full_coverage, ax=axs[0, 0])
ax.set_title("horizontal slice at dv=-4mm")
ax = ba.plot_sslice(ml_coordinate=-0.002, volume=full_coverage, ax=axs[0, 1])
ax.set_title("sagittal slice at ml=-2mm")
ax = ba.plot_cslice(ap_coordinate=-0.003, volume=full_coverage, ax=axs[1, 1])
ax.set_title("coronal slice at ap=-3mm")

axs[1, 0].plot(np.linspace(0, 200), 1 - fcn_cosine([100, 150])(np.linspace(0, 200)))
axs[1, 0].set_xlabel('distance from nearest active site (um)')
axs[1, 0].set_ylabel('weight')