allensdk.brain_observatory.ecephys.align_timestamps.barcode module¶
-
allensdk.brain_observatory.ecephys.align_timestamps.barcode.
extract_barcodes_from_times
(on_times, off_times, inter_barcode_interval=10, bar_duration=0.03, barcode_duration_ceiling=2, nbits=32)[source]¶ Read barcodes from timestamped rising and falling edges.
Parameters: - on_times : numpy.ndarray
Timestamps of rising edges on the barcode line
- off_times : numpy.ndarray
Timestamps of falling edges on the barcode line
- inter_barcode_interval : numeric, optional
Minimun duration of time between barcodes.
- bar_duration : numeric, optional
A value slightly shorter than the expected duration of each bar
- barcode_duration_ceiling : numeric, optional
The maximum duration of a single barcode
- nbits : int, optional
The bit-depth of each barcode
Returns: - barcode_start_times : list of numeric
For each detected barcode, the time at which that barcode started
- barcodes : list of int
For each detected barcode, the value of that barcode as an integer.
Notes
ignores first code in prod (ok, but not intended) ignores first on pulse (intended - this is needed to identify that a barcode is starting)
-
allensdk.brain_observatory.ecephys.align_timestamps.barcode.
find_matching_index
(master_barcodes, probe_barcodes, alignment_type='start')[source]¶ Given a set of barcodes for the master clock and the probe clock, find the indices of a matching set, either starting from the beginning or the end of the list.
Parameters: - master_barcodes : np.ndarray
barcode values on the master line. One per barcode
- probe_barcodes : np.ndarray
barcode values on the probe line. One per barcode
- alignment_type : string
‘start’ or ‘end’
Returns: - master_barcode_index : int
matching index for master barcodes (None if not found)
- probe_barcode_index : int
matching index for probe barcodes (None if not found)
-
allensdk.brain_observatory.ecephys.align_timestamps.barcode.
get_probe_time_offset
(master_times, master_barcodes, probe_times, probe_barcodes, acq_start_index, local_probe_rate)[source]¶ Time offset between master clock and recording probes. For converting probe time to master clock.
Parameters: - master_times : np.ndarray
start times of barcodes (according to the master clock) on the master line. One per barcode.
- master_barcodes : np.ndarray
barcode values on the master line. One per barcode
- probe_times : np.ndarray
start times (according to the probe clock) of barcodes on the probe line. One per barcode
- probe_barcodes : np.ndarray
barcode values on the probe_line. One per barcode
- acq_start_index : int
sample index of probe acquisition start time
- local_probe_rate : float
the probe’s apparent sampling rate
Returns: - total_time_shift : float
Time at which the probe started acquisition, assessed on the master clock. If < 0, the probe started earlier than the master line.
- probe_rate : float
The probe’s sampling rate, assessed on the master clock
- master_endpoints : iterable
Defines the start and end times of the sync interval on the master clock
-
allensdk.brain_observatory.ecephys.align_timestamps.barcode.
linear_transform_from_intervals
(master, probe)[source]¶ Find a scale and translation which aligns two 1d segments
Parameters: - master : iterable
Pair of floats defining the master interval. Order is [start, end].
- probe : iterable
Pair of floats defining the probe interval. Order is [start, end].
Returns: - scale : float
Scale factor. If > 1.0, the probe clock is running fast compared to the master clock. If < 1.0, the probe clock is running slow.
- translation : float
If > 0, the probe clock started before the master clock. If > 0, after.
Notes
- solves
- (master + translation) * scale = probe
for scale and translation
-
allensdk.brain_observatory.ecephys.align_timestamps.barcode.
match_barcodes
(master_times, master_barcodes, probe_times, probe_barcodes)[source]¶ Given sequences of barcode values and (local) times on a probe line and a master line, find the time points on each clock corresponding to the first and last shared barcode.
If there’s only one probe barcode, only the first matching timepoint is returned.
Parameters: - master_times : np.ndarray
start times of barcodes (according to the master clock) on the master line. One per barcode.
- master_barcodes : np.ndarray
barcode values on the master line. One per barcode
- probe_times : np.ndarray
start times (according to the probe clock) of barcodes on the probe line. One per barcode
- probe_barcodes : np.ndarray
barcode values on the probe_line. One per barcode
Returns: - probe_interval : np.ndarray
Start and end times of the matched interval according to the probe_clock.
- master_interval : np.ndarray
Start and end times of the matched interval according to the master clock