Skip to content

Commit

Permalink
Merge branch 'main' into add-filter-auc
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 authored Nov 12, 2024
2 parents 6cdacd4 + 8ce5a38 commit 538d4cb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/spikeanalysis/stimulus_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def run_all(
stim_length_seconds: float | None = None,
stim_name: list | None = None,
time_slice: tuple = (None, None),
min_threshold: None | list = None
):
"""
Pipeline function to run through all steps necessary to load intan data
Expand All @@ -116,6 +117,8 @@ def run_all(
Name of the stimulus. The default is None.
time_slice: tuple[start, stop]
time slice of recording to use, given in seconds with start and stop
min_threshold: None | list, deafult: None,
Whether to set a distinct threshold for analog stim
"""

Expand Down Expand Up @@ -144,6 +147,7 @@ def run_all(
analog_index=stim_index,
stim_length_seconds=stim_length_seconds,
stim_name=stim_name,
min_threshold=min_threshold,
)
if have_digital:
self.get_final_digital_data()
Expand Down Expand Up @@ -228,6 +232,7 @@ def digitize_analog_data(
analog_index: int | None = None,
stim_length_seconds: float | None = None,
stim_name: list[str] | None = None,
min_threshold: None | list = None
):
"""Function to digitize the analog data for stimuli that have "events" rather than assessing
them as continually changing values"""
Expand All @@ -249,6 +254,11 @@ def digitize_analog_data(
current_analog_data = np.expand_dims(current_analog_data, axis=1)

self.dig_analog_events = {}

if min_threshold is None:
min_threshold = [0.09] * current_analog_data.shape[1]
else:
assert len(min_threshold) == current_analog_data.shape[1]

if self._verbose:
event_range = tqdm(range(np.shape(current_analog_data)[1]))
Expand All @@ -257,7 +267,7 @@ def digitize_analog_data(
for row in event_range:
self.dig_analog_events[str(row)] = {}
sub_data = current_analog_data[:, row]
filtered_analog_data = np.where(sub_data > 0.09, 1, 0)
filtered_analog_data = np.where(sub_data > min_threshold[row], 1, 0)
dig_ana_events, dig_ana_lengths = self._calculate_events(filtered_analog_data)
events = dig_ana_events[dig_ana_lengths > stim_length_seconds]
lengths = dig_ana_lengths[dig_ana_lengths > stim_length_seconds]
Expand Down

0 comments on commit 538d4cb

Please sign in to comment.