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_timesnumpy.ndarray
Timestamps of rising edges on the barcode line
- off_timesnumpy.ndarray
Timestamps of falling edges on the barcode line
- inter_barcode_intervalnumeric, optional
Minimun duration of time between barcodes.
- bar_durationnumeric, optional
A value slightly shorter than the expected duration of each bar
- barcode_duration_ceilingnumeric, optional
The maximum duration of a single barcode
- nbitsint, optional
The bit-depth of each barcode
- Returns:
- barcode_start_timeslist of numeric
For each detected barcode, the time at which that barcode started
- barcodeslist 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_barcodesnp.ndarray
barcode values on the master line. One per barcode
- probe_barcodesnp.ndarray
barcode values on the probe line. One per barcode
- alignment_typestring
‘start’ or ‘end’
- Returns:
- master_barcode_indexint
matching index for master barcodes (None if not found)
- probe_barcode_indexint
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_timesnp.ndarray
start times of barcodes (according to the master clock) on the master line. One per barcode.
- master_barcodesnp.ndarray
barcode values on the master line. One per barcode
- probe_timesnp.ndarray
start times (according to the probe clock) of barcodes on the probe line. One per barcode
- probe_barcodesnp.ndarray
barcode values on the probe_line. One per barcode
- acq_start_indexint
sample index of probe acquisition start time
- local_probe_ratefloat
the probe’s apparent sampling rate
- Returns:
- total_time_shiftfloat
Time at which the probe started acquisition, assessed on the master clock. If < 0, the probe started earlier than the master line.
- probe_ratefloat
The probe’s sampling rate, assessed on the master clock
- master_endpointsiterable
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:
- masteriterable
Pair of floats defining the master interval. Order is [start, end].
- probeiterable
Pair of floats defining the probe interval. Order is [start, end].
- Returns:
- scalefloat
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.
- translationfloat
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_timesnp.ndarray
start times of barcodes (according to the master clock) on the master line. One per barcode.
- master_barcodesnp.ndarray
barcode values on the master line. One per barcode
- probe_timesnp.ndarray
start times (according to the probe clock) of barcodes on the probe line. One per barcode
- probe_barcodesnp.ndarray
barcode values on the probe_line. One per barcode
- Returns:
- probe_intervalnp.ndarray
Start and end times of the matched interval according to the probe_clock.
- master_intervalnp.ndarray
Start and end times of the matched interval according to the master clock