Skip to content

Commit

Permalink
add lab exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
fabridamicelli committed Oct 16, 2024
1 parent 33a3441 commit bbf749b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 26 deletions.
28 changes: 17 additions & 11 deletions chapters/lab_explore_data_exercises.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,41 @@
"metadata": {},
"source": [
"## Exercises 2\n",
"We will start by making sure our data/metadata contains the information we expect at a high level.\n",
"\n",
"a) Verify that all subject directories have a eeg sub-directory. \n",
"b) Verify that all data in a subject directories matches with the subject number. \n",
"c) Assert that EEG data for all subjects was taken using 20 channels and sampling frequency 500. \n",
"d) Write a file (`discarded_subjects.txt`) with the subject numbers that do not match that criterion. "
"d) (Optional) Write a file (`discarded_subjects.txt`) with the subject numbers that do not match that criterion. "
]
},
{
"cell_type": "markdown",
"id": "39bea8f9-4d4a-406f-93a8-146d5893872f",
"id": "3af93b8f-e20d-42f8-8c17-0830ba14c8b6",
"metadata": {},
"source": [
"## Exercises 3\n",
"Now we want to look at the data.\n",
"We find that the data is in a particular format `.edf` that we cannot directly read in python. \n",
"Hint: We need to install a third-party library `mne` to read `.edf` files. \n",
"We will take here a little detour to look at the chapter \"Dependencies\" to learn how we deal with them."
"\n",
"a) Plot a histogram of RecordingDuration across all subjects. \n",
"b) Plot one time series.\n",
"c) Plot all time series with labels according to channel name. \n",
"d) Plot the T* and O* channels. "
]
},
{
"cell_type": "markdown",
"id": "3af93b8f-e20d-42f8-8c17-0830ba14c8b6",
"id": "196f319e-51a8-48bd-91f0-931978a5ec04",
"metadata": {},
"source": [
"## Exercises 3\n",
"a) Plot a histogram of RecordingDuration across all subjects. \n",
"b) Plot one time series.\n",
"c) Plot all time series with labels according to channel name. \n",
"d) Plot the T* and O* channels. \n",
"e) Substract the mean from each channel\n",
"f) Plot correlation matrix of all-vs-all channels"
"## Exercises 4\n",
"After having taken this quick look at the data, we want to start processing the data.\n",
"\n",
"a) Add a column called `channel_mean` that\n",
"b) Substract the mean from each channel\n",
"c) Plot correlation matrix of all-vs-all channels"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion docs/081_pandas.html
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,10 @@ <h1 class="title"><span class="chapter-number">15</span>&nbsp; <span class="chap
<h2 data-number="15.1" class="anchored" data-anchor-id="exercises"><span class="header-section-number">15.1</span> Exercises</h2>
<p>Series from dict Missing values</p>
<p>Series from dict Display first 7 elements Display last 7 elements Read in data, assign column names Read in only X rows Compute mean of 1 column Add two columns (numbers) Add two columns (strings) Add a column to existing dataframe Add an indicator column to existing dataframe</p>
<p>Find an interesting dataset, download and explore a bit.</p>
<p>Find an interesting dataset, download and explore it.</p>
<p>Discard rows with missing values Fill missing values Drop entire rows (by index) Drop entire cols Sort elements (index, values)</p>
<p>Summary metric on specific cols Substract mean of a col from other columns</p>
<p>Select a couple of columns of DF (list of str) Select with boolean mask Select with loc Select with iloc</p>


</section>
Expand Down
5 changes: 3 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,16 @@ <h1 class="title">Python Course</h1>
<section id="about-the-course" class="level1 unnumbered">
<h1 class="unnumbered">About the Course</h1>
<p>This is a short introduction to the Python programming language.<br>
The main goal is to be productive right away, so we will emphasize <strong>practical</strong> over theoretical aspects with a focus on data-related tasks, a great target for the Python language!</p>
We will emphasize practical over theoretical aspects with a focus on data-related tasks, a great target for the Python language!</p>
<p>After the course, you will have practical tools under your belt to tackle daily data-related and common automation tasks with Python as well as enough knowledge to bootstrap yourself in your own learning path.</p>
<p>You can check out the code notebooks and report any problems on <a href="https://www.github.com/fabridamicelli/python-course">this GitHub repository</a>.</p>
<p>Off we go! 🚀</p>
</section>
<section id="about-the-author" class="level1">
<h1>About the Author</h1>
<p>Fabrizio Damicelli (PhD, Computational Neuroscience) is a self-taught coder who prefers simple words and solid intuitions to unnecessary sophistication and fancy jargon.<br>
Open source advocate, creator and maintainer of a few of Python packages.<br>
Learn more <a href="https://fabridamicelli.github.io/">here</a></p>
Learn more about him <a href="https://fabridamicelli.github.io/">here</a>.</p>


</section>
Expand Down
20 changes: 15 additions & 5 deletions docs/lab_explore_data_exercises.html
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ <h2 id="toc-title">Table of contents</h2>
<li><a href="#exercises-1" id="toc-exercises-1" class="nav-link active" data-scroll-target="#exercises-1"><span class="header-section-number">21.1</span> Exercises 1</a></li>
<li><a href="#exercises-2" id="toc-exercises-2" class="nav-link" data-scroll-target="#exercises-2"><span class="header-section-number">21.2</span> Exercises 2</a></li>
<li><a href="#exercises-3" id="toc-exercises-3" class="nav-link" data-scroll-target="#exercises-3"><span class="header-section-number">21.3</span> Exercises 3</a></li>
<li><a href="#exercises-4" id="toc-exercises-4" class="nav-link" data-scroll-target="#exercises-4"><span class="header-section-number">21.4</span> Exercises 4</a></li>
</ul>
</nav>
</div>
Expand Down Expand Up @@ -413,29 +414,38 @@ <h2 data-number="21.1" class="anchored" data-anchor-id="exercises-1"><span class
</section>
<section id="exercises-2" class="level2" data-number="21.2">
<h2 data-number="21.2" class="anchored" data-anchor-id="exercises-2"><span class="header-section-number">21.2</span> Exercises 2</h2>
<p>We will start by making sure our data/metadata contains the information we expect at a high level.</p>
<ol type="a">
<li>Verify that all subject directories have a eeg sub-directory.<br>
</li>
<li>Verify that all data in a subject directories matches with the subject number.<br>
</li>
<li>Assert that EEG data for all subjects was taken using 20 channels and sampling frequency 500.<br>
</li>
<li>Write a file (<code>discarded_subjects.txt</code>) with the subject numbers that do not match that criterion.</li>
<li>(Optional) Write a file (<code>discarded_subjects.txt</code>) with the subject numbers that do not match that criterion.</li>
</ol>
<p>Now we want to look at the data. We find that the data is in a particular format <code>.edf</code> that we cannot directly read in python.<br>
We need to install third-party library.<br>
We will take here a little detour to look at the chapter “Dependencies” to learn how we deal with them.</p>
</section>
<section id="exercises-3" class="level2" data-number="21.3">
<h2 data-number="21.3" class="anchored" data-anchor-id="exercises-3"><span class="header-section-number">21.3</span> Exercises 3</h2>
<p>Now we want to look at the data. We find that the data is in a particular format <code>.edf</code> that we cannot directly read in python.<br>
Hint: We need to install a third-party library <code>mne</code> to read <code>.edf</code> files.</p>
<ol type="a">
<li>Plot a histogram of RecordingDuration across all subjects.<br>
</li>
<li>Plot one time series. (Hint: use the library “mne” to read the .edf file)</li>
<li>Plot one time series.</li>
<li>Plot all time series with labels according to channel name.<br>
</li>
<li>Plot the T* and O* channels.</li>
</ol>
</section>
<section id="exercises-4" class="level2" data-number="21.4">
<h2 data-number="21.4" class="anchored" data-anchor-id="exercises-4"><span class="header-section-number">21.4</span> Exercises 4</h2>
<p>After having taken this quick look at the data, we want to start processing the data.</p>
<ol type="a">
<li>Add a column called <code>channel_mean</code> that</li>
<li>Substract the mean from each channel</li>
<li>Plot correlation matrix of all-vs-all channels</li>
</ol>


</section>
Expand Down
18 changes: 14 additions & 4 deletions docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"href": "index.html",
"title": "Python Course",
"section": "",
"text": "About the Course\nThis is a short introduction to the Python programming language.\nThe main goal is to be productive right away, so we will emphasize practical over theoretical aspects with a focus on data-related tasks, a great target for the Python language!\nAfter the course, you will have practical tools under your belt to tackle daily data-related and common automation tasks with Python as well as enough knowledge to bootstrap yourself in your own learning path.\nOff we go! 🚀\n\n\nAbout the Author\nFabrizio Damicelli (PhD, Computational Neuroscience) is a self-taught coder who prefers simple words and solid intuitions to unnecessary sophistication and fancy jargon.\nOpen source advocate, creator and maintainer of a few of Python packages.\nLearn more here",
"text": "About the Course\nThis is a short introduction to the Python programming language.\nWe will emphasize practical over theoretical aspects with a focus on data-related tasks, a great target for the Python language!\nAfter the course, you will have practical tools under your belt to tackle daily data-related and common automation tasks with Python as well as enough knowledge to bootstrap yourself in your own learning path.\nYou can check out the code notebooks and report any problems on this GitHub repository.\nOff we go! 🚀\n\n\nAbout the Author\nFabrizio Damicelli (PhD, Computational Neuroscience) is a self-taught coder who prefers simple words and solid intuitions to unnecessary sophistication and fancy jargon.\nOpen source advocate, creator and maintainer of a few of Python packages.\nLearn more about him here.",
"crumbs": [
"About the Course"
]
Expand Down Expand Up @@ -634,7 +634,7 @@
"href": "081_pandas.html",
"title": "15  Pandas",
"section": "",
"text": "15.1 Exercises\nSeries from dict Missing values\nSeries from dict Display first 7 elements Display last 7 elements Read in data, assign column names Read in only X rows Compute mean of 1 column Add two columns (numbers) Add two columns (strings) Add a column to existing dataframe Add an indicator column to existing dataframe\nFind an interesting dataset, download and explore a bit.\nDiscard rows with missing values Fill missing values Drop entire rows (by index) Drop entire cols Sort elements (index, values)\nSummary metric on specific cols Substract mean of a col from other columns",
"text": "15.1 Exercises\nSeries from dict Missing values\nSeries from dict Display first 7 elements Display last 7 elements Read in data, assign column names Read in only X rows Compute mean of 1 column Add two columns (numbers) Add two columns (strings) Add a column to existing dataframe Add an indicator column to existing dataframe\nFind an interesting dataset, download and explore it.\nDiscard rows with missing values Fill missing values Drop entire rows (by index) Drop entire cols Sort elements (index, values)\nSummary metric on specific cols Substract mean of a col from other columns\nSelect a couple of columns of DF (list of str) Select with boolean mask Select with loc Select with iloc",
"crumbs": [
"<span class='chapter-number'>15</span>  <span class='chapter-title'>Pandas</span>"
]
Expand Down Expand Up @@ -834,7 +834,7 @@
"href": "lab_explore_data_exercises.html#exercises-2",
"title": "21  Lab: Exploring a Dataset",
"section": "21.2 Exercises 2",
"text": "21.2 Exercises 2\n\nVerify that all subject directories have a eeg sub-directory.\n\nVerify that all data in a subject directories matches with the subject number.\n\nAssert that EEG data for all subjects was taken using 20 channels and sampling frequency 500.\n\nWrite a file (discarded_subjects.txt) with the subject numbers that do not match that criterion.\n\nNow we want to look at the data. We find that the data is in a particular format .edf that we cannot directly read in python.\nWe need to install third-party library.\nWe will take here a little detour to look at the chapter “Dependencies” to learn how we deal with them.",
"text": "21.2 Exercises 2\nWe will start by making sure our data/metadata contains the information we expect at a high level.\n\nVerify that all subject directories have a eeg sub-directory.\n\nVerify that all data in a subject directories matches with the subject number.\n\nAssert that EEG data for all subjects was taken using 20 channels and sampling frequency 500.\n\n(Optional) Write a file (discarded_subjects.txt) with the subject numbers that do not match that criterion.",
"crumbs": [
"<span class='chapter-number'>21</span>  <span class='chapter-title'>Lab: Exploring a Dataset</span>"
]
Expand All @@ -844,7 +844,17 @@
"href": "lab_explore_data_exercises.html#exercises-3",
"title": "21  Lab: Exploring a Dataset",
"section": "21.3 Exercises 3",
"text": "21.3 Exercises 3\n\nPlot a histogram of RecordingDuration across all subjects.\n\nPlot one time series. (Hint: use the library “mne” to read the .edf file)\nPlot all time series with labels according to channel name.\n\nPlot the T* and O* channels.",
"text": "21.3 Exercises 3\nNow we want to look at the data. We find that the data is in a particular format .edf that we cannot directly read in python.\nHint: We need to install a third-party library mne to read .edf files.\n\nPlot a histogram of RecordingDuration across all subjects.\n\nPlot one time series.\nPlot all time series with labels according to channel name.\n\nPlot the T* and O* channels.",
"crumbs": [
"<span class='chapter-number'>21</span>  <span class='chapter-title'>Lab: Exploring a Dataset</span>"
]
},
{
"objectID": "lab_explore_data_exercises.html#exercises-4",
"href": "lab_explore_data_exercises.html#exercises-4",
"title": "21  Lab: Exploring a Dataset",
"section": "21.4 Exercises 4",
"text": "21.4 Exercises 4\nAfter having taken this quick look at the data, we want to start processing the data.\n\nAdd a column called channel_mean that\nSubstract the mean from each channel\nPlot correlation matrix of all-vs-all channels",
"crumbs": [
"<span class='chapter-number'>21</span>  <span class='chapter-title'>Lab: Exploring a Dataset</span>"
]
Expand Down
6 changes: 3 additions & 3 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://fabridamicelli.github.io/python-course/index.html</loc>
<lastmod>2024-10-14T17:16:31.238Z</lastmod>
<lastmod>2024-10-16T11:51:27.788Z</lastmod>
</url>
<url>
<loc>https://fabridamicelli.github.io/python-course/01_getting_started.html</loc>
Expand Down Expand Up @@ -62,7 +62,7 @@
</url>
<url>
<loc>https://fabridamicelli.github.io/python-course/081_pandas.html</loc>
<lastmod>2024-10-15T15:08:55.034Z</lastmod>
<lastmod>2024-10-16T11:44:09.906Z</lastmod>
</url>
<url>
<loc>https://fabridamicelli.github.io/python-course/09_plotting.html</loc>
Expand All @@ -86,7 +86,7 @@
</url>
<url>
<loc>https://fabridamicelli.github.io/python-course/lab_explore_data_exercises.html</loc>
<lastmod>2024-10-14T17:33:33.451Z</lastmod>
<lastmod>2024-10-16T12:15:26.677Z</lastmod>
</url>
<url>
<loc>https://fabridamicelli.github.io/python-course/notebook_workflow.html</loc>
Expand Down

0 comments on commit bbf749b

Please sign in to comment.