Skip to content

Commit

Permalink
Graph change enabled for Heart Sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kumar-laxmi committed Feb 22, 2024
1 parent c00f8f4 commit 29e581a
Show file tree
Hide file tree
Showing 22 changed files with 120 additions and 66 deletions.
2 changes: 1 addition & 1 deletion app/DashApp/Heart/aortic_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Heart/erb_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Heart/mitral_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Heart/pulmonary_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Heart/tricuspid_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Lung/LLL_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Lung/LML_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Lung/LUL_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Lung/RLL_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Lung/RML_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/Lung/RUL_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
Binary file modified app/DashApp/__pycache__/ecg_dash.cpython-311.pyc
Binary file not shown.
Binary file modified app/DashApp/__pycache__/rsp_dash.cpython-311.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion app/DashApp/blank_hbr_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def loadAudioData(audioPath):
# Layout of the app
app.layout = html.Div([
dcc.Input(id='audio-path-input',type='text',placeholder='Enter audio path...',style={'display':'none'}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
dcc.Interval(id='interval-component', interval=25, n_intervals=0) # Interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/ecg_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def set_hr_value(x):

# Layout of the app
app.layout = html.Div([
dcc.Graph(id='animated-ecg-chart', style={'height': '95vh'}),
dcc.Graph(id='animated-ecg-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='ecg-data-store', data=ecg_data),
dcc.Store(id='interval-store', data=time.time()), # Store the start time
dcc.Interval(
Expand Down
2 changes: 1 addition & 1 deletion app/DashApp/rsp_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Layout of the app
app.layout = html.Div([
dcc.Graph(id='animated-rsp-chart', style={'height': '95vh'}),
dcc.Graph(id='animated-rsp-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='ecg-data-store', data=rsp_data),
dcc.Store(id='interval-store', data=time.time()), # Store the start time
dcc.Interval(
Expand Down
Binary file modified app/__pycache__/views.cpython-311.pyc
Binary file not shown.
121 changes: 97 additions & 24 deletions app/templates/elements/Scripts/footerButtons.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,121 @@
var tricuspid_btn = document.getElementById("normal_heart_sound_tricuspid_valve");
var erb_btn = document.getElementById("normal_heart_sound_erb_point");

// Blank Div
// Default Divs
var currentDiv = document.getElementById("hbr_div");
var ecgDiv = document.getElementById("ecg_div");
var rspDiv = document.getElementById("rsp_div");

// Heart Divs
var mitralDiv = document.getElementById("mitral_div");
var aorticDiv = document.getElementById("aortic_div");
var pulmonaryDiv = document.getElementById("pulmonary_div");
var tricuspidDiv = document.getElementById("tricuspid_div");
var erbDiv = document.getElementById("erb_div");
var mitralDiv = document.getElementById("mitral_valve_div");
var aorticDiv = document.getElementById("aortic_valve_div");
var pulmonaryDiv = document.getElementById("pulmonary_valve_div");
var tricuspidDiv = document.getElementById("tricuspid_valve_div");
var erbDiv = document.getElementById("erb_point_div");

// Lungs Divs
/*
var LULDiv = document.getElementById("");
var LMLDiv = document.getElementById("");
var LLLDiv = document.getElementById("");
var RULDiv = document.getElementById("");
var RMLDiv = document.getElementById("");
var RLLDiv = document.getElementById("");
*/

// Add a click event listener to the button
hbr_btn.addEventListener("click", function() {
this.classList.toggle("active"); // Toggle the 'active' class on the button
if (currentDiv.style.display === "none") {
currentDiv.style.display = "block";
}
else {
currentDiv.style.display = "none";
}
});

// Click event for Mitral Valve
mitral_btn.addEventListener("click", function() {
if (mitralDiv.style.display === "none") {
mitralDiv.style.display = "block";
currentDiv.style.display = "none";
currentDiv = mitralDiv;
if (currentDiv.style.display === "none" && hbr_btn.classList.contains("active")) {
currentDiv.style.display = "block";
}
else {
mitralDiv.style.display = "none";
currentDiv.style.display = "none";
}
})
});

// Add a click event listener to the button
hbr_btn.addEventListener("click", function() {
// Toggle the 'active' class on the button
this.classList.toggle("active");

// Toggle the display property of currentDiv
if (currentDiv.style.display === "none") {
// Click event for Aortic Valve
aortic_btn.addEventListener("click", function() {
currentDiv.style.display = "none";
currentDiv = aorticDiv;
if (currentDiv.style.display === "none" && hbr_btn.classList.contains("active")) {
currentDiv.style.display = "block";
} else {
}
else {
currentDiv.style.display = "none";
}
});

// Click event for Pulmonary Valve
pulmonary_btn.addEventListener("click", function() {
currentDiv.style.display = "none";
currentDiv = pulmonaryDiv;
if (currentDiv.style.display === "none" && hbr_btn.classList.contains("active")) {
currentDiv.style.display = "block";
}
else {
currentDiv.style.display = "none";
}
});

// Click event for Tricuspid Valve
tricuspid_btn.addEventListener("click", function() {
currentDiv.style.display = "none";
currentDiv = tricuspidDiv;
if (currentDiv.style.display === "none" && hbr_btn.classList.contains("active")) {
currentDiv.style.display = "block";
}
else {
currentDiv.style.display = "none";
}
});

// Click event for Erb's Point
erb_btn.addEventListener("click", function() {
currentDiv.style.display = "none";
currentDiv = erbDiv;
if (currentDiv.style.display === "none" && hbr_btn.classList.contains("active")) {
currentDiv.style.display = "block";
}
else {
currentDiv.style.display = "none";
}
});

compare_btn.addEventListener("click", function() {
// Toggle the 'active' class on the button
this.classList.toggle("active");
this.classList.toggle("active"); // Toggle the 'active' class on the button
});

ecg_btn.addEventListener("click", function() {
// Toggle the 'active' class on the button
this.classList.toggle("active");
this.classList.toggle("active"); // Toggle the 'active' class on the button
if (ecgDiv.style.display === "none") {
ecgDiv.style.display = "block";
}
else {
ecgDiv.style.display = "none";
}
});

rsp_btn.addEventListener("click", function() {
// Toggle the 'active' class on the button
this.classList.toggle("active");
this.classList.toggle("active"); // Toggle the 'active' class on the button
if (rspDiv.style.display === "none") {
rspDiv.style.display = "block";
}
else {
rspDiv.style.display = "none";
}
});

</script>
22 changes: 0 additions & 22 deletions app/templates/elements/Scripts/soundPlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,8 @@
'ulcerative_colitis_div', 'peritoneal_friction_rub_div'
];

var currentVisibleDiv = 'hbr_div';

function setDisplayStyle() {
// Loop through each div in the graphDivs array
graphDivs.forEach(divId => {
var divElement = document.getElementById(divId); // Get the div element by its ID

if (divElement) { // Check if the div element exists before attempting to remove the class
divElement.style.display = "none"; // Remove the "active" class from the div element
}
});
// Set the style of div elements based on hbr_btn active state
if ($('#hbr_btn').hasClass('active')) {
var currentSound = document.getElementById(currentVisibleDiv);
currentSound.style.display = "block";

}
}

function handleSoundClick(identifier, valveType) {
$('#' + identifier + '_sound_' + valveType).click(function () {
currentVisibleDiv = identifier + '_sound_' + valveType;
setDisplayStyle();

$.ajax({
type: 'POST',
url: 'soundPlay/',
Expand Down
13 changes: 8 additions & 5 deletions app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
hr_show, rr_show = 60, 15 # Initialize the Heart Rate and Breadth Rate
current_mitral_valve_sound, current_aortic_valve_sound, current_pulmonary_valve_sound, current_tricuspid_valve_sound, current_erb_valve_sound, current_lungs_sound, current_bowel_sound = None, None, None, None, None, None, None

buzzer = Buzzer(17)
try:
buzzer = Buzzer(17)
except:
buzzer = None

speakers = sc.all_speakers()

Expand Down Expand Up @@ -102,13 +105,13 @@ def heartUpdate(request):
if 'hr_plus' in request.POST:
hr_show += 1
buzzer.on()
time.sleep(0.5)
time.sleep(0.1)
buzzer.off()
print('\nHeart Rate updated to: {}'.format(hr_show))
elif 'hr_minus' in request.POST:
hr_show -= 1
buzzer.on()
time.sleep(0.5)
time.sleep(0.1)
buzzer.off()
print('\nHeart Rate updated to: {}'.format(hr_show))
else:
Expand Down Expand Up @@ -136,13 +139,13 @@ def breathUpdate(request):
if 'rr_plus' in request.POST:
rr_show += 1
buzzer.on()
time.sleep(0.5)
time.sleep(0.1)
buzzer.off()
print('\nBreath Rate updated to: {}'.format(rr_show))
elif 'rr_minus' in request.POST:
rr_show -= 1
buzzer.on()
time.sleep(0.5)
time.sleep(0.1)
buzzer.off()
print('\nBreath Rate updated to: {}'.format(rr_show))
else:
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
2 changes: 1 addition & 1 deletion sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def loadAudioData(audioPath):
placeholder='Enter audio path...',
style={'width': '50%'}
),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True}),
dcc.Graph(id='animated-audio-chart', style={'height': '95vh'}, config={'responsive': True, 'staticPlot': True}),
dcc.Store(id='audio-path-store', data={'value': None}),
dcc.Store(id='audio-data-store', data={'audio_data': [], 'audio_duration': 0}),
dcc.Store(id='interval-store', data=time.time()), # Store the start time and set default heart rate to 60
Expand Down

0 comments on commit 29e581a

Please sign in to comment.