Skip to content

Commit

Permalink
Merge pull request #41 from zm711/updates
Browse files Browse the repository at this point in the history
Working on some minor updates
  • Loading branch information
zm711 authored Oct 3, 2023
2 parents 7cc376d + 44a6209 commit e5d1766
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 254 deletions.
17 changes: 14 additions & 3 deletions docs/source/submodules/stimulus_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ trial groups can be set with a utility function. :code:`set_trial_groups`, which
a key of the Intan channel and a value of the desired trial groups as an :code:`np.array`. Since the channel names are not always easy to know
they can be returned using :code:`get_stimulus_channels`. Finally stimulus' should be named with :code:`set_stimulus_name`.

.. code:-block:: python
.. code-block:: python
stim_dict = stim.get_stimluus_channels()
stim_dict = stim.get_stimulus_channels()
stim.set_trial_groups(trial_dictionary=trial_dictionary) # dict as explained above
sitm.set_stimulus_names(stim_names = name_dictionary) # same keys with str values
Expand All @@ -108,6 +108,17 @@ in the case of optogenetic trains rather than looking at :code:`events`, :code:`
:code:`stim_time_secs` (length of the train) must be given.


Deleting Accidental events
--------------------------

In the case of an accidental event (for example turning on a TTL signal for just a moment accidental) one can use the :code:`delete_events()`
function. Either one :code:`del_index` is given or a list of indices to delete. This means that if event "25" was a mistaken signal one could
do the following:

.. code-block:: python
stim.delete_events(del_index=24, digital=True, digital_channel="DIGITAL-IN-01") #python is 0 based so 25th event is 24 index
Saving files for easy loading
-----------------------------

Expand Down Expand Up @@ -148,5 +159,5 @@ And remember to :code:`save_events`.
stim = StimulusData(file_path='home/myawesomedata')
stim.run_all(stim_length_seconds=10, stim_name=['ana1'])
stim.set_trial_groups(trial_dictionary=my_dictionary)
stim.set_stimulus_names(stim_names=my_name_dictionary)
stim.set_stimulus_name(stim_names=my_name_dictionary)
stim.save_events()
13 changes: 11 additions & 2 deletions src/spikeanalysis/spike_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def run_all(
idthres: float,
rpv: float,
sil: float,
amp_std: float,
amp_cutoff: float,
recurated: bool = False,
set_caching: bool = True,
depth: float = 0,
Expand All @@ -113,6 +115,11 @@ def run_all(
the refractory period violation fraction allowed: 0.02 would be 2% violations
sil: float
the silhouette score allowed -1 (bad) to 1 (perfect)
amp_std: float
the std to use for calculating the number of spikes which past that range
amp_cutoff: float
the cutoff value to use for qc for the amplitudes values, example .98 means 98% fall within
amp_std stds of the mean amplitude
recurated: bool
If more Phy curation has occurred such that any cached or currently loaded values
need to be overwritten (True), Default False
Expand Down Expand Up @@ -140,10 +147,12 @@ def run_all(
except AttributeError:
self.generate_pcs()
self.generate_qcmetrics()
self.qc_preprocessing(idthres=idthres, rpv=rpv, sil=sil, recurated=recurated)
self.set_qc()

self.get_waveforms()
self.get_waveform_values(depth=depth)
self.get_amplitudes(std=amp_std)
self.qc_preprocessing(idthres=idthres, rpv=rpv, sil=sil, amp_cutoff=amp_cutoff, recurated=recurated)
self.set_qc()
self._return_to_dir(current_dir)

def denoise_data(self):
Expand Down
6 changes: 2 additions & 4 deletions src/spikeanalysis/spike_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,7 @@ def _get_event_lengths(self) -> dict:
stim_dict = self.data._get_key_for_stim()

for key, value in stim_dict.items():
stim_lengths[key] = np.mean(
np.array(self.data.events[value]["lengths"]) / self.data._sampling_rate
)
stim_lengths[key] = np.mean(np.array(self.data.events[value]["lengths"]) / self.data._sampling_rate)
return stim_lengths

def _get_event_lengths_all(self) -> dict:
Expand All @@ -672,7 +670,7 @@ def _get_event_lengths_all(self) -> dict:

for key, value in stim_dict.items():
stim_lengths[key] = np.array(self.data.events[value]["lengths"]) / self.data._sampling_rate

return stim_lengths

def _get_trial_groups(self) -> dict:
Expand Down
Loading

0 comments on commit e5d1766

Please sign in to comment.