From cdb4b05605c4901b46b5d4cf1e09f3c4b7f203ef Mon Sep 17 00:00:00 2001 From: weygoldt <88969563+weygoldt@users.noreply.github.com> Date: Thu, 6 Apr 2023 10:15:48 +0200 Subject: [PATCH] cleaned up the root dir --- .gitignore | 1 + .python-version | 2 +- Chirpdetection poster script.md | 141 ---------- README.md | 257 +++++------------- .../figs/algorithm.pdf | Bin .../figs/algorithm1.pdf | Bin .../figs/chirps_in_chasing.pdf | Bin .../figs/chirps_winner_loser.pdf | Bin .../figs/efishlogo.pdf | Bin .../figs/introplot.pdf | Bin .../figs/kde.pdf | Bin .../figs/logo_all.pdf | 0 .../figs/timeline.pdf | Bin {poster_frozen => poster_printed}/main.pdf | Bin {poster_frozen => poster_printed}/main.tex | 0 .../packages.tex | 0 {poster_frozen => poster_printed}/poster.pdf | Bin {poster_frozen => poster_printed}/style.tex | 0 requirements.txt | 2 - 19 files changed, 72 insertions(+), 331 deletions(-) delete mode 100644 Chirpdetection poster script.md rename {poster_frozen => poster_printed}/figs/algorithm.pdf (100%) rename {poster_frozen => poster_printed}/figs/algorithm1.pdf (100%) rename {poster_frozen => poster_printed}/figs/chirps_in_chasing.pdf (100%) rename {poster_frozen => poster_printed}/figs/chirps_winner_loser.pdf (100%) rename {poster_frozen => poster_printed}/figs/efishlogo.pdf (100%) rename {poster_frozen => poster_printed}/figs/introplot.pdf (100%) rename {poster_frozen => poster_printed}/figs/kde.pdf (100%) rename {poster_frozen => poster_printed}/figs/logo_all.pdf (100%) rename {poster_frozen => poster_printed}/figs/timeline.pdf (100%) rename {poster_frozen => poster_printed}/main.pdf (100%) rename {poster_frozen => poster_printed}/main.tex (100%) rename {poster_frozen => poster_printed}/packages.tex (100%) rename {poster_frozen => poster_printed}/poster.pdf (100%) rename {poster_frozen => poster_printed}/style.tex (100%) diff --git a/.gitignore b/.gitignore index 3c2ae5f..54233f1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ data env output +trash # Mac Stuff *.DS_Store diff --git a/.python-version b/.python-version index d8a96f8..675903c 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -chirpdet +chirpdetection diff --git a/Chirpdetection poster script.md b/Chirpdetection poster script.md deleted file mode 100644 index 3868fd3..0000000 --- a/Chirpdetection poster script.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -date: 2023-01-26 -author: Patrick Weygoldt -type: talk -speakers: - - name: - affiliation: - - name: - affiliation: -aliases: -tags: ---- -# Chirp detection poster script - -## 10 minute presentation - -introduction: -- Project goal: Develop a chirp detection algorithm -- What are chirps? - - short frequency excursions in ms range of EOD (electric organ discharge) of weakly el. fish. -- Show plot: - - spectrogram of the EODf of two fish (two lines) - - frequency resolution 150Hz - - nfft: number of windows/datapoints over which the Fourier transform is performed - - frequency over time is shown - - color indicates power - - chirp = upper line, frequency increases shortly - - Problem: - - to resolve chirps on the time domain, frequency domain too coarse - - if lower fish chirps it becomes even harder - => time-frequency uncertainty problem (general) -- Goal: Improve existing detection methods to detect and assign chirps for electric recordings with n fish - -Chirp detection algorithm -Availabe data: -1. Raw electrical signal (EOD of multiple fish) over n electrodes (n = 11) -2. Tracked frequency bands on spectrogram (pre-tracked): just as in upper right plot, but with lower sampling rate (3Hz) - - for one frequency we want the electrode on which the power of the f is the greatest - - power of the strongest of 11 electrodes for each frequencypoint in time was used to track the frequency band - - we cannot track freq on spectrogram's time resolution is too low for detecting chirps if you wanna distinguish between the fish -Feature extraction (in 5s rolling window): -1. Bandpass filter around the tracked frequency band for one individual (+-5Hz) - - first subplot grey, red = envelope of filtered baseline -2. Dynamic bandpass filter above baseline (+-5Hz) = 2nd subplot, gray filtered search frequency, orange = envelope - - dynamic search window above the current fish of interest - - Why dynamic: if another fish has a higher frequency, we need to find a window without another fish to be able to detect the chirp - - window above fish: look if there's another fish (array stuff), True/false thing, find longest subarray - - chirps excursions always increase the frequency and decrease the amplitude - - to find chirp, we need to search above the fish and look for break down in amplitude - - no peaks in filtered above = no chirp - - amplitude break down of baseline can have multiple reasons (e.g. fish swims away, stone) -3. Instantaneous frequency of baseline = 3rd subplot, gray filtered inst., yellow = envelope - - calculated on filtered raw data - - get zero crossings of each period and calculate frequency manually - - we know that chirps are increases in frequency, here we look at the frequency feature of chirps -Peak detection: -1. Detect peaks on bandpass filtered and inverted baseline envelope (lower red line) -2. Detect peaks on bandpass filtered search frequency (lower orange line) -3. Detect peaks on absolute inst. freq (lower yellow line) - - Peak prominence: Minimal distance from highest peak to next peak -Peak classification: -- all three features have to be present at once in a 20ms window (appr. chirp length) in strongest electrodes -- mean of peak timestamps of features is saved as chirp timestamp - -Chirps in dyadic competitions -1. Competition experiment by Til Raab: - - two fish compete for one shelter - - 6h recording, 3h light, 3h dark - - electrical and video recordings - - with video recordings, behavior was tracked and assigned to an antagonistic category: Chasing (on- and offset) and physical contacts -- we did behavioral analysis with the detected chirps of our algorithm -2. Plot: Contact an chasing event timepoints, chirps of both fish, tracked frequency bands - - from literature: Chirps assumed as submissive signal by loser fish -4. Winner Loser boxplot - - chirps counts for winner and loser (n=22 recordings with winner and loser) - - loser tends to chirp more (Wilcoxon not significant, but trend with 0.054) - - white lines are paired fish for competition -5. Size difference plot - - Literature: Larger wish usually wins. (Larger resource holding potential theory, Till with rises) - - The smaller the size difference between fish, the more chirps are emitted taken winner and loser together - - correlation within winners and losers are not significant - - n = 21 because one recording with equal fish size was excluded -6. Frequency plot - - Literature: Males are more aggressive and chirp more, males have a lower EODf - - EODf has no effect on the competition outcome - -Chirps emitted by loser fish might stop chasing events -- Chirps were centered around the timestamps of each event in a +-60s time window (for each category and each recording) -- kernel density estimation of centered chirps (gaussian kernel with 2s width and 10ms resolution) -- We show some example plots -1. First plot: No correlation case for chasing offset - - no correlation between chirping and the offset - - this was the case for most recordings and all events -2. Second plot: Correlation case for chirping and offset - - For some few dyads/individuals, chirp rate increases drastically before the chasing offset - - also slightly visible before chasing onsets - - no correlation for physical contacts -3. Third plot: Time of chasing events in the night VS the chirps during the chasing events and during night - - fraction of chirps during chasings is not increased relative to the fraction of chasing events overall - - Chirps do not seem to have an increased significance for chasing events - - only for some few dyads the chirp rate increased during chasings -- Gray/black areas: - - bootstrapped data (n = 50) - - all chirps for one recording during the night (because there more chirps) - - all shuffled chirps again centered around event and convolved - -Conclusion: -- First tests indicate that our algorithm is able to detect chirps in recordings of multiple fish -- Algorithm results were applied on behavioral data for further analysis - - -## 2 Minute presentation - -Introduction: -- Project goal: Develop a chirp detection algorithm -- What are chirps? - - Short frequency excursions in ms range of EOD (electric organ discharge) of weakly el. fish. - - to resolve chirps on the time domain, frequency domain too coarse, especially for multiple fish -- Goal: Improve existing detection methods - -Detection algorithm -- Improved existing detection methods by extracting 3 features that change during a chirp but are not limited by the time frequency uncertainty - 1. Amplitude drop of EOD (show trough) - 2. Peaks of instantaneous frequency of EOD - 3. Peaks in the dynamically adjusted frequency band above the fish's baseline EODf (special). -- Detected and classified peaks are chirp times - -Application: Chirps during competition -- Detected over 10000 chirps in real data from a competition experiment -- Analysis of the relationship of chirps and competition events -- Fish competed for a shelter -- Were able to replicate some findings from literature - - e.g. loser fish tend to chirp more - - Other findings are not that clear and require the consideration of more factors, e.g. sex -- We explored how the chirp rate changes during onsets and offsets of chasing events - - For some recordings, chirping increased strongly before the offset of a chasing, for some nothing happens - - The number of chirps during chasings is only elevated for some dyads - -Conclusion -- Algorithm can be used to detect chirps -- We could replicate some literature findings and motivate further examination \ No newline at end of file diff --git a/README.md b/README.md index 3edd598..dfdebf1 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,5 @@ - - - - - - - - - - - - - -
@@ -37,7 +11,7 @@

chirpdetector

- An algorithm to detect the chirps of weakly electric fish. + An algorithm to detect the chirps of weakly electric fish on multielectrode recordings.
Explore the docs »
@@ -56,31 +30,14 @@

Table of Contents
    -
  1. - About The Project - -
  2. -
  3. - Getting Started - -
  4. +
  5. About The Project
  6. +
  7. Getting Started
  8. Usage
  9. -
  10. Roadmap
  11. -
  12. Contributing
  13. -
  14. License
  15. -
  16. Contact
  17. -
  18. Acknowledgments
  19. +
  20. Roadmap
- - ## About The Project [![Product Name Screen Shot][product-screenshot]](https://example.com) @@ -90,98 +47,11 @@ Here's a blank template to get started: To avoid retyping too much info. Do a se

(back to top)

-```sh - . -├──  2022-06-02-10_00 -│ ├──  2022.06.02_0.mp4 -│ ├──  analysis -│ │ ├──  baseline_freq_times.npy -│ │ ├──  baseline_freqs.npy -│ │ ├──  fish_freq.npy -│ │ ├──  fish_freq_interp.npy -│ │ ├──  frame_times.npy -│ │ ├──  rise_idx.npy -│ │ └──  rise_size.npy -│ ├──  backup -│ │ ├──  fund_v.npy -│ │ ├──  ident_v.npy -│ │ ├──  idx_v.npy -│ │ ├──  meta.npy -│ │ ├──  sign_v.npy -│ │ ├──  spec.npy -│ │ └──  times.npy -│ ├──  chirp_ids.npy -│ ├──  chirps.npy -│ ├──  chirps_ids.npy -│ ├──  fill_freqs.npy -│ ├──  fill_spec.npy -│ ├──  fill_spec_shape.npy -│ ├──  fill_times.npy -│ ├──  fishgrid.cfg -│ ├──  fund_v.npy -│ ├──  ident_v.npy -│ ├──  idx_v.npy -│ ├──  LED_frames.npy -│ ├──  led_idxs.csv -│ ├──  led_times.csv -│ ├──  LED_val.npy -│ ├──  meta.npy -│ ├──  sign_v.npy -│ ├──  spec.npy -│ ├──  times.npy -│ └──  traces-grid1.raw -└──  mount_data -``` - - - - - - - - - - - - - -

(back to top)

- - - - ## Getting Started This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps. - - - - - - - - -### Installation - -1. Get a free API Key at [https://example.com](https://example.com) -2. Clone the repo - ```sh - git clone https://github.com/github_username/repo_name.git - ``` -3. Install NPM packages - ```sh - npm install - ``` -4. Enter your API in `config.js` - ```js - const API_KEY = 'ENTER YOUR API'; - ``` - -

(back to top)

- - ## Usage @@ -193,68 +63,80 @@ _For more examples, please refer to the [Documentation](https://example.com)_

(back to top)

- - -## Roadmap +## To do - [ ] Feature 1 - [ ] Feature 2 - [ ] Feature 3 - [ ] Nested Feature -See the [open issues](https://github.com/github_username/repo_name/issues) for a full list of proposed features (and known issues). - -

(back to top)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -## Contact - -Your Name - [@twitter_handle](https://twitter.com/twitter_handle) - email@email_client.com - -Project Link: [https://github.com/github_username/repo_name](https://github.com/github_username/repo_name) -

(back to top)

- - -## Acknowledgments - -* []() -* []() -* []() - -

(back to top)

- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -289,3 +171,4 @@ Project Link: [https://github.com/github_username/repo_name](https://github.com/ [JQuery.com]: https://img.shields.io/badge/jQuery-0769AD?style=for-the-badge&logo=jquery&logoColor=white [JQuery-url]: https://jquery.com + diff --git a/poster_frozen/figs/algorithm.pdf b/poster_printed/figs/algorithm.pdf similarity index 100% rename from poster_frozen/figs/algorithm.pdf rename to poster_printed/figs/algorithm.pdf diff --git a/poster_frozen/figs/algorithm1.pdf b/poster_printed/figs/algorithm1.pdf similarity index 100% rename from poster_frozen/figs/algorithm1.pdf rename to poster_printed/figs/algorithm1.pdf diff --git a/poster_frozen/figs/chirps_in_chasing.pdf b/poster_printed/figs/chirps_in_chasing.pdf similarity index 100% rename from poster_frozen/figs/chirps_in_chasing.pdf rename to poster_printed/figs/chirps_in_chasing.pdf diff --git a/poster_frozen/figs/chirps_winner_loser.pdf b/poster_printed/figs/chirps_winner_loser.pdf similarity index 100% rename from poster_frozen/figs/chirps_winner_loser.pdf rename to poster_printed/figs/chirps_winner_loser.pdf diff --git a/poster_frozen/figs/efishlogo.pdf b/poster_printed/figs/efishlogo.pdf similarity index 100% rename from poster_frozen/figs/efishlogo.pdf rename to poster_printed/figs/efishlogo.pdf diff --git a/poster_frozen/figs/introplot.pdf b/poster_printed/figs/introplot.pdf similarity index 100% rename from poster_frozen/figs/introplot.pdf rename to poster_printed/figs/introplot.pdf diff --git a/poster_frozen/figs/kde.pdf b/poster_printed/figs/kde.pdf similarity index 100% rename from poster_frozen/figs/kde.pdf rename to poster_printed/figs/kde.pdf diff --git a/poster_frozen/figs/logo_all.pdf b/poster_printed/figs/logo_all.pdf similarity index 100% rename from poster_frozen/figs/logo_all.pdf rename to poster_printed/figs/logo_all.pdf diff --git a/poster_frozen/figs/timeline.pdf b/poster_printed/figs/timeline.pdf similarity index 100% rename from poster_frozen/figs/timeline.pdf rename to poster_printed/figs/timeline.pdf diff --git a/poster_frozen/main.pdf b/poster_printed/main.pdf similarity index 100% rename from poster_frozen/main.pdf rename to poster_printed/main.pdf diff --git a/poster_frozen/main.tex b/poster_printed/main.tex similarity index 100% rename from poster_frozen/main.tex rename to poster_printed/main.tex diff --git a/poster_frozen/packages.tex b/poster_printed/packages.tex similarity index 100% rename from poster_frozen/packages.tex rename to poster_printed/packages.tex diff --git a/poster_frozen/poster.pdf b/poster_printed/poster.pdf similarity index 100% rename from poster_frozen/poster.pdf rename to poster_printed/poster.pdf diff --git a/poster_frozen/style.tex b/poster_printed/style.tex similarity index 100% rename from poster_frozen/style.tex rename to poster_printed/style.tex diff --git a/requirements.txt b/requirements.txt index ad47b80..af5d16a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -audioio==0.10.0 cmocean==2.0 cycler==0.11.0 ipython==8.12.0 @@ -9,5 +8,4 @@ paramiko==2.11.1 PyYAML==6.0 scipy==1.10.1 scp==0.14.5 -thunderfish==1.9.10 tqdm==4.64.1