Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
Vent Display
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Marcos Mendez Quintero
Vent Display
Commits
ed7b8f5e
Commit
ed7b8f5e
authored
4 years ago
by
Avinash Baskaran
Browse files
Options
Downloads
Patches
Plain Diff
pv work changes
parent
732d0ec2
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
breath_plot.html
+55
-19
55 additions, 19 deletions
breath_plot.html
with
55 additions
and
19 deletions
breath_plot.html
+
55
−
19
View file @
ed7b8f5e
...
...
@@ -1406,29 +1406,61 @@ function compute_current_TRIP(TRIP_min,TRIP_max, samples)
// net Pressure-Volume Work:
// integral under P*V curve
function
PressureVolumeWork
(
samples
,
a
,
z
)
{
// A routine to calculate work per breath
function
PressureVolumeWork
(
breath
,
transitions
,
samples
)
{
// -1 for quadilateral approximation
var
flows
=
samples
.
filter
(
s
=>
s
.
event
==
'
M
'
&&
s
.
type
==
'
F
'
);
var
pressures
=
samples
.
filter
(
s
=>
s
.
event
==
'
M
'
&&
s
.
type
==
'
D
'
&&
s
.
loc
==
'
A
'
);
if
(
breath
.
vol_i
==
0
)
{
return
(
"
null
"
);
}
else
{
var
beginTransition
=
transitions
[
breath
.
trans_begin_inhale
];
var
beginTime_ms
=
beginTransition
.
ms
;
var
endTransition
=
transitions
[
breath
.
trans_cross_zero
];
var
endTime_ms
=
endTransition
.
ms
;
var
flows
=
samples
.
filter
(
s
=>
s
.
event
==
'
M
'
&&
s
.
type
==
'
F
'
&&
s
.
ms
>=
beginTime_ms
&&
s
.
ms
<=
endTime_ms
);
var
pressures
=
samples
.
filter
(
s
=>
s
.
event
==
'
M
'
&&
s
.
type
==
'
D
'
&&
s
.
loc
==
'
A
'
&&
s
.
ms
>=
beginTime_ms
&&
s
.
ms
<=
endTime_ms
);
console
.
log
(
"
begin transition time, end transition time:
"
,
beginTime_ms
,
endTime_ms
);
//var pressureVolume_prod= 0;
//for(var j = a; j
<
z
-
1
;
j
++
)
{
// // I'll use qadrilateral approximation.
// // We'll form each quadrilateral between two samples.
// var ms = flows[j+1].ms - flows[j].ms;
// var ht = (((flows[j+1].val*pressures[j+1].val) + (flows[j].val*pressures[j+1].val ))/2) * CONVERT_PIRDS_TO_SLM;
// // Flow in standard liters per minute,
// // divide by 60000 to get liters/s
// pressureVolume_prod += ms * ht/60000;
// if (isNaN(pressureVolume_prod)) {
// debugger;
// }
// }
// pressure cm H2O --> atm (divide by 1033)
// return pressureVolume_prod/1033
var
pressureVolume_prod
=
0
;
for
(
var
j
=
a
;
j
<
z
-
1
;
j
++
)
{
// I'll use qadrilateral approximation.
// We'll form each quadrilateral between two samples.
var
ms
=
flows
[
j
+
1
].
ms
-
flows
[
j
].
ms
;
var
ht
=
(((
flows
[
j
+
1
].
val
*
pressures
[
j
+
1
].
val
)
+
(
flows
[
j
].
val
*
pressures
[
j
+
1
].
val
))
/
2
)
*
CONVERT_PIRDS_TO_SLM
;
// Flow in standard liters per minute,
// divide by 60000 to get liters/s
pressureVolume_prod
+=
ms
*
ht
/
60000
;
if
(
isNaN
(
pressureVolume_prod
))
{
debugger
;
}
// average pressure * average flow ~ approximation of work
var
pAv_cm
=
0
;
for
(
var
i
=
0
;
i
<
pressures
.
length
;
i
++
)
{
pAv_cm
+=
pressures
[
i
].
val
/
10
;
}
pAv_cm
/=
pressures
.
length
;
var
pressures_pascales
=
pAv_cm
*
98.0665
;
//cm to pasc.
var
fAv_lpm
=
0
;
for
(
var
i
=
0
;
i
<
flows
.
length
;
i
++
)
{
fAv_lpm
+=
flows
[
i
].
val
/
1000
;
}
fAv_lpm
/=
flows
.
length
;
console
.
log
(
"
flows:
"
,
flows
,
"
\n
pressures:
"
,
pressures
)
console
.
log
(
"
pAv, vAv =
"
,
pAv_cm
,
fAv_lpm
);
var
flow_cubicMetersPerSecond
=
fAv_lpm
/
1000
/
60
;
//lpm to cmps
var
avPower
=
pressures_pascales
*
flow_cubicMetersPerSecond
;
// Watts
var
avWork
=
avPower
*
(
endTime_ms
-
beginTime_ms
)
/
1000
;
// Joules
console
.
log
(
"
Power (Watts):
"
,
avPower
);
console
.
log
(
"
Work (Joules):
"
,
avWork
);
return
avWork
;
}
// pressure cm H2O --> atm (divide by 1033)
return
pressureVolume_prod
/
1033
}
function
testWork
(
samples
){
// breaths give us inspiration transition points
var
flows
=
samples
.
filter
(
s
=>
s
.
event
==
'
M
'
&&
s
.
type
==
'
F
'
);
...
...
@@ -1441,6 +1473,10 @@ function compute_current_TRIP(TRIP_min,TRIP_max, samples)
var
transitions
=
compute_transitions
(
vm
,
flows
);
var
breaths
=
compute_breaths_based_without_negative_flow
(
transitions
,
flows
);
console
.
log
(
breaths
);
for
(
i
=
0
;
i
<
breaths
.
length
;
i
++
)
{
var
w
=
PressureVolumeWork
(
breaths
[
i
],
transitions
,
samples
);
console
.
log
(
w
);
}
}
...
...
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