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
1a803371
Commit
1a803371
authored
5 days ago
by
LexvanGastel
Browse files
Options
Downloads
Patches
Plain Diff
Text and input
parent
164a44d4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Q2main.py
+1
-1
1 addition, 1 deletion
Q2main.py
Q3main.py
+30
-22
30 additions, 22 deletions
Q3main.py
with
31 additions
and
23 deletions
Q2main.py
+
1
−
1
View file @
1a803371
...
...
@@ -48,7 +48,7 @@ class ImageProcessor:
return
red_mask
,
yellow_mask
,
green_mask
def
detect_blobs
(
mask
,
min_sigma
=
5
,
max_sigma
=
5
0
,
num_sigma
=
10
,
threshold
=
0.
5
):
def
detect_blobs
(
mask
,
min_sigma
=
5
,
max_sigma
=
3
0
,
num_sigma
=
10
,
threshold
=
0.
2
):
mask
=
mask
.
astype
(
np
.
float64
)
/
255.0
#print('mask made')
blobs
=
blob_log
(
mask
,
min_sigma
=
min_sigma
,
max_sigma
=
max_sigma
,
num_sigma
=
num_sigma
,
threshold
=
threshold
)
...
...
This diff is collapsed.
Click to expand it.
Q3main.py
+
30
−
22
View file @
1a803371
import
scipy.io
# Load the .mat file
mat_file
=
'
emg_data_walking.mat
'
data
=
scipy
.
io
.
loadmat
(
mat_file
)
def
load_emg_data
(
file_path
):
"""
Laadt EMG-gegevens uit een .mat bestand en retourneert de kanaalnamen.
"""
try
:
mat_data
=
scipy
.
io
.
loadmat
(
file_path
)
emg_data
=
mat_data
.
get
(
'
emg_data_walking
'
)
if
emg_data
is
None
:
raise
KeyError
(
"
De verwachte variabele
'
emg_data_walking
'
is niet in het bestand aanwezig.
"
)
channel_names
=
[
ch
[
0
]
for
ch
in
emg_data
[
'
data_headers
'
][
0
][
0
][
0
]]
print
(
"
EMG-kanalen:
"
)
for
idx
,
name
in
enumerate
(
channel_names
):
print
(
f
"
{
idx
}
:
{
name
}
"
)
return
channel_names
except
Exception
as
e
:
print
(
f
"
Fout bij het laden van het EMG-bestand:
{
e
}
"
)
return
[]
# Display the keys in the loaded structure
print
(
"
Keys in the loaded .mat file:
"
,
data
.
keys
()
)
file_path
=
"
emg_data_walking.mat
"
channel_names
=
load_emg_data
(
file_path
)
#
Analyze the structure of the data (check what is inside the 'data' dictionary)
# This will help you understand what variables are present
for
key
,
value
in
data
.
items
():
print
(
f
"
Key:
{
key
}
, Type:
{
type
(
value
)
}
"
)
print
(
f
"
Value shape:
{
value
.
shape
if
hasattr
(
value
,
'
shape
'
)
else
'
N/A
'
}
\n
"
)
#
Gekozen spieren met validatie
chosen_muscles
=
{
'
rectus_femoris
'
:
0
,
'
tibialis_anterior
'
:
7
}
# Now, assuming the EMG channels are contained in a variable called 'emgChannels'
# You will need to adjust the field name depending on the structure of your file
if
'
emgChannels
'
in
data
:
emg_channels
=
data
[
'
emgChannels
'
]
# If 'emgChannels' contains the names, extract and display them
if
isinstance
(
emg_channels
,
np
.
ndarray
)
and
emg_channels
.
ndim
==
2
:
print
(
"
\n
EMG Channel Names:
"
)
for
channel
in
emg_channels
.
flatten
():
print
(
channel
)
else
:
print
(
"
\n
'
EMG channels
'
not found in the data. Please check the structure.
"
)
\ No newline at end of file
valid_muscles
=
{
name
:
idx
for
name
,
idx
in
chosen_muscles
.
items
()
if
idx
<
len
(
channel_names
)}
print
(
f
"
Gekozen spieren:
{
valid_muscles
}
"
)
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