Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSTH #339

Merged
merged 13 commits into from
Aug 24, 2022
Merged

PSTH #339

merged 13 commits into from
Aug 24, 2022

Conversation

tensionhead
Copy link
Contributor

@tensionhead tensionhead commented Aug 23, 2022

PSTH 🚀

  • added peri stimulus time histogram with a frontend API like in FT
  • one minimal functional test was included, general proper tests still missing
  • additional datasets like avg or var will get added once TimeLockData is up to speed

addresses #295

Author Guidelines

  • Was the code checked for memory leaks/performance bottlenecks?
  • Is the code running locally and on the ESI cluster?
  • Is the code running on all supported platforms?

Reviewer Checklist

  • Are testing routines present?
  • Do parallel loops have a set length and correct termination conditions?
  • Do objects in the global package namespace perform proper parsing of their input?
  • Do code-blocks provide novel functionality, i.e., no re-factoring using builtin/external packages possible?
  • Code layout
    • Is the code PEP8 compliant?
    • Does the code adhere to agreed-upon naming conventions?
    • Are keywords clearly named and easy to understand?
    • No commented-out code?
  • Are all docstrings complete and accurate?
  • Is the CHANGELOG.md up to date?

Changes to be committed:
	modified:   syncopy/datatype/__init__.py
	deleted:    syncopy/datatype/statistical_data.py
- got a working frontend call

Changes to be committed:
	modified:   syncopy/datatype/continuous_data.py
	modified:   syncopy/spikes/compRoutines.py
	modified:   syncopy/spikes/psth.py
	modified:   syncopy/spikes/spike_psth.py
- fixed some remaining indexing issues
- correct channel labels now

Changes to be committed:
	modified:   syncopy/datatype/continuous_data.py
	modified:   syncopy/spikes/compRoutines.py
	modified:   syncopy/spikes/psth.py
	modified:   syncopy/spikes/spike_psth.py
- now it's time to make sense out of the histograms

Changes to be committed:
	modified:   syncopy/spikes/compRoutines.py
	modified:   syncopy/spikes/spike_psth.py
- totally random trial definition can produce trials with no events,
which causes downstream problems for indexing
- massaged the synth generator to always have at least 90% of average
trial size nSamples .// nTrials
- this might be a problem in RL as well if ppl define trials in empty regions..

Changes to be committed:
	modified:   syncopy/tests/synth_data.py
- added NaN masking for time bins if trial outside of latency
- TODO: fix time axis / trialdefinition

Changes to be committed:
	modified:   syncopy/datatype/continuous_data.py
	modified:   syncopy/datatype/discrete_data.py
	modified:   syncopy/spikes/compRoutines.py
	modified:   syncopy/spikes/psth.py
	modified:   syncopy/spikes/spike_psth.py
	modified:   syncopy/tests/synth_data.py
- should be investigated why the manual construction of the Indexer
to access selected trials outside the CR was necessary

Changes to be committed:
	modified:   syncopy/spikes/compRoutines.py
	modified:   syncopy/spikes/psth.py
	modified:   syncopy/spikes/spike_psth.py
Changes to be committed:
	modified:   syncopy/spikes/psth.py
	new file:   syncopy/tests/test_spike_psth.py
@codecov
Copy link

codecov bot commented Aug 23, 2022

Codecov Report

Merging #339 (2122a46) into dev (5df8804) will increase coverage by 3.04%.
The diff coverage is 60.58%.

@@            Coverage Diff             @@
##              dev     #339      +/-   ##
==========================================
+ Coverage   65.84%   68.89%   +3.04%     
==========================================
  Files          77       77              
  Lines        8742     8850     +108     
  Branches     1784     1816      +32     
==========================================
+ Hits         5756     6097     +341     
+ Misses       2591     2335     -256     
- Partials      395      418      +23     
Impacted Files Coverage Δ
syncopy/datatype/continuous_data.py 83.37% <33.33%> (+1.36%) ⬆️
syncopy/spikes/spike_psth.py 43.36% <47.36%> (+20.78%) ⬆️
syncopy/spikes/psth.py 74.07% <76.00%> (+54.62%) ⬆️
syncopy/spikes/compRoutines.py 89.47% <80.95%> (+89.47%) ⬆️
syncopy/datatype/__init__.py 100.00% <100.00%> (ø)
syncopy/datatype/base_data.py 81.96% <100.00%> (-0.19%) ⬇️
syncopy/datatype/discrete_data.py 83.70% <100.00%> (+0.37%) ⬆️
syncopy/tests/synth_data.py 83.33% <100.00%> (+19.69%) ⬆️
syncopy/nwanalysis/connectivity_analysis.py 73.45% <0.00%> (-2.66%) ⬇️
syncopy/shared/tools.py 79.76% <0.00%> (-2.39%) ⬇️
... and 20 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@dfsp-spirit dfsp-spirit self-assigned this Aug 24, 2022
Changes to be committed:
	modified:   syncopy/tests/synth_data.py
sinfo = data.sampleinfo
trials = data.trials

lenTrials = np.diff(sinfo).squeeze()
Copy link
Collaborator

@dfsp-spirit dfsp-spirit Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lenTrials this seems to be unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, this I will remove!

Comment on lines 176 to 179
chan_labels = [f'channel{i}_unit{j}' for i, j in combs]

# now we have our global (single-trial, avg, std,..) histogram shape
h_shape = (nBins, len(combs))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not part of this change set, but chan_labels and h_shape are also unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, it's for book keeping of that complicated output shape, yet the chan_labels already get used in process_metadata, so I'll remove 'em.

@dfsp-spirit
Copy link
Collaborator

The docstring for the frontend, spike_psth(), lists a boolean parameter vartriallen that does not exist. Do we want to implement this later? Otherwise it should be removed.

@dfsp-spirit
Copy link
Collaborator

The output parameter for the frontend, spike_psth(), seems to be ignored.

# now map with respect to unit for all single trial channels (-bins)
map_unit = {u: np.logical_or.reduce([map_cu(c, u) for c in chan_vec]) for u in unique_units}

# map into histogram time x channel dimensions
map_unit_hist = {u: [np.any(map_cu(c, u)) for c in chan_vec] for u in unique_units}

for i, iunit in enumerate(unique_units):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again not part of this changeset, but i is unused, so no need for enumerate

from syncopy.datatype import SpikeData
from syncopy.shared.tools import get_defaults, get_frontend_cfg
from syncopy.datatype import TimeLockData
from syncopy.datatype.base_data import Indexer

from syncopy.shared.errors import SPYValueError, SPYTypeError, SPYWarning, SPYInfo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: SPYTypeError, SPYWarning, SPYInfo are imported but not used

onset,
trl_end,
chan_unit_combs=None,
tbins=None,
samplerate=1000):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not part of this changeset, but the docstring for the samplerate parameter is missing

@tensionhead
Copy link
Contributor Author

The docstring for the frontend, spike_psth(), lists a boolean parameter vartriallen that does not exist. Do we want to implement this later? Otherwise it should be removed.

I implemented it just now :)

The output parameter for the frontend, spike_psth(), seems to be ignored.

yep this still needs to be done!

- still TODO: 'output' parameter

Changes to be committed:
	modified:   syncopy/datatype/base_data.py
	modified:   syncopy/spikes/spike_psth.py
Changes to be committed:
	modified:   syncopy/spikes/psth.py
@tensionhead tensionhead merged commit 55934ac into dev Aug 24, 2022
@tensionhead tensionhead deleted the psth branch September 1, 2022 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants