Public
Edited
Sep 3, 2023
1 fork
Insert cell
Insert cell
Insert cell
viewof htn_delta = Inputs.range([0, 40], {
label: "Amount",
step: 1,
value: 20
})
Insert cell
Insert cell
Insert cell
data_dot = {
if (htn == "Yes") {
return [{ MAP: x_value + htn_delta, CBF: data_htn.at(x_value).y }];
} else {
return [{ MAP: x_value, CBF: data_htn.at(x_value).y }];
}
}
Insert cell
Select a data source…
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
x: { domain: [0, 200], label: "Cerebral Perfusion Pressure" },
y: { domain: [0, 100], label: "Cerebral Blood Flow" },
//height: 500,
//width: 800,
marks: [
Plot.line(data_2, {
x: "x",
y: "y",
stroke: "#C0C0C0",
strokeDasharray: "1,5",
strokeWidth: 4
}),
Plot.line(
data_htn,
{
x: "x",
y: "y",
//stroke: "#8AAFFF",
strokeWidth: 4
},
{
strokeWidth: 7,
stroke: "#8AAFFF"
}
),
Plot.dot(data_dot, {
x: "MAP",
y: "CBF",
r: 12,
fill: "#FF6666",
stroke: "#797979",
strokeWidth: 1,
symbol: "circle"
})
]
})
Insert cell
Insert cell
xValues = Array.from({ length: 201 }, (_, i) => i)
Insert cell
dataPoints = 100; // Number of data points
Insert cell
minMAP = 60; // Minimum mean arterial pressure (mmHg)
Insert cell
maxMAP = 150; // Maximum mean arterial pressure (mmHg)
Insert cell
sigmoidSlope = 0.1 // Slope of the sigmoid curve
Insert cell
sigmoidMidpoint = 80
Insert cell
//yValues = [];
Insert cell
xvalues = Array.from(
{ length: 200 },
(_, i) => minMAP + (i / (dataPoints - 1)) * (maxMAP - minMAP)
)
Insert cell
yvalues = xValues.map(
(currentMAP) =>
100 / (1 + Math.exp(-sigmoidSlope * (currentMAP - sigmoidMidpoint)))
)
Insert cell
sigmoidCurve = (xValue) => {
const sigmoidSlope = 0.05; // Slope of the sigmoid curve
const sigmoidMidpoint = 100; // Midpoint of the sigmoid curve
return 100 / (1 + Math.exp(-sigmoidSlope * (xValue - sigmoidMidpoint)));
}
Insert cell
sigmoidCurve_2 = (yValue) => {
const sigmoidSlope = 0.1; // Slope of the sigmoid curve
const sigmoidMidpoint = 80; // Midpoint of the sigmoid curve
return sigmoidMidpoint - Math.log(100 / yValue - 1) / sigmoidSlope;
}
Insert cell
yValues = Array.from({ length: 201 }, (_, i) => sigmoidCurve_2(i))
Insert cell
yValues = xValues.map(
(currentMAP) =>
100 / (1 + Math.exp(-sigmoidSlope * (currentMAP - sigmoidMidpoint)))
)
Insert cell
data = (xValues, yValues)
Insert cell
Insert cell
import {Pack} from "@d3/pack"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more