# run "%qui qt" magic command from Ipython prompt for interactive mode import pandas as pd from mayavi import mlab from atlaselectrophysiology import rendering import ibllib.atlas as atlas # the csv file is available here: # https://github.com/int-brain-lab/ibllib-matlab/blob/master/needles/maps/first_pass_map.csv output_video = '/home/olivier/Videos/first_pass.webm' csv_file = "/home/olivier/Documents/MATLAB/ibllib-matlab/needles/maps/first_pass_map.csv" # start of the code brain_atlas = atlas.AllenAtlas(25) brain_atlas = atlas.NeedlesAtlas(25) df_map = pd.read_csv(csv_file) fig = rendering.figure() plt_trj = [] for index, rec in df_map.iterrows(): ins = atlas.Insertion.from_dict({'x': rec.ml_um, 'y': rec.ap_um, 'z': rec.dv_um, 'phi': rec.phi, 'theta': rec.theta, 'depth': rec.depth_um}) mlapdv = brain_atlas.xyz2ccf(ins.xyz) plt = mlab.plot3d(mlapdv[:, 1], mlapdv[:, 2], mlapdv[:, 0], line_width=3, color=(1, .6, .6), tube_radius=15) plt_trj.append(plt) ##
# environment installation guide https://github.com/int-brain-lab/iblenv # run "%qui qt" magic command from Ipython prompt for interactive mode from mayavi import mlab from one.api import ONE from atlaselectrophysiology import rendering import ibllib.atlas as atlas one = ONE(base_url="https://alyx.internationalbrainlab.org") fig = rendering.figure() subject = 'KS003' trajs = one.alyx.rest('trajectories', 'list', subject=subject) ba_allen = atlas.AllenAtlas(25) ba_needles = atlas.NeedlesAtlas(25) plt_trj = [] for index, trj in enumerate(trajs): if trj['coordinate_system'] == 'IBL-Allen': brain_atlas = ba_allen elif trj['coordinate_system'] == 'Needles-Allen': brain_atlas = ba_needles ins = atlas.Insertion.from_dict(trj, brain_atlas=brain_atlas) ins = atlas.Insertion.from_dict(trj, brain_atlas=ba_allen) mlapdv = brain_atlas.xyz2ccf(ins.xyz) if trj['provenance'] == 'Micro-manipulator': color = (0., 1., 0.) # Green elif trj['provenance'] == 'Histology track': color = (1., 0., 0.) # Red