Browse Source

Projektbericht hinzugefügt und % Fortschritt Anzeige grober gemacht

master
seyffejn 4 years ago
parent
commit
f05fa4faee

+ 47
- 65
TinnitusAnalyse/.idea/workspace.xml View File

@@ -2,11 +2,11 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="5b3f2136-e422-4072-84be-e86e40fa2d55" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/dictionaries/Julian.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dictionaries/Julian.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/MyTinnitusFreeSong.wav" beforeDir="false" afterPath="$PROJECT_DIR$/MyTinnitusFreeSong.wav" afterDir="false" />
<change beforePath="$PROJECT_DIR$/SoundGenerator.py" beforeDir="false" afterPath="$PROJECT_DIR$/SoundGenerator.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TinnitusAnalyse_GUI.py" beforeDir="false" afterPath="$PROJECT_DIR$/TinnitusAnalyse_GUI.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TinnitusDaten.csv" beforeDir="false" afterPath="$PROJECT_DIR$/TinnitusDaten.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/musikTest.wav" beforeDir="false" afterPath="$PROJECT_DIR$/musikTest.wav" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/venv/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -16,12 +16,12 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/TinnitusAnalyse_GUI.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352">
<caret line="210" lean-forward="true" selection-start-line="210" selection-end-line="210" />
<state>
<caret line="234" column="42" selection-start-line="234" selection-start-column="42" selection-end-line="234" selection-end-column="42" />
<folding>
<element signature="e#0#30#0" expanded="true" />
</folding>
@@ -30,28 +30,10 @@
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/io/wavfile.py">
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/fir_filter_design.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="275">
<caret line="263" selection-start-line="263" selection-end-line="263" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/filter_design.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="66">
<caret line="2278" column="41" selection-start-line="2278" selection-start-column="41" selection-end-line="2278" selection-end-column="41" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/tkinter/__init__.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="278">
<caret line="1557" selection-start-line="1557" selection-end-line="1557" />
<state relative-caret-position="6562">
<caret line="399" selection-start-line="399" selection-end-line="399" />
</state>
</provider>
</entry>
@@ -59,8 +41,8 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/SoundGenerator.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="373">
<caret line="278" selection-start-line="278" selection-end-line="278" />
<state relative-caret-position="583">
<caret line="257" selection-start-line="257" selection-end-line="257" />
<folding>
<element signature="e#0#42#0" expanded="true" />
</folding>
@@ -68,15 +50,6 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/signaltools.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="275">
<caret line="1694" column="4" selection-start-line="1694" selection-start-column="4" selection-end-line="1694" selection-end-column="4" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
@@ -111,9 +84,11 @@
<find>Speichern</find>
<find>csv</find>
<find>order</find>
<find>feedback</find>
<find>musikTest</find>
<find>Daten er</find>
<find>samples</find>
<find>feedback</find>
<find>framerate</find>
</findStrings>
<dirStrings>
<dir>C:\Users\Julian\PycharmProjects\TinnitusAnalyse</dir>
@@ -130,9 +105,9 @@
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="-8" />
<option name="y" value="-8" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="2520" />
<option name="y" value="-21" />
<option name="width" value="1294" />
<option name="height" value="1407" />
</component>
@@ -298,23 +273,23 @@
<servers />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="2576" height="1416" extended-state="6" />
<frame x="2552" y="-8" width="1696" height="1026" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Favorites" side_tool="true" />
<window_info content_ui="combo" id="Project" order="0" weight="0.25" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Version Control" weight="0.32969603" />
<window_info anchor="bottom" id="Python Console" weight="0.32969603" />
<window_info anchor="bottom" id="Terminal" weight="0.32969603" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32969603" />
<window_info anchor="bottom" id="Run" order="2" weight="0.47368422" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.3998441" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Version Control" order="7" weight="0.32969603" />
<window_info anchor="bottom" id="Terminal" order="8" weight="0.32969603" />
<window_info anchor="bottom" id="Event Log" order="9" side_tool="true" />
<window_info anchor="bottom" id="Python Console" order="10" weight="0.32969603" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -343,45 +318,52 @@
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/tkinter/__init__.py">
<entry file="file://$USER_HOME$/.PyCharmCE2019.1/system/python_stubs/-1242442885/builtins.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="278">
<caret line="1557" selection-start-line="1557" selection-end-line="1557" />
<state relative-caret-position="375">
<caret line="4857" column="53" selection-start-line="4857" selection-start-column="53" selection-end-line="4857" selection-end-column="53" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.PyCharmCE2019.1/system/python_stubs/-1242442885/builtins.py">
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/io/wavfile.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375">
<caret line="4857" column="53" selection-start-line="4857" selection-start-column="53" selection-end-line="4857" selection-end-column="53" />
<state relative-caret-position="4386">
<caret line="263" selection-start-line="263" selection-end-line="263" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/filter_design.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="38437">
<caret line="2278" column="41" selection-start-line="2278" selection-start-column="41" selection-end-line="2278" selection-end-column="41" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/signaltools.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="275">
<state relative-caret-position="28492">
<caret line="1694" column="4" selection-start-line="1694" selection-start-column="4" selection-end-line="1694" selection-end-column="4" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/filter_design.py">
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/tkinter/__init__.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="66">
<caret line="2278" column="41" selection-start-line="2278" selection-start-column="41" selection-end-line="2278" selection-end-column="41" />
<state relative-caret-position="-3474">
<caret line="1557" selection-start-line="1557" selection-end-line="1557" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/io/wavfile.py">
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python35/Lib/site-packages/scipy/signal/fir_filter_design.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="275">
<caret line="263" selection-start-line="263" selection-end-line="263" />
<state relative-caret-position="6562">
<caret line="399" selection-start-line="399" selection-end-line="399" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/TinnitusAnalyse_GUI.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352">
<caret line="210" lean-forward="true" selection-start-line="210" selection-end-line="210" />
<state>
<caret line="234" column="42" selection-start-line="234" selection-start-column="42" selection-end-line="234" selection-end-column="42" />
<folding>
<element signature="e#0#30#0" expanded="true" />
</folding>
@@ -390,8 +372,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/SoundGenerator.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="373">
<caret line="278" selection-start-line="278" selection-end-line="278" />
<state relative-caret-position="583">
<caret line="257" selection-start-line="257" selection-end-line="257" />
<folding>
<element signature="e#0#42#0" expanded="true" />
</folding>

BIN
TinnitusAnalyse/MyTinnitusFreeSong.wav View File


BIN
TinnitusAnalyse/Projektbericht/Abbildungen/Filter1_WhiteNoise_EchtzeitFilter.png View File


BIN
TinnitusAnalyse/Projektbericht/Projektbericht.docx View File


BIN
TinnitusAnalyse/Projektbericht/~$ojektbericht.docx View File


BIN
TinnitusAnalyse/Projektbericht/~WRL0004.tmp View File


+ 44
- 6
TinnitusAnalyse/SoundGenerator.py View File

@@ -6,7 +6,7 @@ import sys # für Fehlermeldungen
from scipy import signal
import csv
import time
#import matplotlib.pyplot as plt
import matplotlib.pyplot as plt

"""---------------------------------------------------------------------------------------------------------------------
In .wav-Dateien wird der Ton in absoluten Werte eingetragen. Die Standart-framerate ist 44100
@@ -151,6 +151,25 @@ class Sound:
# sosfilt filtert das Signal mittels mehrerer 'second order sections' (= Filter 2. Ordnung) die über sos definiert sind
outdata[:, 0] = signal.sosfilt(sos, outdata[:, 0])

# Plotten des Filters für Filterentwicklung und Dokumentation nützlich---------
# w, h = signal.sosfreqz(sos, worN=1500)
# plt.subplot(2, 1, 1)
# db = 20 * np.log10(np.maximum(np.abs(h), 1e-5))
# plt.plot(w / np.pi, db)
# plt.ylim(-75, 5)
# plt.grid(True)
# plt.yticks([0, -20, -40, -60])
# plt.ylabel('Gain [dB]')
# plt.title('Frequency Response')
# plt.subplot(2, 1, 2)
# plt.plot(w / np.pi, np.angle(h))
# plt.grid(True)
# plt.yticks([-np.pi, -0.5 * np.pi, 0, 0.5 * np.pi, np.pi],
# [r'$-\pi$', r'$-\pi/2$', '0', r'$\pi/2$', r'$\pi$'])
# plt.ylabel('Phase [rad]')
# plt.xlabel('Normalized frequency (1.0 = Nyquist)')
# plt.show()
# -------------------------------------------------------------------------------
if self.tinnitus.rechtsRauschenLautstaerke:
# (-3dB Grenzen) bzw was der Bandpass durchlässt
fGrenz = [self.tinnitus.rechtsRauschenUntereGrenzfrequenz,
@@ -238,11 +257,18 @@ class Sound:
# -------------------------------------

if ll != 0.0: # nur wenn die Lautstärke des linken Tinnitus ungleich 0 ist, wird auf diesem Ohr auch gefiltert

b, a = signal.iirfilter(order, cutoff_frequencies, rp=max_ripple_passband, btype='bandstop', ftype='butter',
fs=self.music_samplerate) # Diese Funktion erstellt den IIR-Bandpassfilter (links)

music_links = signal.lfilter(b, a, self.music_data[:, 0]) # diese Funktion filtert die Audiodaten

# FIR Filterversuch
# b = signal.firwin(order, cutoff_frequencies, pass_zero="bandstop", fs=self.music_samplerate, width=bandwidth,
# window="hamming")
#
# music_links = signal.lfilter(b, [1.0], self.music_data[:, 0])


else:
music_links = self.music_data[:, 0] # ungefiltert, wenn kein Tinnitus angegeben wurde

@@ -255,6 +281,12 @@ class Sound:
fs=self.music_samplerate) # Diese Funktion erstellt den IIR-Bandpassfilter (rechts)

music_rechts = signal.lfilter(b, a, self.music_data[:, 1]) # rechts

# FIR Filterversuch
# b = signal.firwin(order, cutoff_frequencies, pass_zero="bandstop", fs=self.music_samplerate, width=bandwidth,
# window="hamming")
#
# music_rechts = signal.lfilter(b, [1.0], self.music_data[:, 1])
else:
music_rechts = self.music_data[:, 1] # diese Funktion filtert die Audiodaten(die Tinnitusfreq wird entfernt)

@@ -267,13 +299,18 @@ class Sound:
#Maximum finden (Funktion max(...) ist minimal schneller, macht aber Probleme beim Feedback)
start_time = time.time()
max_ges = 0
fortschritt = 0
for i in range(nframes):
if max_ges < abs(music_links[i]):
max_ges = abs(music_links[i])
if max_ges < abs(music_rechts[i]):
max_ges = abs(music_rechts[i])
if i % 50000 == 0:
fortschritt = i / nframes * 100
if i % int(nframes/10) == 0: # glaub hier stand 10000 davor oder 50000
# fortschritt = i / nframes * 100
# self.filterfortschritt = 3, round(fortschritt, 1)
# print(" max: ", self.filterfortschritt[1], "%")

fortschritt += 10
self.filterfortschritt = 3, round(fortschritt, 1)
print(" max: ", self.filterfortschritt[1], "%")
end_time = time.time()
@@ -310,6 +347,7 @@ class Sound:

# Die Audiosamples schreiben
print("Musikdatei wird erstellt...")
fortschritt = 0
for tinnitus_data in range(nframes): #geht jeden Sample-Wert der Musikdatei einzeln durch
# Die Audiodaten müssen von float in einen passenden int-Wert umgerechnet werden
packedMusic.append(struct.pack('h', int(music_links[tinnitus_data] * 32767.0)))
@@ -317,8 +355,8 @@ class Sound:

# wav_obj.writeframes(struct.pack('h', int(music_links[x] * 32767.0))) # Werte für links und rechts werden bei
# wav_obj.writeframes(struct.pack('h', int(musicRechts[x] * 32767.0))) # wav abwechselnd eingetragen
if tinnitus_data % 50000 == 0:
fortschritt = tinnitus_data/nframes*100
if tinnitus_data % int(nframes/10) == 0:
fortschritt += 10
self.filterfortschritt = 4, round(fortschritt, 1)
print(" samples: ", self.filterfortschritt[1], "%")


+ 9
- 5
TinnitusAnalyse/TinnitusAnalyse_GUI.py View File

@@ -209,24 +209,28 @@ def unten_button_filtere_tinnitus_aus_musik():
# Filtern in extra thread, damit sich die GUI nicht aufhängt: (daemon beendet den Thread, wenn das Hauptprogramm beendet wird)
filter_thread = threading.Thread(target=sound.musik_filtern, daemon=True)
filter_thread.start()
time.sleep(3) # Zeit, damit man das Feedback lesen kann, bevor es gelöscht wird (siehe übernächste Zeile)
time.sleep(1) # Zeit, damit man das Feedback lesen kann, bevor es gelöscht wird (siehe übernächste Zeile)

safe_percentage = 0
while filter_thread.is_alive():
feedback.lineCounter = 11 # "Workaround" um Zeilen überschreiben zu können
#feedback.lineCounter = 11 # "Workaround" um Zeilen überschreiben zu können
schritt = sound.filterfortschritt[0]
if schritt == 3 or schritt == 4: #Nur bei dem 3. und 4. Schritt wird der Fortschritt in Prozent angezeigt
if schritt == 3 or schritt == 4: # Nur bei dem 3. und 4. Schritt wird der Fortschritt in Prozent angezeigt
fb = "Schritt " + str(schritt) + " von 4 (" + str(sound.filterfortschritt[1]) + "%)"
feedback(fb)
if sound.filterfortschritt[1] > safe_percentage:
feedback(fb)
safe_percentage = sound.filterfortschritt[1]
elif schritt < 3:
fb = "Schritt " + str(schritt) + " von 4"
feedback(fb)

if sound.filterfortschritt[0] == 5: #ist 5, wenn erfolgreich gefiltert wurde
print("-- filtern beendet --")
feedback("Filtervorgang erfolgreich abgeschlossen. \n"
"Audiodatei unter dem Namen MyTinnitusFreeSong.wav erstellt", "white", "green")
else:
print("Fehler bei Filterfunktion. Siehe Compiler-Meldungen")
feedback("Fehlgeschlagener Filterversuch!", "red", "white")
feedback("Fehlgeschlagener Filterversuch. Ein SWAT-Team gut ausgebildeter Affen ist unterwegs!", "red", "white")
except:
feedback("Fehlgeschlagener Filterversuch. Drücke zuerst den Speichern Knopf"
"Stelle sicher, dass die Lautstärke mindestens einer Seite über 0"

+ 12
- 10
TinnitusAnalyse/TinnitusDaten.csv View File

@@ -1,14 +1,16 @@
Vorname;asd
Nachname;asd
linke Frequenz;5040.0
linke Lautstärke;0.04
linkes Rauschen Lautstärke;0.0
linkes Rauschen untere Grenzfrequenz;10.0
linkes Rauschen obere Grenzfrequenz;20000.0
rechte Frequenz;5040.0
rechte Lautstärke;0.02
Vorname;Mustermann
Nachname;Max
linke Frequenz;8420.0
linke Lautstärke;0.5
linkes Rauschen Lautstärke;0.015
linkes Rauschen untere Grenzfrequenz;7440.0
linkes Rauschen obere Grenzfrequenz;11910.0
rechte Frequenz;0.0
rechte Lautstärke;0.0
rechtes Rauschen Lautstärke;0.0
rechtes Rauschen untere Grenzfrequenz;10.0
rechtes Rauschen obere Grenzfrequenz;20000.0
Kommentar;
Kommentar;Lediglich auf dem linken Ohr höre ich einen hohen Piepston
und ein leises Rauschen (vergleichbar mit einem laufenden
Kühlschrank)


BIN
TinnitusAnalyse/__pycache__/SoundGenerator.cpython-35.pyc View File


Loading…
Cancel
Save