Skip to content

Commit

Permalink
added discord notification for pushes
Browse files Browse the repository at this point in the history
  • Loading branch information
soulsyrup committed Nov 27, 2023
1 parent 6b5d28f commit c72290e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 70 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/discord_notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Send discord notification
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Send Discord notification to Server 1
env:
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }}
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an")
COMMIT_DESCRIPTION=$(git log -1 --pretty=format:"%b")
curl -X POST -H "Content-Type: application/json" -d "{ \"content\": \"New commit by $COMMIT_AUTHOR! Check out the latest changes: https://github.com/Unlimited-Research-Cooperative/human-cortical-organoid-signal-analysis/commits/${{ github.sha }}\", \"embeds\": [ { \"title\": \"$COMMIT_MESSAGE\", \"description\": \"$COMMIT_DESCRIPTION\" } ] }" https://discord.com/api/webhooks/$DISCORD_WEBHOOK_ID/$DISCORD_WEBHOOK_TOKEN
- name: Send Discord notification to Server 2
env:
URC_WEBHOOK_ID: ${{ secrets.URC_WEBHOOK_ID }}
URC_WEBHOOK_TOKEN: ${{ secrets.URC_WEBHOOK_TOKEN }}
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an")
COMMIT_DESCRIPTION=$(git log -1 --pretty=format:"%b")
curl -X POST -H "Content-Type: application/json" -d "{ \"content\": \"New commit by $COMMIT_AUTHOR! Check out the latest changes: https://github.com/Unlimited-Research-Cooperative/human-cortical-organoid-signal-analysis/commits/${{ github.sha }}\", \"embeds\": [ { \"title\": \"$COMMIT_MESSAGE\", \"description\": \"$COMMIT_DESCRIPTION\" } ] }" https://discord.com/api/webhooks/$URC_WEBHOOK_ID/$URC_WEBHOOK_TOKEN
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"source": [
"import numpy as np\n",
"import scipy.stats as stats\n",
"from collections import Counter\n",
"\n",
"def load_data(filepath):\n",
" # Load your electrophysiological data\n",
Expand All @@ -34,40 +35,26 @@
" symbols.append('H') # High\n",
" return symbols\n",
"\n",
"def analyze_patterns(symbolic_data):\n",
" # Analyze patterns in symbolic sequences\n",
" # Implement your specific pattern analysis logic here\n",
" pass\n",
"def pattern_frequency(symbolic_sequence, pattern_length=3):\n",
" # Count frequency of each pattern of given length\n",
" patterns = [symbolic_sequence[i:i+pattern_length] for i in range(len(symbolic_sequence)-pattern_length+1)]\n",
" pattern_counts = Counter(patterns)\n",
" total_patterns = len(patterns)\n",
" pattern_freq = {pattern: count/total_patterns for pattern, count in pattern_counts.items()}\n",
" return pattern_freq\n",
"\n",
"def quantify_changes(pre_data, post_data):\n",
" # Existing entropy-based analysis\n",
" pre_entropy = stats.entropy(pre_data)\n",
" post_entropy = stats.entropy(post_data)\n",
" entropy_change = post_entropy - pre_entropy\n",
"def analyze_patterns(pre_symbols, post_symbols):\n",
" # Analyze changes in pattern frequencies\n",
" pre_freq = pattern_frequency(pre_symbols)\n",
" post_freq = pattern_frequency(post_symbols)\n",
"\n",
" # Additional metrics\n",
" transfer_entropy_change = calculate_transfer_entropy(pre_data, post_data)\n",
" fractal_dimension_change = calculate_higuchi_fractal_dimension(post_data) - calculate_higuchi_fractal_dimension(pre_data)\n",
" mfdfa_change = perform_mfdfa(post_data) - perform_mfdfa(pre_data)\n",
" phase_sync_change = calculate_phase_space_synchronization(pre_data, post_data)\n",
" spectral_change = perform_spectral_analysis(post_data) - perform_spectral_analysis(pre_data)\n",
" # Compute changes in frequencies\n",
" pattern_changes = {pattern: post_freq.get(pattern, 0) - pre_freq.get(pattern, 0) for pattern in set(pre_freq) | set(post_freq)}\n",
" return pattern_changes\n",
"\n",
" # Combine results\n",
" results = {\n",
" \"entropy_change\": entropy_change,\n",
" \"transfer_entropy_change\": transfer_entropy_change,\n",
" \"fractal_dimension_change\": fractal_dimension_change,\n",
" \"mfdfa_change\": mfdfa_change,\n",
" \"phase_sync_change\": phase_sync_change,\n",
" \"spectral_change\": spectral_change\n",
" }\n",
" return results\n",
"\n",
"\n",
"def perform_paired_t_test(data_before, data_after):\n",
" # Perform paired t-test\n",
" t_statistic, p_value = stats.ttest_rel(data_before, data_after)\n",
" return t_statistic, p_value\n",
"def quantify_changes(pattern_changes):\n",
" # Convert changes in pattern frequencies to a numeric metric for t-test\n",
" return np.mean(list(pattern_changes.values()))\n",
"\n",
"# Load data\n",
"pre_stim_data = load_data('path_to_pre_stimulation_data.npy')\n",
Expand All @@ -81,11 +68,10 @@
"post_symbols = symbolic_transformation(post_stim_data, thresholds)\n",
"\n",
"# Analyze patterns\n",
"analyze_patterns(pre_symbols)\n",
"analyze_patterns(post_symbols)\n",
"pattern_changes = analyze_patterns(pre_symbols, post_symbols)\n",
"\n",
"# Quantify changes for paired t-test\n",
"changes = quantify_changes(pre_symbols, post_symbols)\n",
"change_metric = quantify_changes(pattern_changes)\n",
"\n",
"# Perform paired t-test\n",
"t_statistic, p_value = perform_paired_t_test(pre_stim_data, post_stim_data)\n",
Expand All @@ -96,7 +82,7 @@
"if p_value < 0.05:\n",
" print(\"Significant changes observed in the cortical spheroids post-stimulation.\")\n",
"else:\n",
" print(\"No significant changes observed.\")\n"
" print(\"No significant changes observed.\")"
]
}
],
Expand Down
56 changes: 21 additions & 35 deletions symbolic_dynamics_metric/symbolic_dynamics_metric.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"source": [
"import numpy as np\n",
"import scipy.stats as stats\n",
"from collections import Counter\n",
"\n",
"def load_data(filepath):\n",
" # Load your electrophysiological data\n",
Expand All @@ -34,40 +35,26 @@
" symbols.append('H') # High\n",
" return symbols\n",
"\n",
"def analyze_patterns(symbolic_data):\n",
" # Analyze patterns in symbolic sequences\n",
" # Implement your specific pattern analysis logic here\n",
" pass\n",
"def pattern_frequency(symbolic_sequence, pattern_length=3):\n",
" # Count frequency of each pattern of given length\n",
" patterns = [symbolic_sequence[i:i+pattern_length] for i in range(len(symbolic_sequence)-pattern_length+1)]\n",
" pattern_counts = Counter(patterns)\n",
" total_patterns = len(patterns)\n",
" pattern_freq = {pattern: count/total_patterns for pattern, count in pattern_counts.items()}\n",
" return pattern_freq\n",
"\n",
"def quantify_changes(pre_data, post_data):\n",
" # Existing entropy-based analysis\n",
" pre_entropy = stats.entropy(pre_data)\n",
" post_entropy = stats.entropy(post_data)\n",
" entropy_change = post_entropy - pre_entropy\n",
"def analyze_patterns(pre_symbols, post_symbols):\n",
" # Analyze changes in pattern frequencies\n",
" pre_freq = pattern_frequency(pre_symbols)\n",
" post_freq = pattern_frequency(post_symbols)\n",
"\n",
" # Additional metrics\n",
" transfer_entropy_change = calculate_transfer_entropy(pre_data, post_data)\n",
" fractal_dimension_change = calculate_higuchi_fractal_dimension(post_data) - calculate_higuchi_fractal_dimension(pre_data)\n",
" mfdfa_change = perform_mfdfa(post_data) - perform_mfdfa(pre_data)\n",
" phase_sync_change = calculate_phase_space_synchronization(pre_data, post_data)\n",
" spectral_change = perform_spectral_analysis(post_data) - perform_spectral_analysis(pre_data)\n",
" # Compute changes in frequencies\n",
" pattern_changes = {pattern: post_freq.get(pattern, 0) - pre_freq.get(pattern, 0) for pattern in set(pre_freq) | set(post_freq)}\n",
" return pattern_changes\n",
"\n",
" # Combine results\n",
" results = {\n",
" \"entropy_change\": entropy_change,\n",
" \"transfer_entropy_change\": transfer_entropy_change,\n",
" \"fractal_dimension_change\": fractal_dimension_change,\n",
" \"mfdfa_change\": mfdfa_change,\n",
" \"phase_sync_change\": phase_sync_change,\n",
" \"spectral_change\": spectral_change\n",
" }\n",
" return results\n",
"\n",
"\n",
"def perform_paired_t_test(data_before, data_after):\n",
" # Perform paired t-test\n",
" t_statistic, p_value = stats.ttest_rel(data_before, data_after)\n",
" return t_statistic, p_value\n",
"def quantify_changes(pattern_changes):\n",
" # Convert changes in pattern frequencies to a numeric metric for t-test\n",
" return np.mean(list(pattern_changes.values()))\n",
"\n",
"# Load data\n",
"pre_stim_data = load_data('path_to_pre_stimulation_data.npy')\n",
Expand All @@ -81,11 +68,10 @@
"post_symbols = symbolic_transformation(post_stim_data, thresholds)\n",
"\n",
"# Analyze patterns\n",
"analyze_patterns(pre_symbols)\n",
"analyze_patterns(post_symbols)\n",
"pattern_changes = analyze_patterns(pre_symbols, post_symbols)\n",
"\n",
"# Quantify changes for paired t-test\n",
"changes = quantify_changes(pre_symbols, post_symbols)\n",
"change_metric = quantify_changes(pattern_changes)\n",
"\n",
"# Perform paired t-test\n",
"t_statistic, p_value = perform_paired_t_test(pre_stim_data, post_stim_data)\n",
Expand All @@ -96,7 +82,7 @@
"if p_value < 0.05:\n",
" print(\"Significant changes observed in the cortical spheroids post-stimulation.\")\n",
"else:\n",
" print(\"No significant changes observed.\")\n"
" print(\"No significant changes observed.\")"
]
}
],
Expand Down

0 comments on commit c72290e

Please sign in to comment.