Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
assignment Programming 2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gastel, L. van (Lex, Student B-BMT)
assignment Programming 2
Commits
c7cf0c1c
Commit
c7cf0c1c
authored
1 week ago
by
LexvanGastel
Browse files
Options
Downloads
Patches
Plain Diff
vraag9
parent
9ceb0184
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+49
-13
49 additions, 13 deletions
main.py
with
49 additions
and
13 deletions
main.py
+
49
−
13
View file @
c7cf0c1c
import
scipy.io
import
numpy
as
np
from
scipy.signal
import
butter
,
filtfilt
import
scipy.signal
import
matplotlib.pyplot
as
plt
def
load_emg_data
(
file_path
):
...
...
@@ -25,8 +26,8 @@ def load_emg_data(file_path):
return
channel_names
file_path
=
"
emg_data_walking.mat
"
load_emg_data
(
file_path
)
#
file_path = "emg_data_walking.mat"
#
load_emg_data(file_path)
chosen_muscles
=
{
'
rectus_fomoris
'
:
0
,
...
...
@@ -43,7 +44,7 @@ class DataRetrieval:
def
load_data
(
self
):
mat_data
=
scipy
.
io
.
loadmat
(
self
.
file_path
)
self
.
emg_data
=
mat_data
[
'
emg_data_walking
'
]
self
.
channel_names
=
emg_data
[
'
data_headers
'
][
0
][
0
]
self
.
channel_names
=
self
.
emg_data
[
'
data_headers
'
][
0
][
0
]
self
.
channel_names
=
[
ch
[
0
]
for
ch
in
self
.
channel_names
[
0
]]
def
get_channel_names
(
self
):
...
...
@@ -63,15 +64,50 @@ class SignalProcessing:
pass
#print(dir(scipy.signal))
mat_data
=
scipy
.
io
.
loadmat
(
'
emg_data_walking.mat
'
)
emg_data
=
mat_data
[
'
emg_data_walking
'
]
sampling_rate
=
emg_data
[
'
sampling_rate
'
][
0
][
0
][
0
]
data
=
emg_data
[
'
data
'
][
0
][
0
]
num_samples
=
data
.
shape
[
1
]
def
info_emg_data
(
file_path
):
mat_data
=
scipy
.
io
.
loadmat
(
file_path
)
emg_data
=
mat_data
[
'
emg_data_walking
'
]
sampling_rate
=
emg_data
[
'
sampling_rate
'
][
0
][
0
][
0
]
data
=
emg_data
[
'
data
'
][
0
][
0
]
num_samples
=
data
.
shape
[
1
]
duration
=
num_samples
/
sampling_rate
return
sampling_rate
,
data
,
num_samples
,
duration
#file_path = "emg_data_walking.mat"
#info_emg_data(file_path)
def
plot_emg_data
(
file_path
):
sampling_rate
,
data
,
num_samples
,
duration
=
info_emg_data
(
file_path
)
sampling_time
=
float
(
1
/
sampling_rate
)
time_vector
=
np
.
arange
(
0
,
duration
,
sampling_time
)
channel_rectus_femoris
=
data
[
chosen_muscles
[
'
rectus_fomoris
'
],
:]
channel_tibialis_anterior
=
data
[
chosen_muscles
[
'
tibialis_anterior
'
],
:]
plt
.
figure
(
figsize
=
(
10
,
6
))
plt
.
subplot
(
2
,
1
,
1
)
plt
.
plot
(
time_vector
,
channel_rectus_femoris
)
plt
.
title
(
'
EMG Data - Rectus femoris
'
)
plt
.
xlabel
(
'
Time [Seconds]
'
)
plt
.
ylabel
(
'
Amplitude
'
)
plt
.
subplot
(
2
,
1
,
2
)
plt
.
plot
(
time_vector
,
channel_tibialis_anterior
)
plt
.
title
(
'
EMG Data - Tibialis Anterior
'
)
plt
.
xlabel
(
'
Time [seconds]
'
)
plt
.
ylabel
(
'
Amplitude
'
)
plt
.
tight_layout
()
plt
.
show
()
file_path
=
"
emg_data_walking
"
plot_emg_data
(
file_path
)
duration
=
num_samples
/
sampling_rate
print
(
f
"
Sampling frequentie:
{
sampling_rate
}
Hz
"
)
print
(
f
"
Aantal samples:
{
num_samples
}
"
)
print
(
f
"
Lengte van de data:
{
duration
}
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment