ibllib.pipes.histology

Functions

coverage

Computes a coverage volume from :param trajs: dictionary of trajectories from Alyx rest endpoint (one.alyx.rest…) :param ba: ibllib.atlas.BrainAtlas instance :return: 3D np.array the same size as the volume provided in the brain atlas

coverage_grid

create_channel_dict

Create channel dictionary in form to upload to alyx :param traj: alyx trajectory object to attach channel information to :type traj: dict :param brain_locations: information about location of electrode channels in brain atlas :type insertion: Bunch :return tdict: :type tdict: list of dict

create_trajectory_dict

Create trajectory dictionary in form to upload to alyx :param probe id: unique id of probe insertion :type probe_id: string (hexadecimal UUID) :param insertion: Insertion object describing entry and tip of trajectory :type insertion: object atlas.Insertion :param provenance: ‘Histology track’ or ‘Ephys aligned histology track’ :type provenance: string :return tdict: :type tdict: dict

detect_missing_histology_tracks

Compares the number of probe insertions to the number of registered histology tracks to see if there is a discrepancy so that missing tracks can be properly logged in the database :param path_tracks: path to track files to be registered :param subject: subject nickname for which to detect missing tracks

get_brain_regions

param xyz

numpy array of 3D coordinates corresponding to a picked track or a trajectory

get_micro_manipulator_data

Looks for all ephys sessions for a given subject and get the probe micro-manipulator trajectories.

get_picked_tracks

This outputs reads in the Lasagna output and converts the picked tracks in the IBL coordinates :param histology_path: Path object: folder path containing tracks :return: xyz coordinates in

interpolate_along_track

Get the coordinates of points along a track according to their distances from the first point.

load_track_csv

Loads a lasagna track and convert to IBL-ALlen coordinate framework :param file_track: :return: xyz

plot2d_all

Plot all tracks on a single 2d slice :param trajectories: dictionary output of the Alyx REST query on trajectories :param tracks: :return:

plot3d_all

Plot all tracks on a single 2d slice :param trajectories: dictionary output of the Alyx REST query on trajectories :param tracks: :return:

register_aligned_track

Register ephys aligned trajectory and channel locations to Alyx Here we update Alyx models on the database in 2 steps 1) The trajectory computed from the final electrode channel locations 2) Channel locations are set to the trajectory

register_track

Register the user picks to a probe in Alyx Here we update Alyx models on the database in 3 steps 1) The user picks converted to IBL coordinates will be stored in the json field of the corresponding probe insertion models 2) The trajectory computed from the histology track is created or patched 3) Channel locations are set in the table

register_track_files

param path_tracks

path to directory containing tracks; also works with a single file name

load_track_csv(file_track)[source]

Loads a lasagna track and convert to IBL-ALlen coordinate framework :param file_track: :return: xyz

get_picked_tracks(histology_path, glob_pattern='*_pts_transformed.csv')[source]

This outputs reads in the Lasagna output and converts the picked tracks in the IBL coordinates :param histology_path: Path object: folder path containing tracks :return: xyz coordinates in

get_micro_manipulator_data(subject, one=None, force_extract=False)[source]

Looks for all ephys sessions for a given subject and get the probe micro-manipulator trajectories. If probes ALF object not on flat-iron, attempts to perform the extraction from meta-data and task settings file.

plot2d_all(trajectories, tracks)[source]

Plot all tracks on a single 2d slice :param trajectories: dictionary output of the Alyx REST query on trajectories :param tracks: :return:

plot3d_all(trajectories, tracks)[source]

Plot all tracks on a single 2d slice :param trajectories: dictionary output of the Alyx REST query on trajectories :param tracks: :return:

interpolate_along_track(xyz_track, depths)[source]

Get the coordinates of points along a track according to their distances from the first point. :param xyz_track: np.array [npoints, 3]. Usually the first point is the deepest :param depths: distance from the first point of the track, usually the convention is the deepest point is 0 and going up :return: xyz_channels

get_brain_regions(xyz, channels_positions=array([[ 43., 20.], [ 11., 20.], [ 59., 40.], [ 27., 40.], [ 43., 60.], [ 11., 60.], [ 59., 80.], [ 27., 80.], [ 43., 100.], [ 11., 100.], [ 59., 120.], [ 27., 120.], [ 43., 140.], [ 11., 140.], [ 59., 160.], [ 27., 160.], [ 43., 180.], [ 11., 180.], [ 59., 200.], [ 27., 200.], [ 43., 220.], [ 11., 220.], [ 59., 240.], [ 27., 240.], [ 43., 260.], [ 11., 260.], [ 59., 280.], [ 27., 280.], [ 43., 300.], [ 11., 300.], [ 59., 320.], [ 27., 320.], [ 43., 340.], [ 11., 340.], [ 59., 360.], [ 27., 360.], [ 11., 380.], [ 59., 400.], [ 27., 400.], [ 43., 420.], [ 11., 420.], [ 59., 440.], [ 27., 440.], [ 43., 460.], [ 11., 460.], [ 59., 480.], [ 27., 480.], [ 43., 500.], [ 11., 500.], [ 59., 520.], [ 27., 520.], [ 43., 540.], [ 11., 540.], [ 59., 560.], [ 27., 560.], [ 43., 580.], [ 11., 580.], [ 59., 600.], [ 27., 600.], [ 43., 620.], [ 11., 620.], [ 59., 640.], [ 27., 640.], [ 43., 660.], [ 11., 660.], [ 59., 680.], [ 27., 680.], [ 43., 700.], [ 11., 700.], [ 59., 720.], [ 27., 720.], [ 43., 740.], [ 11., 740.], [ 59., 760.], [ 43., 780.], [ 11., 780.], [ 59., 800.], [ 27., 800.], [ 43., 820.], [ 11., 820.], [ 59., 840.], [ 27., 840.], [ 43., 860.], [ 11., 860.], [ 59., 880.], [ 27., 880.], [ 43., 900.], [ 11., 900.], [ 59., 920.], [ 27., 920.], [ 43., 940.], [ 11., 940.], [ 59., 960.], [ 27., 960.], [ 43., 980.], [ 11., 980.], [ 59., 1000.], [ 27., 1000.], [ 43., 1020.], [ 11., 1020.], [ 59., 1040.], [ 27., 1040.], [ 43., 1060.], [ 11., 1060.], [ 59., 1080.], [ 27., 1080.], [ 43., 1100.], [ 11., 1100.], [ 59., 1120.], [ 27., 1120.], [ 11., 1140.], [ 59., 1160.], [ 27., 1160.], [ 43., 1180.], [ 11., 1180.], [ 59., 1200.], [ 27., 1200.], [ 43., 1220.], [ 11., 1220.], [ 59., 1240.], [ 27., 1240.], [ 43., 1260.], [ 11., 1260.], [ 59., 1280.], [ 27., 1280.], [ 43., 1300.], [ 11., 1300.], [ 59., 1320.], [ 27., 1320.], [ 43., 1340.], [ 11., 1340.], [ 59., 1360.], [ 27., 1360.], [ 43., 1380.], [ 11., 1380.], [ 59., 1400.], [ 27., 1400.], [ 43., 1420.], [ 11., 1420.], [ 59., 1440.], [ 27., 1440.], [ 43., 1460.], [ 11., 1460.], [ 59., 1480.], [ 27., 1480.], [ 43., 1500.], [ 11., 1500.], [ 59., 1520.], [ 43., 1540.], [ 11., 1540.], [ 59., 1560.], [ 27., 1560.], [ 43., 1580.], [ 11., 1580.], [ 59., 1600.], [ 27., 1600.], [ 43., 1620.], [ 11., 1620.], [ 59., 1640.], [ 27., 1640.], [ 43., 1660.], [ 11., 1660.], [ 59., 1680.], [ 27., 1680.], [ 43., 1700.], [ 11., 1700.], [ 59., 1720.], [ 27., 1720.], [ 43., 1740.], [ 11., 1740.], [ 59., 1760.], [ 27., 1760.], [ 43., 1780.], [ 11., 1780.], [ 59., 1800.], [ 27., 1800.], [ 43., 1820.], [ 11., 1820.], [ 59., 1840.], [ 27., 1840.], [ 43., 1860.], [ 11., 1860.], [ 59., 1880.], [ 27., 1880.], [ 11., 1900.], [ 59., 1920.], [ 27., 1920.], [ 43., 1940.], [ 11., 1940.], [ 59., 1960.], [ 27., 1960.], [ 43., 1980.], [ 11., 1980.], [ 59., 2000.], [ 27., 2000.], [ 43., 2020.], [ 11., 2020.], [ 59., 2040.], [ 27., 2040.], [ 43., 2060.], [ 11., 2060.], [ 59., 2080.], [ 27., 2080.], [ 43., 2100.], [ 11., 2100.], [ 59., 2120.], [ 27., 2120.], [ 43., 2140.], [ 11., 2140.], [ 59., 2160.], [ 27., 2160.], [ 43., 2180.], [ 11., 2180.], [ 59., 2200.], [ 27., 2200.], [ 43., 2220.], [ 11., 2220.], [ 59., 2240.], [ 27., 2240.], [ 43., 2260.], [ 11., 2260.], [ 59., 2280.], [ 43., 2300.], [ 11., 2300.], [ 59., 2320.], [ 27., 2320.], [ 43., 2340.], [ 11., 2340.], [ 59., 2360.], [ 27., 2360.], [ 43., 2380.], [ 11., 2380.], [ 59., 2400.], [ 27., 2400.], [ 43., 2420.], [ 11., 2420.], [ 59., 2440.], [ 27., 2440.], [ 43., 2460.], [ 11., 2460.], [ 59., 2480.], [ 27., 2480.], [ 43., 2500.], [ 11., 2500.], [ 59., 2520.], [ 27., 2520.], [ 43., 2540.], [ 11., 2540.], [ 59., 2560.], [ 27., 2560.], [ 43., 2580.], [ 11., 2580.], [ 59., 2600.], [ 27., 2600.], [ 43., 2620.], [ 11., 2620.], [ 59., 2640.], [ 27., 2640.], [ 11., 2660.], [ 59., 2680.], [ 27., 2680.], [ 43., 2700.], [ 11., 2700.], [ 59., 2720.], [ 27., 2720.], [ 43., 2740.], [ 11., 2740.], [ 59., 2760.], [ 27., 2760.], [ 43., 2780.], [ 11., 2780.], [ 59., 2800.], [ 27., 2800.], [ 43., 2820.], [ 11., 2820.], [ 59., 2840.], [ 27., 2840.], [ 43., 2860.], [ 11., 2860.], [ 59., 2880.], [ 27., 2880.], [ 43., 2900.], [ 11., 2900.], [ 59., 2920.], [ 27., 2920.], [ 43., 2940.], [ 11., 2940.], [ 59., 2960.], [ 27., 2960.], [ 43., 2980.], [ 11., 2980.], [ 59., 3000.], [ 27., 3000.], [ 43., 3020.], [ 11., 3020.], [ 59., 3040.], [ 43., 3060.], [ 11., 3060.], [ 59., 3080.], [ 27., 3080.], [ 43., 3100.], [ 11., 3100.], [ 59., 3120.], [ 27., 3120.], [ 43., 3140.], [ 11., 3140.], [ 59., 3160.], [ 27., 3160.], [ 43., 3180.], [ 11., 3180.], [ 59., 3200.], [ 27., 3200.], [ 43., 3220.], [ 11., 3220.], [ 59., 3240.], [ 27., 3240.], [ 43., 3260.], [ 11., 3260.], [ 59., 3280.], [ 27., 3280.], [ 43., 3300.], [ 11., 3300.], [ 59., 3320.], [ 27., 3320.], [ 43., 3340.], [ 11., 3340.], [ 59., 3360.], [ 27., 3360.], [ 43., 3380.], [ 11., 3380.], [ 59., 3400.], [ 27., 3400.], [ 11., 3420.], [ 59., 3440.], [ 27., 3440.], [ 43., 3460.], [ 11., 3460.], [ 59., 3480.], [ 27., 3480.], [ 43., 3500.], [ 11., 3500.], [ 59., 3520.], [ 27., 3520.], [ 43., 3540.], [ 11., 3540.], [ 59., 3560.], [ 27., 3560.], [ 43., 3580.], [ 11., 3580.], [ 59., 3600.], [ 27., 3600.], [ 43., 3620.], [ 11., 3620.], [ 59., 3640.], [ 27., 3640.], [ 43., 3660.], [ 11., 3660.], [ 59., 3680.], [ 27., 3680.], [ 43., 3700.], [ 11., 3700.], [ 59., 3720.], [ 27., 3720.], [ 43., 3740.], [ 11., 3740.], [ 59., 3760.], [ 27., 3760.], [ 43., 3780.], [ 11., 3780.], [ 59., 3800.], [ 43., 3820.], [ 11., 3820.], [ 59., 3840.], [ 27., 3840.]]), brain_atlas=<ibllib.atlas.atlas.AllenAtlas object>)[source]
Parameters

xyz – numpy array of 3D coordinates corresponding to a picked track or a trajectory

the deepest point is assumed to be the tip. :param channels_positions: :param brain_atlas: :return: brain_regions (associated to each channel),

insertion (object atlas.Insertion, defining 2 points of entries (tip and end of probe))

register_track(probe_id, picks=None, one=None, overwrite=False, channels=True)[source]

Register the user picks to a probe in Alyx Here we update Alyx models on the database in 3 steps 1) The user picks converted to IBL coordinates will be stored in the json field of the corresponding probe insertion models 2) The trajectory computed from the histology track is created or patched 3) Channel locations are set in the table

register_aligned_track(probe_id, xyz_channels, chn_coords=None, one=None, overwrite=False, channels=True)[source]

Register ephys aligned trajectory and channel locations to Alyx Here we update Alyx models on the database in 2 steps 1) The trajectory computed from the final electrode channel locations 2) Channel locations are set to the trajectory

create_trajectory_dict(probe_id, insertion, provenance)[source]

Create trajectory dictionary in form to upload to alyx :param probe id: unique id of probe insertion :type probe_id: string (hexadecimal UUID) :param insertion: Insertion object describing entry and tip of trajectory :type insertion: object atlas.Insertion :param provenance: ‘Histology track’ or ‘Ephys aligned histology track’ :type provenance: string :return tdict: :type tdict: dict

create_channel_dict(traj, brain_locations)[source]

Create channel dictionary in form to upload to alyx :param traj: alyx trajectory object to attach channel information to :type traj: dict :param brain_locations: information about location of electrode channels in brain atlas :type insertion: Bunch :return tdict: :type tdict: list of dict

register_track_files(path_tracks, one=None, overwrite=False)[source]
Parameters
  • path_tracks – path to directory containing tracks; also works with a single file name

  • one

Returns

detect_missing_histology_tracks(path_tracks=None, one=None, subject=None)[source]

Compares the number of probe insertions to the number of registered histology tracks to see if there is a discrepancy so that missing tracks can be properly logged in the database :param path_tracks: path to track files to be registered :param subject: subject nickname for which to detect missing tracks

coverage(trajs, ba=None, dist_fcn=[100, 150])[source]

Computes a coverage volume from :param trajs: dictionary of trajectories from Alyx rest endpoint (one.alyx.rest…) :param ba: ibllib.atlas.BrainAtlas instance :return: 3D np.array the same size as the volume provided in the brain atlas

coverage_grid(xyz_channels, spacing=500, ba=None)[source]