hal

Find the folder structure here: Folder Structure.

Overview

Members

hal.build_training_sequences(well_no: int)

Builds general event sequences: pre_recording_start (ID: 2), closed_loop_start (ID: 3), post_recording_start (ID: 4), and end_experiment (ID: 5)

These are meant to be used to signal when the training actually happens in the closed-loop program.

Parameters:

well_no (int) – well number

hal.connect_stim_units_to_stim_electrodes(stim_electrodes: List[int], array: Array) List[int]

Connects stimulation units to stimulation electrodes. This function was taken from example code from MaxWell.

Parameters:
  • stim_electrodes (List[int]) – list of stimulation electrodes to connect

  • array (mx.Array) – MaxWell array generated from a list of recording/stimulation electrodes

Raises:
  • RuntimeError – when a stimulation channel cannot connect to a stimulation electrode

  • RuntimeError – when two electrodes are connected to the same unit

Returns:

a list of stimulation units

Return type:

List[int]

hal.get_electrode_square(center: int, radius: int, step_width=1)

Generates a square of electrodes centered around a single electrode

Parameters:
  • center (int) – the target electrode to center the square around

  • radius (int) – half the length of the square, measured in steps/chosen electrodes

  • step_width (int, optional) – how far to “step” when choosing electrodes in the square, defaults to 1

Returns:

list of electrodes

Return type:

List[int]

hal.get_file_names(well_no: int, experiment_name: str, trial_path: str)

Returns names and paths for recording directory, config, and h5 file for sequential experiments.

Parameters:
  • well_no (int) – well number

  • experiment_name (str) – name of the experiment

  • trial_path (str) – full path of the trial

Returns:

tuple of recording directory, experiment name, and config, respectively

Return type:

List[str]

hal.init_well(well_no: int, rec_elecs: List[int] | str, stim_elecs: List[int], connect=True, power_up=True) Array

Initilizes the well recording electrodes and stimulation electrodes. By default, it will connect the stimulation units and power them, but this can be overridden by setting the last two arguments to False or by passing an empty list for stim_elecs. This can be useful for setting stimulations to different DAC channels, since this function sets all stimulation electrodes to DAC 0 automatically. The stimulation electrodes will also be selected for recording, so they don’t need to be in the recording electrodes list.

Important Note: This function will pick recording electrodes by adding stim_elecs and rec_elecs, meaning that rec_elecs does not have to contain everything in stim_elecs. However, if the number of electrodes in both lists combined is greater than 1020, then some of the electrodes will not be chosen. If that happens, stim_elecs will have preference over rec_elecs.

Parameters:
  • well_no (int) – Well number

  • rec_elecs (List[int] | str) – Recording electrodes, as a list of electrode numbers OR as a full path to a MaxWell configuration file

  • stim_elecs (List[int]) – Stimulation electrodes, as a list of electrode numbers. If empty, connecting and powering up will not be attempted.

  • connect (bool, optional) – Indicates if the stimulation units should be connected, defaults to True

  • power_up (bool, optional) – Indicates if the stimulation units should be powered up, defaults to True

Returns:

a maxlab array with the configured electrodes

Return type:

mx.Array

hal.make_trial_folders(experiment_parameters)

Creates folders for saving data based on a dict, generated from an experiment json file (see: Folder Structure)

Parameters:

experiment_parameters (HAL.json.dict{}) – Holds the experiment paremeters; the following elements are required: 'FOLDER', 'NAME', 'WELLS'

Returns:

Returns the full path of the trial folder

Return type:

string

hal.make_trial_folders_parallel(parent_path: str, experiment_name: str, chip_id: str | int) str

Creates folders for saving data in the HAL specified folder format for parallel experiments (i.e. when recording multiple wells at once; see Folder Structure).

Parameters:
  • parent_path (string) – full path of the parent folder

  • experiment_name (string) – name of experiment

  • chip_id (string | int) – chip id

Returns:

Returns the full path of the trial folder

Return type:

string

hal.make_trial_folders_raw(parent_path: str, experiment_name: str, chip_id: str | int, wells: List[int]) str

Creates folders for saving data without using a dict, in the HAL specified folder format (see Folder Structure).

Parameters:
  • parent_path (string) – full path of the parent folder

  • experiment_name (string) – name of experiment

  • chip_id (string | int) – chip id

  • wells (List[int]) – list of wells that the experiment will run on

Returns:

Returns the full path of the trial folder

Return type:

string

hal.power_up_stim_units(stimulation_units: List[int], dac=0)

Powers up stimulation units for an experiment

Parameters:

stimulation_units (List[int]) – stimulation units to power up

hal.write_closed_loop_args(s: Saving, arguments: List[str])

Writes arguments of closed-loop C++ program to the experiment h5 file under key “closed_loop_args”

Parameters:
  • s (mx.Saving) – Experiment to save the stimulation electrodes for

  • arguments (List[str]) – arguments of the closed loop program

hal.write_exp_description(s: Saving, description: str) None

Writes experiment description as a property to the experiment h5 file under key “description”

Parameters:
  • s (mx.Saving) – Experiment to save the stimulation electrodes for

  • description (str) – description of the experiment

hal.write_exp_notes(s: Saving, notes: str) None

Writes experiment notes as a property to the experiment h5 file under key “notes”

Parameters:
  • s (mx.Saving) – Experiment to save the stimulation electrodes for

  • notes (str) – notes of the experiment

hal.write_stim_electrodes(s: Saving, stim_electrodes: List[int])

Writes the stimulation electrodes as a property to the experiment h5 file under key “stim_electrodes”

Note that this function must be called after opening the file

Parameters:
  • s (mx.Saving) – Experiment to save the stimulation electrodes for

  • stim_electrodes (List[int]) – stimulation electrodes