|
@@ -1,14 +1,57 @@
|
|
|
+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/two_location.dart';
|
|
|
+import 'package:vid/us/vid_us_unit.dart';
|
|
|
|
|
|
import 'calculator.dart';
|
|
|
+import 'formulas/general.dart';
|
|
|
|
|
|
class PulsatilityIndexCal extends Calculator<TwoLocation, double> {
|
|
|
PulsatilityIndexCal(super.ref);
|
|
|
|
|
|
+ static const pulsatilityIndexKey = "PI(TCD)";
|
|
|
+
|
|
|
@override
|
|
|
void calculate() {
|
|
|
if (ref.feature == null) return;
|
|
|
|
|
|
final feature = ref.feature!;
|
|
|
+
|
|
|
+ feature.values.clear();
|
|
|
+
|
|
|
+ feature.updateStringValue(
|
|
|
+ ItemOutputMeta(ref.displayName, ref.description, VidUsUnit.None),
|
|
|
+ '',
|
|
|
+ );
|
|
|
+
|
|
|
+ double pi = double.nan;
|
|
|
+ double ps = double.nan;
|
|
|
+ double ed = double.nan;
|
|
|
+ double vMean = double.nan;
|
|
|
+
|
|
|
+ final child1Feature = findChildFeature(ref.child1);
|
|
|
+ final child2Feature = findChildFeature(ref.child2);
|
|
|
+ if (child1Feature != null && child2Feature != null) {
|
|
|
+ ps = pickChildFloatValue(ref.child1) ?? double.nan;
|
|
|
+ ed = pickChildFloatValue(ref.child2) ?? double.nan;
|
|
|
+
|
|
|
+ ps = roundDouble(ps);
|
|
|
+ ed = roundDouble(ed);
|
|
|
+
|
|
|
+ vMean = GeneralFormulas.medianVelocity(ps, ed);
|
|
|
+ pi = GeneralFormulas.pi(ps, ed, vMean);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (var output in ref.meta.outputs) {
|
|
|
+ if (output.name == pulsatilityIndexKey) {
|
|
|
+ if (!pi.isNaN) {
|
|
|
+ feature.updateFloatValue(output, roundDouble(pi), VidUsUnit.None);
|
|
|
+ }
|
|
|
+ } else if (output.name == MeasureTerms.VelocityMean) {
|
|
|
+ if (!vMean.isNaN) {
|
|
|
+ feature.updateFloatValue(output, roundDouble(vMean), VidUsUnit.cms);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|