Browse Source

Implement stream vid data reader.

Justin 2 years ago
parent
commit
847b0cdb98

+ 6 - 6
lib/us/vid_us_2d_visual.dart

@@ -26,15 +26,15 @@ class VidUs2DVisual extends VidUsVisual {
   VidUs2DVisual() {
     setVisualType(VidUsVisualType.V2D);
     _logicalCoordinates =
-        new Map<VidUsVisualAreaType, VidUsLogicalCoordinate>();
+        Map<VidUsVisualAreaType, VidUsLogicalCoordinate>();
     _physicalCoordinates =
-        new Map<VidUsVisualAreaType, VidUsPhysicalCoordinate>();
+        Map<VidUsVisualAreaType, VidUsPhysicalCoordinate>();
   }
 
   ///Convert VidUs2DVisual to binary data.
   @override
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     var baseData = super.toBytes();
     writer.writeBytes(baseData);
     writer.writeByte(_physicalCoordinates.length);
@@ -52,7 +52,7 @@ class VidUs2DVisual extends VidUsVisual {
 
   ///Convert binary data to VidUs2DVisual.
   static VidUsVisual fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var visualType = VidUsVisualType.values[reader.readByte()];
     var displayMode = VidUsDisplayMode.values[reader.readByte()];
     if (visualType == VidUsVisualType.V2D) {
@@ -64,7 +64,7 @@ class VidUs2DVisual extends VidUsVisual {
         var mode = VidUsMode.fromBytes(reader.readBytes());
         modes.add(mode);
       }
-      var visual = new VidUs2DVisual();
+      var visual = VidUs2DVisual();
       visual.setIndicator(indicator);
       modes.forEach((mode) {
         visual.modes.add(mode);
@@ -87,7 +87,7 @@ class VidUs2DVisual extends VidUsVisual {
       visual.setDisplayMode(displayMode);
       return visual;
     }
-    throw new Exception(
+    throw Exception(
         "Can not restore visual data from $visualType to VidUs2DVisual.");
   }
 }

+ 4 - 4
lib/us/vid_us_3d_visual.dart

@@ -23,7 +23,7 @@ class VidUs3DVisual extends VidUsVisual {
   @override
   Uint8List toBytes() {
     var baseData = super.toBytes();
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     writer.writeBytes(baseData);
     writer.writeByte(_tissue3DAreas.length);
     _tissue3DAreas.forEach((area) {
@@ -34,12 +34,12 @@ class VidUs3DVisual extends VidUsVisual {
 
   ///Convert binary data to VidUs3DVisual.
   static VidUsVisual fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var visualType = VidUsVisualType.values[reader.readByte()];
     var displayMode = VidUsDisplayMode.values[reader.readByte()];
     if (visualType == VidUsVisualType.V3D) {
       var indicator = VidUsVisualIndicator.values[reader.readByte()];
-      var visual = new VidUs3DVisual();
+      var visual = VidUs3DVisual();
       visual.setIndicator(indicator);
       var activeModeType = VidUsModeType.values[reader.readByte()];
       var modeCount = reader.readByte();
@@ -56,7 +56,7 @@ class VidUs3DVisual extends VidUsVisual {
       visual.setDisplayMode(displayMode);
       return visual;
     }
-    throw new Exception(
+    throw Exception(
         "Can not restore visual data from $visualType to VidUs3DVisual.");
   }
 }

+ 3 - 3
lib/us/vid_us_application.dart

@@ -43,7 +43,7 @@ class VidUsApplication {
 
   ///Convert VidUsApplication to binary data.
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     writer.writeString(_applicationId);
     writer.writeString(_applicationOriginalId);
     writer.writeString(_applicationName);
@@ -54,13 +54,13 @@ class VidUsApplication {
 
   ///Convert binary data to VidUsApplication.
   static VidUsApplication fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var applicationId = reader.readString();
     var applicationOriginalId = reader.readString();
     var applicationName = reader.readString();
     var applicationCategoryName = reader.readString();
     var isUserDefined = reader.readBool();
-    return new VidUsApplication(applicationId, applicationOriginalId,
+    return VidUsApplication(applicationId, applicationOriginalId,
         applicationName, applicationCategoryName, isUserDefined);
   }
 }

+ 0 - 1
lib/us/vid_us_data_reader.dart

@@ -1,4 +1,3 @@
-import 'dart:convert';
 import 'dart:typed_data';
 
 class VidUsDataReader {

+ 1 - 1
lib/us/vid_us_data_writer.dart

@@ -4,7 +4,7 @@ import 'dart:typed_data';
 
 ///Not used for now.
 class VidUsDataWriter {
-  final BytesBuilder _builder = new BytesBuilder();
+  final BytesBuilder _builder = BytesBuilder();
 
   Uint8List get data => _builder.toBytes();
 

+ 3 - 3
lib/us/vid_us_image.dart

@@ -51,7 +51,7 @@ class VidUsImage implements IImageDataContainer {
 
   /// VidUsImage image to binary data.
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     writer.writeInt(_index);
     writer.writeByte(_visuals.length);
     _visuals.forEach((visual) {
@@ -66,7 +66,7 @@ class VidUsImage implements IImageDataContainer {
 
   /// Convert binary data to VidUsImage
   static VidUsImage fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var index = reader.readInt();
     var visualCount = reader.readByte();
     List<VidUsVisual> visuals = [];
@@ -77,7 +77,7 @@ class VidUsImage implements IImageDataContainer {
     var width = reader.readInt16();
     var height = reader.readInt16();
     var imageData = reader.readBytes();
-    var result = new VidUsImage(index, width, height, imageData);
+    var result = VidUsImage(index, width, height, imageData);
     visuals.forEach((visual) {
       result._visuals.add(visual);
     });

+ 213 - 4
lib/us/vid_us_image_data.dart

@@ -1,5 +1,6 @@
 import 'dart:typed_data';
 import 'package:vid/us/vid_us_data_reader.dart';
+import 'package:vid/us/vid_us_data_stream_reader.dart';
 import 'package:vid/us/vid_us_image.dart';
 import 'package:vid/us/vid_us_probe.dart';
 
@@ -41,10 +42,10 @@ class VidUsImageData {
 
   /// Create a VINNO Image Data.
   VidUsImageData(Uint8List data) {
-    _reader = new VidUsDataReader(data);
+    _reader = VidUsDataReader(data);
     var header = _reader.readString();
     if (header != header) {
-      throw new Exception("The input data is not a VID data.");
+      throw Exception("The input data is not a VID data.");
     }
     _version = _reader.readInt();
     //Get probe info
@@ -56,7 +57,7 @@ class VidUsImageData {
     _imagePositionList = [];
     var imagePositionListData = _reader.readBytes();
     _imageCount = imagePositionListData.length ~/ 8;
-    var imagePositionReader = new VidUsDataReader(imagePositionListData);
+    var imagePositionReader = VidUsDataReader(imagePositionListData);
     for (var i = 0; i < _imageCount; i++) {
       _imagePositionList.add(imagePositionReader.readInt64V2());
     }
@@ -65,10 +66,218 @@ class VidUsImageData {
   /// Get one image from the vid.
   VidUsImage getImage(int index) {
     if (index >= _imageCount || index < 0) {
-      throw new Exception("Can not find image Data");
+      throw Exception("Can not find image Data");
     }
     //Jump to image.
     var imageData = _reader.readBytes(_imagePositionList[index]);
     return VidUsImage.fromBytes(imageData);
   }
 }
+
+class ReadTimeoutException implements Exception {}
+
+///Only suport read for now.
+///Not suport carotid3d for now.
+class StreamedVidUsImageData {
+  late VidUsDataStreamReader _reader;
+  late List<int> _imagePositionList;
+  late int _version;
+  late int _imageCount;
+  late VidUsProbe _probe;
+  late VidUsImageFormat _imageFormat;
+  late Uint8List _extendedData;
+  late int _readTimeout;
+
+  final Duration DelayDuration = const Duration(milliseconds: 10);
+
+  final String header = "VINNO IMAGE DATA";
+
+  /// Gets the version of this image data.
+  int get version => _version;
+
+  /// Gets the image count of this image data.
+  int get imageCount => _imageCount;
+
+  /// Gets the probe information.
+  VidUsProbe get probe => _probe;
+
+  /// Gets the image format of this image data.
+  VidUsImageFormat get imageFormat => _imageFormat;
+
+  /// Gets or sets the extended data.
+  Uint8List get extendedData => _extendedData;
+
+  /// Create a VINNO Image Data.
+  StreamedVidUsImageData(Stream<Uint8List> stream, [int readTimeout = 1000]) {
+    _readTimeout = readTimeout;
+    _reader = VidUsDataStreamReader(stream);
+  }
+
+  //Initialize the StreamedVidUsImageData
+  Future initialize() async {
+    var header = await _readHeader();
+    if (header != header) {
+      throw Exception("The input data is not a VID data.");
+    }
+    _version = await _readVersion();
+    //Get probe info
+    _probe = await _readProbe();
+    _imageFormat = await _readImageFormat();
+    _extendedData = await _readExtendedData();
+    _imagePositionList = [];
+    var imagePositionListData = await _readImagePositionListData();
+    _imageCount = imagePositionListData.length ~/ 8;
+    var imagePositionReader = VidUsDataReader(imagePositionListData);
+    for (var i = 0; i < _imageCount; i++) {
+      _imagePositionList.add(imagePositionReader.readInt64V2());
+    }
+  }
+
+  //Read header from stream.
+  Future<String> _readHeader() async {
+    var timeout = 0;
+    while (true) {
+      try {
+        var header = _reader.readString();
+        return header;
+      } catch (ex) {
+        if (ex is NotReadyException) {
+          if (timeout >= _readTimeout) {
+            throw ReadTimeoutException();
+          }
+          await Future.delayed(DelayDuration);
+          timeout += DelayDuration.inMilliseconds;
+        } else {
+          rethrow;
+        }
+      }
+    }
+  }
+
+  //Read the version from the stream.
+  Future<int> _readVersion() async {
+    var timeout = 0;
+    while (true) {
+      try {
+        var version = _reader.readInt();
+        return version;
+      } catch (ex) {
+        if (ex is NotReadyException) {
+          if (timeout >= _readTimeout) {
+            throw ReadTimeoutException();
+          }
+          await Future.delayed(DelayDuration);
+          timeout += DelayDuration.inMilliseconds;
+        } else {
+          rethrow;
+        }
+      }
+    }
+  }
+
+  //Read the probe info from the stream.
+  Future<VidUsProbe> _readProbe() async {
+    var timeout = 0;
+    while (true) {
+      try {
+        var probeData = _reader.readBytes();
+        return VidUsProbe.fromBytes(probeData);
+      } catch (ex) {
+        if (ex is NotReadyException) {
+          if (timeout >= _readTimeout) {
+            throw ReadTimeoutException();
+          }
+          await Future.delayed(DelayDuration);
+          timeout += DelayDuration.inMilliseconds;
+        } else {
+          rethrow;
+        }
+      }
+    }
+  }
+
+  //Read the image format from the stream.
+  Future<VidUsImageFormat> _readImageFormat() async {
+    var timeout = 0;
+    while (true) {
+      try {
+        return VidUsImageFormat.values[_reader.readInt()];
+      } catch (ex) {
+        if (ex is NotReadyException) {
+          if (timeout >= _readTimeout) {
+            throw ReadTimeoutException();
+          }
+          await Future.delayed(DelayDuration);
+          timeout += DelayDuration.inMilliseconds;
+        } else {
+          rethrow;
+        }
+      }
+    }
+  }
+
+  //Read extended data from the stream.
+  Future<Uint8List> _readExtendedData() async {
+    var timeout = 0;
+    while (true) {
+      try {
+        return _reader.readBytes();
+      } catch (ex) {
+        if (ex is NotReadyException) {
+          if (timeout >= _readTimeout) {
+            throw ReadTimeoutException();
+          }
+          await Future.delayed(DelayDuration);
+          timeout += DelayDuration.inMilliseconds;
+        } else {
+          rethrow;
+        }
+      }
+    }
+  }
+
+  //Read the image positions data from the stream. 
+  Future<Uint8List> _readImagePositionListData() async {
+    var timeout = 0;
+    while (true) {
+      try {
+        return _reader.readBytes();
+      } catch (ex) {
+        if (ex is NotReadyException) {
+          if (timeout >= _readTimeout) {
+            throw ReadTimeoutException();
+          }
+          await Future.delayed(DelayDuration);
+          timeout += DelayDuration.inMilliseconds;
+        } else {
+          rethrow;
+        }
+      }
+    }
+  }
+
+  /// Get one image from the vid.
+  Future<VidUsImage> getImage(int index) async {
+    if (index >= _imageCount || index < 0) {
+      throw Exception("Can not find image Data");
+    }
+    //Jump to image.
+    var timeout = 0;
+    while (true) {
+      try {
+        var imageData = _reader.readBytes(_imagePositionList[index]);
+        return VidUsImage.fromBytes(imageData);
+      } catch (ex) {
+        if (ex is NotReadyException) {
+          if (timeout >= _readTimeout) {
+            throw ReadTimeoutException();
+          }
+          await Future.delayed(DelayDuration);
+          timeout += DelayDuration.inMilliseconds;
+        } else {
+          rethrow;
+        }
+      }
+    }
+  }
+}

+ 4 - 4
lib/us/vid_us_logical_coordinate.dart

@@ -26,7 +26,7 @@ class VidUsLogicalCoordinate {
       this._region, this._xUnit, this._yUnit);
 
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     writer.writeBool(_isFlipHorizontal);
     writer.writeBool(_isFlipVertical);
     writer.writeByte(VidUsUnitMap.getUnitValue(_xUnit));
@@ -39,7 +39,7 @@ class VidUsLogicalCoordinate {
   }
 
   static VidUsLogicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var isFlipHorizontal = reader.readBool();
     var isFlipVertical = reader.readBool();
     var xUnit = VidUsUnitMap.getUnit(reader.readByte());
@@ -48,8 +48,8 @@ class VidUsLogicalCoordinate {
     var top = reader.readDouble();
     var right = reader.readDouble();
     var bottom = reader.readDouble();
-    var region = new VidUsRect.tlbr(
-        new VidUsPoint(left, top), new VidUsPoint(right, bottom));
+    var region = VidUsRect.tlbr(
+        VidUsPoint(left, top), VidUsPoint(right, bottom));
     return VidUsLogicalCoordinate(
         isFlipHorizontal, isFlipVertical, region, xUnit, yUnit);
   }

+ 3 - 3
lib/us/vid_us_mode.dart

@@ -31,7 +31,7 @@ class VidUsMode {
   VidUsMode(this._name, this._displayName, this._type);
 
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     writer.writeString(this.name);
     writer.writeString(this.displayName);
     writer.writeByte(this._type.index);
@@ -39,10 +39,10 @@ class VidUsMode {
   }
 
   static VidUsMode fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var name = reader.readString();
     var displayName = reader.readString();
     var type = VidUsModeType.values[reader.readByte()];
-    return new VidUsMode(name, displayName, type);
+    return VidUsMode(name, displayName, type);
   }
 }

+ 34 - 34
lib/us/vid_us_physical_coordinate.dart

@@ -19,13 +19,13 @@ class VidUsPhysicalCoordinate {
   late PhysicalCoordinateType _type;
 
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     writer.writeByte(_type.index);
     return writer.data;
   }
 
   static VidUsPhysicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var type = PhysicalCoordinateType.values[reader.readByte()];
     switch (type) {
       case PhysicalCoordinateType.ConvexTissue:
@@ -45,7 +45,7 @@ class VidUsPhysicalCoordinate {
       case PhysicalCoordinateType.PWV:
         return VidUsPWVPhysicalCoordinate.fromBytes(bytes);
       default:
-        throw new Exception("Not supported CoordinateType $type");
+        throw Exception("Not supported CoordinateType $type");
     }
   }
 }
@@ -78,7 +78,7 @@ class VidUsTissuePhysicalCoordinate extends VidUsPhysicalCoordinate {
 
   @override
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     var baseData = super.toBytes();
     writer.writeBytes(baseData);
     writer.writeDouble(_depthStart);
@@ -111,7 +111,7 @@ class VidUsTimeMotionPhysicalCoordinate extends VidUsPhysicalCoordinate {
 
   @override
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     var baseData = super.toBytes();
     writer.writeBytes(baseData);
     writer.writeDouble(_min);
@@ -135,7 +135,7 @@ class VidUsConvexTissuePhysicalCoordinate
 
   @override
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     var baseData = super.toBytes();
     writer.writeBytes(baseData);
     writer.writeDouble(_zeroRadius);
@@ -143,10 +143,10 @@ class VidUsConvexTissuePhysicalCoordinate
   }
 
   static VidUsPhysicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var type = PhysicalCoordinateType.values[reader.readByte()];
     if (type != PhysicalCoordinateType.ConvexTissue) {
-      throw new Exception(
+      throw Exception(
           "Type not matched, target type:{$PhysicalCoordinateType.ConvexTissue)}, source type:{$type}");
     }
     var depthStart = reader.readDouble();
@@ -154,7 +154,7 @@ class VidUsConvexTissuePhysicalCoordinate
     var width = reader.readDouble();
     var beamPosition = reader.readDouble();
     var zeroRadius = reader.readDouble();
-    return new VidUsConvexTissuePhysicalCoordinate(
+    return VidUsConvexTissuePhysicalCoordinate(
         depthEnd, depthStart, width, beamPosition, zeroRadius);
   }
 }
@@ -174,7 +174,7 @@ class VidUsLinearTissuePhysicalCoordinate
 
   @override
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     var baseData = super.toBytes();
     writer.writeBytes(baseData);
     writer.writeDouble(_steer);
@@ -182,10 +182,10 @@ class VidUsLinearTissuePhysicalCoordinate
   }
 
   static VidUsPhysicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var type = PhysicalCoordinateType.values[reader.readByte()];
     if (type != PhysicalCoordinateType.LinearTissue) {
-      throw new Exception(
+      throw Exception(
           "Type not matched, target type:{$PhysicalCoordinateType.LinearTissue}, source type:{$type}");
     }
     var depthStart = reader.readDouble();
@@ -193,7 +193,7 @@ class VidUsLinearTissuePhysicalCoordinate
     var width = reader.readDouble();
     var beamPosition = reader.readDouble();
     var steer = reader.readDouble();
-    return new VidUsLinearTissuePhysicalCoordinate(
+    return VidUsLinearTissuePhysicalCoordinate(
         depthEnd, depthStart, width, beamPosition, steer);
   }
 }
@@ -222,7 +222,7 @@ class VidUsConvexTVTissuePhysicalCoordinate
   }
 
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     var baseData = super.toBytes();
     writer.writeBytes(baseData);
     writer.writeDouble(_originalZeroRadius);
@@ -231,10 +231,10 @@ class VidUsConvexTVTissuePhysicalCoordinate
   }
 
   static VidUsPhysicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var type = PhysicalCoordinateType.values[reader.readByte()];
     if (type != PhysicalCoordinateType.ConvexTVTissue) {
-      throw new Exception(
+      throw Exception(
           "Type not matched, target type:{$PhysicalCoordinateType.ConvexTVTissue}, source type:{$type}");
     }
     var depthStart = reader.readDouble();
@@ -244,7 +244,7 @@ class VidUsConvexTVTissuePhysicalCoordinate
     var zeroRadius = reader.readDouble();
     var originalZeroRadius = reader.readDouble();
     var originalRocx = reader.readDouble();
-    return new VidUsConvexTVTissuePhysicalCoordinate(depthEnd, depthStart,
+    return VidUsConvexTVTissuePhysicalCoordinate(depthEnd, depthStart,
         width, beamPosition, zeroRadius, originalZeroRadius, originalRocx);
   }
 }
@@ -258,10 +258,10 @@ class VidUsLinearTVTissuePhysicalCoordinate
   }
 
   static VidUsPhysicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var type = PhysicalCoordinateType.values[reader.readByte()];
     if (type != PhysicalCoordinateType.LinearTVTissue) {
-      throw new Exception(
+      throw Exception(
           "Type not matched, target type:{$PhysicalCoordinateType.LinearTVTissue}, source type:{$type}");
     }
     var depthStart = reader.readDouble();
@@ -269,7 +269,7 @@ class VidUsLinearTVTissuePhysicalCoordinate
     var width = reader.readDouble();
     var beamPosition = reader.readDouble();
     var zeroRadius = reader.readDouble();
-    return new VidUsLinearTVTissuePhysicalCoordinate(
+    return VidUsLinearTVTissuePhysicalCoordinate(
         depthEnd, depthStart, width, beamPosition, zeroRadius);
   }
 }
@@ -288,7 +288,7 @@ class VidUsDopplerPhysicalCoordinate extends VidUsTimeMotionPhysicalCoordinate {
 
   @override
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     var baseData = super.toBytes();
     writer.writeBytes(baseData);
     writer.writeDouble(_baseLine);
@@ -296,17 +296,17 @@ class VidUsDopplerPhysicalCoordinate extends VidUsTimeMotionPhysicalCoordinate {
   }
 
   static VidUsPhysicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var type = PhysicalCoordinateType.values[reader.readByte()];
     if (type != PhysicalCoordinateType.Doppler) {
-      throw new Exception(
+      throw Exception(
           "Type not matched, target type:{$PhysicalCoordinateType.Doppler}, source type:{$type}");
     }
     var min = reader.readDouble();
     var max = reader.readDouble();
     var sweepSpeed = reader.readDouble();
     var baseLine = reader.readDouble();
-    return new VidUsDopplerPhysicalCoordinate(sweepSpeed, max, min, baseLine);
+    return VidUsDopplerPhysicalCoordinate(sweepSpeed, max, min, baseLine);
   }
 }
 
@@ -329,7 +329,7 @@ class VidUsTissueTimeMotionPhysicalCoordinate
   }
 
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     var baseData = super.toBytes();
     writer.writeBytes(baseData);
     writer.writeDouble(_depthStart);
@@ -338,10 +338,10 @@ class VidUsTissueTimeMotionPhysicalCoordinate
   }
 
   static VidUsPhysicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var type = PhysicalCoordinateType.values[reader.readByte()];
     if (type != PhysicalCoordinateType.TissueTimeMotion) {
-      throw new Exception(
+      throw Exception(
           "Type not matched, target type:{$PhysicalCoordinateType.TissueTimeMotion}, source type:{$type}");
     }
     var min = reader.readDouble();
@@ -349,7 +349,7 @@ class VidUsTissueTimeMotionPhysicalCoordinate
     var sweepSpeed = reader.readDouble();
     var depthStart = reader.readDouble();
     var depthEnd = reader.readDouble();
-    return new VidUsTissueTimeMotionPhysicalCoordinate(
+    return VidUsTissueTimeMotionPhysicalCoordinate(
         sweepSpeed, max, min, depthStart, depthEnd);
   }
 }
@@ -363,10 +363,10 @@ class VidUsMAMPhysicalCoordinate
   }
 
   static VidUsPhysicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var type = PhysicalCoordinateType.values[reader.readByte()];
     if (type != PhysicalCoordinateType.MAM) {
-      throw new Exception(
+      throw Exception(
           "Type not matched, target type:{$PhysicalCoordinateType.MAM}, source type:{$type}");
     }
 
@@ -375,7 +375,7 @@ class VidUsMAMPhysicalCoordinate
     var sweepSpeed = reader.readDouble();
     var depthStart = reader.readDouble();
     var depthEnd = reader.readDouble();
-    return new VidUsMAMPhysicalCoordinate(
+    return VidUsMAMPhysicalCoordinate(
         sweepSpeed, max, min, depthStart, depthEnd);
   }
 }
@@ -389,10 +389,10 @@ class VidUsPWVPhysicalCoordinate
   }
 
   static VidUsPhysicalCoordinate fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var type = PhysicalCoordinateType.values[reader.readByte()];
     if (type != PhysicalCoordinateType.PWV) {
-      throw new Exception(
+      throw Exception(
           "Type not matched, target type:{$PhysicalCoordinateType.PWV}, source type:{$type}");
     }
 
@@ -401,7 +401,7 @@ class VidUsPWVPhysicalCoordinate
     var sweepSpeed = reader.readDouble();
     var depthStart = reader.readDouble();
     var depthEnd = reader.readDouble();
-    return new VidUsPWVPhysicalCoordinate(
+    return VidUsPWVPhysicalCoordinate(
         sweepSpeed, max, min, depthStart, depthEnd);
   }
 }

+ 3 - 3
lib/us/vid_us_probe.dart

@@ -37,7 +37,7 @@ class VidUsProbe {
   }
 
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     writer.writeString(_name);
     writer.writeByte(_type.index);
     writer.writeBytes(_application.toBytes());
@@ -46,11 +46,11 @@ class VidUsProbe {
   }
 
   static VidUsProbe fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
     var name = reader.readString();
     var type = VidUsProbeType.values[reader.readByte()];
     var application = VidUsApplication.fromBytes(reader.readBytes());
     var frameRate = reader.readDouble();
-    return new VidUsProbe(name, type, application, frameRate);
+    return VidUsProbe(name, type, application, frameRate);
   }
 }

+ 4 - 4
lib/us/vid_us_rect.dart

@@ -21,13 +21,13 @@ class VidUsRect {
 
   double get height => (_bottom - _top).abs();
 
-  VidUsPoint get topLeft => new VidUsPoint(_left, _top);
+  VidUsPoint get topLeft => VidUsPoint(_left, _top);
 
-  VidUsPoint get topRight => new VidUsPoint(_right, _top);
+  VidUsPoint get topRight => VidUsPoint(_right, _top);
 
-  VidUsPoint get bottomLeft => new VidUsPoint(_left, _bottom);
+  VidUsPoint get bottomLeft => VidUsPoint(_left, _bottom);
 
-  VidUsPoint get bottomRight => new VidUsPoint(_right, _bottom);
+  VidUsPoint get bottomRight => VidUsPoint(_right, _bottom);
 
   VidUsRect.xywh(double x, double y, double width, double height) {
     _left = topLeft.x;

+ 6 - 6
lib/us/vid_us_tissue_3d_area.dart

@@ -32,7 +32,7 @@ class VidUsTissue3DArea {
   }
 
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     writer.writeByte(_indicator.index);
     writer.writeDouble(_cmPerPixel);
     writer.writeDouble(_globalOffset.x);
@@ -45,18 +45,18 @@ class VidUsTissue3DArea {
   }
 
   static VidUsTissue3DArea fromBytes(Uint8List tissue3DAreaData) {
-    var reader = new VidUsDataReader(tissue3DAreaData);
+    var reader = VidUsDataReader(tissue3DAreaData);
     var indicator = VidUs3DAreaIndicator.values[reader.readByte()];
     var cmPerPixel = reader.readDouble();
     var x = reader.readDouble();
     var y = reader.readDouble();
-    var globalOffset = new VidUsPoint(x, y);
+    var globalOffset = VidUsPoint(x, y);
     var left = reader.readDouble();
     var top = reader.readDouble();
     var right = reader.readDouble();
     var bottom = reader.readDouble();
-    var bounds = new VidUsRect.tlbr(
-        new VidUsPoint(left, top), new VidUsPoint(right, bottom));
-    return new VidUsTissue3DArea(bounds, cmPerPixel, globalOffset, indicator);
+    var bounds = VidUsRect.tlbr(
+        VidUsPoint(left, top), VidUsPoint(right, bottom));
+    return VidUsTissue3DArea(bounds, cmPerPixel, globalOffset, indicator);
   }
 }

+ 3 - 3
lib/us/vid_us_visual.dart

@@ -56,7 +56,7 @@ class VidUsVisual {
   }
 
   Uint8List toBytes() {
-    var writer = new VidUsDataWriter();
+    var writer = VidUsDataWriter();
     writer.writeByte(_visualType.index);
     writer.writeByte(_displayMode.index);
     writer.writeByte(_indicator.index);
@@ -69,7 +69,7 @@ class VidUsVisual {
   }
 
   static VidUsVisual fromBytes(Uint8List bytes) {
-    var reader = new VidUsDataReader(bytes);
+    var reader = VidUsDataReader(bytes);
 
     var visualType = VidUsVisualType.values[reader.readByte()];
     if (visualType == VidUsVisualType.V2D) {
@@ -78,6 +78,6 @@ class VidUsVisual {
     if (visualType == VidUsVisualType.V3D) {
       return VidUs3DVisual.fromBytes(bytes);
     }
-    throw new Exception("Not supported visual $visualType");
+    throw Exception("Not supported visual $visualType");
   }
 }