{
  "id": 467955,
  "title": "Looking at EEG files with multiple distinct brain activity classes",
  "url": "/competitions/hms-harmful-brain-activity-classification/discussion/467955",
  "author_name": "Jacob Sharples",
  "post_date": "2024-01-14T19:43:54.778000",
  "votes": 5,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Based on the training data, there are 783 different EEG files with more than one distinct brain activity class. However, some of these consolidated EEG files contain as many as 412 windows in the file (eeg_sub_id). It could be interesting to look at the EEG files with the <strong>most distinct brain activity classes</strong> given the <strong>least amount of eeg_sub_id</strong>. </p>\n<p>The code below finds the eeg files based on this 'activity_ratio' (number of unique brain activity classes / number of eeg_sub_id). I filter to only look at files that have multiple unique brain activity classes.</p>\n<pre><code>df = pd()\n\n(df\n (, as_index=False)\n \n ()\n (, axis=)\n (df)\n (, as_index=False)\n ({:,\n      :})\n (\n     activity_ratio = lambda x: x / x\n )\n (, ascending=False)\n ()\n)\n</code></pre>\n<p>Here is an example of an EEG file with a high activity ratio: <strong>1416585128</strong>. There are only three different windows in the EEG file (eeg_sub_id) and three different activity brain activity classes.</p>\n<p>Only look at Fp1 as an example:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6247135%2Fc01fcfd4c09bc87b36b5f7c765a0ba55%2Fexample_eeg_visual_1416585128.svg?generation=1705261179593013&amp;alt=media\"></p>\n<p>It could be interesting to look at these specific EEG files since they can potentially contain a relatively large amount of information in brain activity classes.</p>",
  "messages": [
    {
      "id": 2601936,
      "postDate": "2024-01-14T19:43:54.780Z",
      "content": "<p>Based on the training data, there are 783 different EEG files with more than one distinct brain activity class. However, some of these consolidated EEG files contain as many as 412 windows in the file (eeg_sub_id). It could be interesting to look at the EEG files with the <strong>most distinct brain activity classes</strong> given the <strong>least amount of eeg_sub_id</strong>. </p>\n<p>The code below finds the eeg files based on this 'activity_ratio' (number of unique brain activity classes / number of eeg_sub_id). I filter to only look at files that have multiple unique brain activity classes.</p>\n<pre><code>df = pd()\n\n(df\n (, as_index=False)\n \n ()\n (, axis=)\n (df)\n (, as_index=False)\n ({:,\n      :})\n (\n     activity_ratio = lambda x: x / x\n )\n (, ascending=False)\n ()\n)\n</code></pre>\n<p>Here is an example of an EEG file with a high activity ratio: <strong>1416585128</strong>. There are only three different windows in the EEG file (eeg_sub_id) and three different activity brain activity classes.</p>\n<p>Only look at Fp1 as an example:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6247135%2Fc01fcfd4c09bc87b36b5f7c765a0ba55%2Fexample_eeg_visual_1416585128.svg?generation=1705261179593013&amp;alt=media\"></p>\n<p>It could be interesting to look at these specific EEG files since they can potentially contain a relatively large amount of information in brain activity classes.</p>",
      "rawMarkdown": "Based on the training data, there are 783 different EEG files with more than one distinct brain activity class. However, some of these consolidated EEG files contain as many as 412 windows in the file (eeg_sub_id). It could be interesting to look at the EEG files with the **most distinct brain activity classes** given the **least amount of eeg_sub_id**. \n\nThe code below finds the eeg files based on this 'activity_ratio' (number of unique brain activity classes / number of eeg_sub_id). I filter to only look at files that have multiple unique brain activity classes.\n\n```\ndf = pd.read_csv(\"/kaggle/input/hms-harmful-brain-activity-classification/train.csv\")\n\n(df\n .groupby(['eeg_id'], as_index=False)\n ['expert_consensus']\n .nunique()\n .set_axis(['eeg_id', 'unique_activity'], axis=1)\n .merge(df)\n .groupby('eeg_id', as_index=False)\n .agg({'unique_activity':'max',\n      'eeg_sub_id':'nunique'})\n .assign(\n     activity_ratio = lambda x: x.unique_activity / x.eeg_sub_id\n )\n .sort_values('activity_ratio', ascending=False)\n .query(\"unique_activity > 1\")\n)\n```\n\nHere is an example of an EEG file with a high activity ratio: **1416585128**. There are only three different windows in the EEG file (eeg_sub_id) and three different activity brain activity classes.\n\nOnly look at Fp1 as an example:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6247135%2Fc01fcfd4c09bc87b36b5f7c765a0ba55%2Fexample_eeg_visual_1416585128.svg?generation=1705261179593013&alt=media)\n\nIt could be interesting to look at these specific EEG files since they can potentially contain a relatively large amount of information in brain activity classes.",
      "votes": 5
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2601936": "Based on the training data, there are 783 different EEG files with more than one distinct brain activity class. However, some of these consolidated EEG files contain as many as 412 windows in the file (eeg_sub_id). It could be interesting to look at the EEG files with the **most distinct brain activity classes** given the **least amount of eeg_sub_id**. \n\nThe code below finds the eeg files based on this 'activity_ratio' (number of unique brain activity classes / number of eeg_sub_id). I filter to only look at files that have multiple unique brain activity classes.\n\n```\ndf = pd.read_csv(\"/kaggle/input/hms-harmful-brain-activity-classification/train.csv\")\n\n(df\n .groupby(['eeg_id'], as_index=False)\n ['expert_consensus']\n .nunique()\n .set_axis(['eeg_id', 'unique_activity'], axis=1)\n .merge(df)\n .groupby('eeg_id', as_index=False)\n .agg({'unique_activity':'max',\n      'eeg_sub_id':'nunique'})\n .assign(\n     activity_ratio = lambda x: x.unique_activity / x.eeg_sub_id\n )\n .sort_values('activity_ratio', ascending=False)\n .query(\"unique_activity > 1\")\n)\n```\n\nHere is an example of an EEG file with a high activity ratio: **1416585128**. There are only three different windows in the EEG file (eeg_sub_id) and three different activity brain activity classes.\n\nOnly look at Fp1 as an example:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6247135%2Fc01fcfd4c09bc87b36b5f7c765a0ba55%2Fexample_eeg_visual_1416585128.svg?generation=1705261179593013&alt=media)\n\nIt could be interesting to look at these specific EEG files since they can potentially contain a relatively large amount of information in brain activity classes."
  }
}