ibllib.pipes.histology

Functions

coverage

Computes a coverage volume from

coverage_grid

create_channel_dict

Create channel dictionary in form to upload to alyx

create_trajectory_dict

Create trajectory dictionary in form to upload to alyx

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

get_brain_regions

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

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

plot2d_all

Plot all tracks on a single 2d slice

plot3d_all

Plot all tracks on a single 2d slice

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_chronic_track

Register the user picks to a chronic insertion in Alyx.

register_chronic_track_files

Registers track files for chronic insertions

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

load_track_csv(file_track, brain_atlas=None)[source]

Loads a lasagna track and convert to IBL-ALlen coordinate framework

Parameters:

file_track

Returns:

xyz

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

This outputs reads in the Lasagna output and converts the picked tracks in the IBL coordinates

Parameters:

histology_path – Path object: folder path containing tracks

Returns:

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, brain_atlas=None)[source]

Plot all tracks on a single 2d slice

Parameters:
  • trajectories – dictionary output of the Alyx REST query on trajectories

  • tracks

Returns:

plot3d_all(trajectories, tracks, brain_atlas=None)[source]

Plot all tracks on a single 2d slice

Parameters:
  • trajectories – dictionary output of the Alyx REST query on trajectories

  • tracks

Returns:

interpolate_along_track(xyz_track, depths)[source]

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

Parameters:
  • xyz_track – np.array [npoints, 3]. Usually the first point is the deepest

  • 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=None, brain_atlas=None)[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_chronic_track(chronic_id, picks=None, one=None, overwrite=False, channels=True, brain_atlas=None)[source]

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

Parameters:
  • chronic_id

  • picks

  • one

  • overwrite

  • channels

  • brain_atlas

Returns:

register_track(probe_id, picks=None, one=None, overwrite=False, channels=True, brain_atlas=None, endpoint='insertions')[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, brain_atlas=None)[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, endpoint='insertions')[source]

Create trajectory dictionary in form to upload to alyx

Parameters:
  • id (probe) – unique id of probe insertion

  • insertion (object atlas.Insertion) – Insertion object describing entry and tip of trajectory

  • provenance (string) – ‘Histology track’ or ‘Ephys aligned histology track’

  • endpoint (string) – Alyx endpoint, either ‘insertions’, or ‘chronic-insertions’

Return tdict:

create_channel_dict(traj, brain_locations)[source]

Create channel dictionary in form to upload to alyx

Parameters:
  • traj (dict) – alyx trajectory object to attach channel information to

  • brain_locations – information about location of electrode channels in brain atlas

Return tdict:

register_chronic_track_files(path_tracks, one=None, overwrite=False, brain_atlas=None)[source]

Registers track files for chronic insertions

Parameters:
  • path_tracks

  • one

  • overwrite

  • brain_atlas

Returns:

register_track_files(path_tracks, one=None, overwrite=False, brain_atlas=None)[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, brain_atlas=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

Parameters:
  • path_tracks – path to track files to be registered

  • subject – subject nickname for which to detect missing tracks

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

Computes a coverage volume from

Parameters:
  • trajs – dictionary of trajectories from Alyx rest endpoint (one.alyx.rest…)

  • ba – iblatlas.atlas.BrainAtlas instance

Returns:

3D np.array the same size as the volume provided in the brain atlas

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