Exemple #1
0
    def test_histology_insertion_from_track(self):

        for file_track in self.path_tracks.rglob("*_pts.csv"):
            xyz = histology.load_track_csv(file_track)
            insertion = atlas.Insertion.from_track(xyz, brain_atlas=brain_atlas)
            # checks that the tip coordinate is not the deepest point but its projection
            self.assertFalse(np.all(np.isclose(insertion.tip, xyz[-1])))
Exemple #2
0
 def test_histology_get_brain_regions(self):
     # first part of the test is to check on an actual track file
     for file_track in self.path_tracks.rglob("*_pts.csv"):
         xyz = histology.load_track_csv(file_track)
         channels, ins = histology.get_brain_regions(xyz=xyz, brain_atlas=brain_atlas)
     # also check that it works from an insertion
     channels, ins2 = histology.get_brain_regions(xyz=ins.xyz, brain_atlas=brain_atlas)
     self.assertTrue(channels.acronym[-1] == 'VISpm1')
     self.assertTrue(channels.acronym[0] == 'APN')
     a = np.array([ins.x, ins.y, ins.z, ins.phi, ins.theta, ins.depth])
     b = np.array([ins2.x, ins2.y, ins2.z, ins2.phi, ins2.theta, ins2.depth])
     self.assertTrue(np.all(np.isclose(a, b)))
environment installation guide https://github.com/int-brain-lab/iblenv
'''
# Author: Olivier Winter

import numpy as np

from ibllib.pipes import histology
import ibllib.atlas as atlas

# === Parameters section (edit) ===
track_file = "/Users/gaelle/Downloads/electrodetracks_lic3/2019-08-27_lic3_002_probe00_pts.csv"
FULL_BLOWN_GUI = True  # set to False for simple matplotlib view

# === Code (do not edit) ===
ba = atlas.AllenAtlas(res_um=25)
xyz_picks = histology.load_track_csv(track_file)
bl, ins = histology.get_brain_regions(xyz_picks)

if FULL_BLOWN_GUI:
    from iblapps.histology import atlas_mpl
    mw, cax = atlas_mpl.viewatlas(ba, ap_um=np.mean(ins.xyz[:, 1]) * 1e6)
else:
    cax = ba.plot_cslice(ap_coordinate=np.mean(ins.xyz[:, 1]))

cax.plot(ins.xyz[:, 0] * 1e6, ins.xyz[:, 2] * 1e6)
cax.plot(bl.xyz[:, 0] * 1e6, bl.xyz[:, 2] * 1e6, '*')
# cax.plot(ba.bc.xscale * 1e6, ba.top[ba.bc.y2i(np.mean(ins.xyz[:, 1])), :] * 1e6)

if FULL_BLOWN_GUI:
    mw.mpl_widget.draw()