Skip to content

Commit

Permalink
add return option
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 committed Jan 11, 2024
1 parent e0446f5 commit 9be1883
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/spikeanalysis/spike_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,16 @@ def autocorrelogram(self, time_ms: float = 500):

self.acg = acg

def return_value(self, value: str):

_values = ("zscores", "raw_zscores", "mean_firing_rate", "raw_firing_rate", "correlations", "latency", "psths")

if hasattr(self, value):
return getattr(self, value)
else:
print(f"possible values are {_values}")
raise AttributeError(f"{value} does not exist run appropriate function")

def _generate_sample_z_parameter(self, save: bool = True) -> dict:
"""
Function for providing example z score parameters. Then saves as json
Expand Down
18 changes: 18 additions & 0 deletions test/test_spike_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@ def test_z_score_data(sa):
assert np.sum(z_data[0, 0, :15]) < np.sum(z_data[0, 0, 150:200]), "Should be high z score"


def test_return_value(sa):
sa.events = {
"0": {
"events": np.array([100, 200]),
"lengths": np.array([100, 100]),
"trial_groups": np.array([1, 1]),
"stim": "test",
}
}
sa.get_raw_psth(window=[0, 300], time_bin_ms=50)

psths = sa.return_value("psths")
assert "test" in psths.keys()

with pytest.raises(AttributeError):
_ = sa.return_value("lats")


def test_get_interspike_intervals(sa):
sa.get_interspike_intervals()

Expand Down

0 comments on commit 9be1883

Please sign in to comment.