|
@@ -1,3 +1,5 @@
|
|
|
+// ignore_for_file: non_constant_identifier_names
|
|
|
+
|
|
|
import 'package:fis_measure/interfaces/process/items/item_metas.dart';
|
|
|
import 'package:fis_measure/interfaces/process/items/terms.dart';
|
|
|
import 'package:fis_measure/process/primitives/combos/simpson.dart';
|
|
@@ -7,6 +9,7 @@ import 'package:vid/us/vid_us_unit.dart';
|
|
|
|
|
|
import 'formulas/cardiac.dart';
|
|
|
import 'lv_study.dart';
|
|
|
+import 'dart:math' as math;
|
|
|
|
|
|
class LvSimpsonCal extends LvStudyCalculatorBase<LvStudySimpson> {
|
|
|
LvSimpsonCal(super.ref) {
|
|
@@ -27,6 +30,10 @@ class LvSimpsonCal extends LvStudyCalculatorBase<LvStudySimpson> {
|
|
|
"",
|
|
|
);
|
|
|
|
|
|
+ for (var childItem in ref.childItems) {
|
|
|
+ _clacChildItem(childItem as MultiSimpsonPath);
|
|
|
+ }
|
|
|
+
|
|
|
for (var output in ref.meta.outputs) {
|
|
|
switch (output.name) {
|
|
|
case MeasureTerms.LVEDV:
|
|
@@ -55,11 +62,14 @@ class LvSimpsonCal extends LvStudyCalculatorBase<LvStudySimpson> {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // _updateA2cGroup();
|
|
|
+ // _updateA4cGroup();
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
void updateLVEDV() {
|
|
|
- final value = _clacLvedv(ref.a2cLvedv, ref.a4cLvedv);
|
|
|
+ final value = _clacLvedvNew(ref.a2cLvedv, ref.a4cLvedv);
|
|
|
if (value != null) {
|
|
|
updateFloatValueByName(MeasureTerms.LVEDV, value, unit: VidUsUnit.cm3);
|
|
|
v.lvedv = value;
|
|
@@ -68,42 +78,160 @@ class LvSimpsonCal extends LvStudyCalculatorBase<LvStudySimpson> {
|
|
|
|
|
|
@override
|
|
|
void updateLVESV() {
|
|
|
- final value = _clacLvedv(ref.a2cLvesv, ref.a4cLvesv);
|
|
|
+ final value = _clacLvedvNew(ref.a2cLvesv, ref.a4cLvesv);
|
|
|
if (value != null) {
|
|
|
updateFloatValueByName(MeasureTerms.LVESV, value, unit: VidUsUnit.cm3);
|
|
|
v.lvesv = value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- double? _clacLvedv(MultiSimpsonPath a2c, MultiSimpsonPath a4c) {
|
|
|
- final a2cFeature = findChildFeature(a2c);
|
|
|
- final a4cFeature = findChildFeature(a4c);
|
|
|
- if (a2cFeature == null || a4cFeature == null) {
|
|
|
+ double? _clacLvedv(MultiSimpsonPath path1, MultiSimpsonPath path2) {
|
|
|
+ final feature1 = findChildFeature(path1);
|
|
|
+ final feature2 = findChildFeature(path2);
|
|
|
+ if (feature1 == null || feature2 == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- a2cFeature as SimpsonPathFeature;
|
|
|
- a4cFeature as SimpsonPathFeature;
|
|
|
- double a2cL = a2cFeature.centerLineLength;
|
|
|
- double a4cL = a4cFeature.centerLineLength;
|
|
|
+ feature1 as SimpsonPathFeature;
|
|
|
+ feature2 as SimpsonPathFeature;
|
|
|
+ final distance1 = feature1.centerLineLength;
|
|
|
+ final distance2 = feature2.centerLineLength;
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
|
|
|
List<double> aDiameters =
|
|
|
List.generate(SimpsonPath.splitterCount, (index) => 0);
|
|
|
- int index = 0;
|
|
|
- a4cFeature.horizontalSplitterLegths.forEach((key, value) {
|
|
|
+ index = 0;
|
|
|
+ feature1.horizontalSplitterLegths.forEach((key, value) {
|
|
|
aDiameters[index++] = value;
|
|
|
});
|
|
|
|
|
|
List<double> bDiameters =
|
|
|
List.generate(SimpsonPath.splitterCount, (index) => 0);
|
|
|
index = 0;
|
|
|
- a2cFeature.horizontalSplitterLegths.forEach((key, value) {
|
|
|
+ feature2.horizontalSplitterLegths.forEach((key, value) {
|
|
|
bDiameters[index++] = value;
|
|
|
});
|
|
|
- final longDiameter = (a2cL + a4cL) / 2.0;
|
|
|
+
|
|
|
+ final longDiameter = (distance1 + distance2) / 2.0;
|
|
|
final lvesv = CardiacFormulas.lvSimsonVolume(
|
|
|
- longDiameter, aDiameters, bDiameters, SimpsonPath.splitterCount);
|
|
|
+ longDiameter,
|
|
|
+ aDiameters,
|
|
|
+ bDiameters,
|
|
|
+ SimpsonPath.splitterCount,
|
|
|
+ );
|
|
|
return lvesv;
|
|
|
}
|
|
|
+
|
|
|
+ double? _clacLvedvNew(MultiSimpsonPath path1, MultiSimpsonPath path2) {
|
|
|
+ final feature1 = findChildFeature(path1);
|
|
|
+ final feature2 = findChildFeature(path2);
|
|
|
+ if (feature1 == null || feature2 == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ feature1 as SimpsonPathFeature;
|
|
|
+ feature2 as SimpsonPathFeature;
|
|
|
+ final distance1 = feature1.centerLineLength;
|
|
|
+ final distance2 = feature2.centerLineLength;
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
+
|
|
|
+ List<double> aDiameters =
|
|
|
+ List.generate(SimpsonPath.splitterCount, (index) => 0);
|
|
|
+ index = 0;
|
|
|
+ feature1.horizontalSplitterLegths.forEach((key, value) {
|
|
|
+ aDiameters[index++] = value;
|
|
|
+ });
|
|
|
+
|
|
|
+ List<double> bDiameters =
|
|
|
+ List.generate(SimpsonPath.splitterCount, (index) => 0);
|
|
|
+ index = 0;
|
|
|
+ feature2.horizontalSplitterLegths.forEach((key, value) {
|
|
|
+ bDiameters[index++] = value;
|
|
|
+ });
|
|
|
+
|
|
|
+ double sum = 0;
|
|
|
+ for (var i = 0; i < SimpsonPath.splitterCount; i++) {
|
|
|
+ sum += aDiameters[i] * bDiameters[i];
|
|
|
+ }
|
|
|
+ final maxL = math.max(distance1, distance2);
|
|
|
+ final value = maxL * 3.1415926 / (4 * 20) * sum;
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+ void _clacChildItem(MultiSimpsonPath childItem) {
|
|
|
+ final feature = findChildFeature(childItem);
|
|
|
+ if (feature == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ feature as SimpsonPathFeature;
|
|
|
+
|
|
|
+ // final outputs = childItem.meta.outputs;
|
|
|
+ // TODO:
|
|
|
+ final itemName = childItem.meta.description.split(' ').first;
|
|
|
+ final outputs = [
|
|
|
+ ItemOutputMeta("Area", "$itemName LVAs", VidUsUnit.mm2),
|
|
|
+ ItemOutputMeta("L", "$itemName LVLs", VidUsUnit.mm),
|
|
|
+ ];
|
|
|
+ for (var output in outputs) {
|
|
|
+ switch (output.name) {
|
|
|
+ case "Area":
|
|
|
+ feature.updateFloatValue(output, feature.area, VidUsUnit.cm2);
|
|
|
+ break;
|
|
|
+ case "L":
|
|
|
+ feature.updateFloatValue(
|
|
|
+ output, feature.centerLineLength, VidUsUnit.cm);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void _updateA2cGroup() {
|
|
|
+ _updateLVEDV_A2C();
|
|
|
+ _updateLVESV_A2C();
|
|
|
+ }
|
|
|
+
|
|
|
+ void _updateA4cGroup() {
|
|
|
+ _updateLVEDV_A2C();
|
|
|
+ _updateLVESV_A2C();
|
|
|
+ }
|
|
|
+
|
|
|
+ void _updateLVEDV_A2C() {
|
|
|
+ final feature = findChildFeature(ref.a2cLvedv);
|
|
|
+ if (feature == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ feature as SimpsonPathFeature;
|
|
|
+ final value = _SimpsonFormulas.lvedv(
|
|
|
+ feature.area,
|
|
|
+ feature.centerLineLength,
|
|
|
+ );
|
|
|
+ ref.feature!.updateFloatValue(
|
|
|
+ ItemOutputMeta("LVEDV(A2C Simp)", "LVEDV(A2C Simp)", VidUsUnit.ml),
|
|
|
+ value,
|
|
|
+ VidUsUnit.ml,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ void _updateLVESV_A2C() {
|
|
|
+ final feature = findChildFeature(ref.a2cLvesv);
|
|
|
+ if (feature == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ feature as SimpsonPathFeature;
|
|
|
+ final value = _SimpsonFormulas.lvedv(
|
|
|
+ feature.area,
|
|
|
+ feature.centerLineLength,
|
|
|
+ );
|
|
|
+ ref.feature!.updateFloatValue(
|
|
|
+ ItemOutputMeta("LVESV(A2C Simp)", "LVESV(A2C Simp)", VidUsUnit.ml),
|
|
|
+ value,
|
|
|
+ VidUsUnit.ml,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ void _updateLVEDV_A4C() {}
|
|
|
+ void _updateLVESV_A4C() {}
|
|
|
}
|
|
|
|
|
|
class LvSingleSimpsonCal extends LvStudyCalculatorBase<LvStudySingleSimpson> {
|
|
@@ -125,6 +253,8 @@ class LvSingleSimpsonCal extends LvStudyCalculatorBase<LvStudySingleSimpson> {
|
|
|
"",
|
|
|
);
|
|
|
|
|
|
+ _clacChildItem(ref.lvedv);
|
|
|
+
|
|
|
for (var output in ref.meta.outputs) {
|
|
|
switch (output.name) {
|
|
|
case MeasureTerms.LVEDV:
|
|
@@ -167,7 +297,7 @@ class LvSingleSimpsonCal extends LvStudyCalculatorBase<LvStudySingleSimpson> {
|
|
|
|
|
|
@override
|
|
|
void updateLVEDV() {
|
|
|
- final value = _calcLvedv(ref.lvedv);
|
|
|
+ final value = _calcLvedvNew(ref.lvedv);
|
|
|
if (value != null) {
|
|
|
updateFloatValueByName(MeasureTerms.LVEDV, value, unit: VidUsUnit.cm3);
|
|
|
v.lvedv = value;
|
|
@@ -176,7 +306,7 @@ class LvSingleSimpsonCal extends LvStudyCalculatorBase<LvStudySingleSimpson> {
|
|
|
|
|
|
@override
|
|
|
void updateLVESV() {
|
|
|
- final value = _calcLvedv(ref.lvesv);
|
|
|
+ final value = _calcLvedvNew(ref.lvesv);
|
|
|
if (value != null) {
|
|
|
updateFloatValueByName(MeasureTerms.LVESV, value, unit: VidUsUnit.cm3);
|
|
|
v.lvesv = value;
|
|
@@ -205,4 +335,70 @@ class LvSingleSimpsonCal extends LvStudyCalculatorBase<LvStudySingleSimpson> {
|
|
|
SimpsonPath.splitterCount,
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ double? _calcLvedvNew(MultiSimpsonPath item) {
|
|
|
+ final feature = findChildFeature(item);
|
|
|
+ if (feature == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ feature as SimpsonPathFeature;
|
|
|
+
|
|
|
+ double longDiameter = roundDouble(feature.centerLineLength);
|
|
|
+ int index = 0;
|
|
|
+ List<double> bDiameters =
|
|
|
+ List.generate(SimpsonPath.splitterCount, (index) => 0);
|
|
|
+ feature.horizontalSplitterLegths.forEach((key, value) {
|
|
|
+ bDiameters[index++] = value;
|
|
|
+ });
|
|
|
+
|
|
|
+ double sum = 0;
|
|
|
+ for (var i = 0; i < SimpsonPath.splitterCount; i++) {
|
|
|
+ sum += math.pow(bDiameters[i], 2).toDouble();
|
|
|
+ }
|
|
|
+ var value = longDiameter * 3.1415926 / (4 * 20) * sum;
|
|
|
+ return value;
|
|
|
+
|
|
|
+ return CardiacFormulas.lvSimsonVolume(
|
|
|
+ longDiameter,
|
|
|
+ bDiameters,
|
|
|
+ bDiameters,
|
|
|
+ SimpsonPath.splitterCount,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ void _clacChildItem(MultiSimpsonPath childItem) {
|
|
|
+ final feature = findChildFeature(childItem);
|
|
|
+ if (feature == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ feature as SimpsonPathFeature;
|
|
|
+
|
|
|
+ // final outputs = childItem.meta.outputs;
|
|
|
+ // TODO:
|
|
|
+ final itemName = childItem.meta.description.split(' ').first;
|
|
|
+ final outputs = [
|
|
|
+ ItemOutputMeta("Area", "$itemName LVAs", VidUsUnit.mm2),
|
|
|
+ ItemOutputMeta("L", "$itemName LVLs", VidUsUnit.mm),
|
|
|
+ ];
|
|
|
+ for (var output in outputs) {
|
|
|
+ switch (output.name) {
|
|
|
+ case "Area":
|
|
|
+ feature.updateFloatValue(output, feature.area, VidUsUnit.cm2);
|
|
|
+ break;
|
|
|
+ case "L":
|
|
|
+ feature.updateFloatValue(
|
|
|
+ output, feature.centerLineLength, VidUsUnit.cm);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+abstract class _SimpsonFormulas {
|
|
|
+ static double lvedv(double area, double distance) {
|
|
|
+ final value = 0.85 * math.pow(area, 2) / distance;
|
|
|
+ return value;
|
|
|
+ }
|
|
|
}
|