mrd-python 2.1.1__tar.gz → 2.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mrd_python-2.1.1 → mrd_python-2.2.1}/PKG-INFO +5 -3
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/__init__.py +10 -0
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/_binary.py +6 -6
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/_dtypes.py +10 -5
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/_ndjson.py +1 -1
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/binary.py +170 -26
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/ndjson.py +679 -60
- mrd_python-2.2.1/mrd/protocols.py +320 -0
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/tools/export_png_images.py +6 -3
- mrd_python-2.2.1/mrd/tools/fastmri_to_mrd.py +221 -0
- mrd_python-2.2.1/mrd/tools/ismrmrd_to_mrd.py +708 -0
- mrd_python-2.2.1/mrd/tools/mrd_to_ismrmrd.py +696 -0
- mrd_python-2.2.1/mrd/tools/mrd_to_seq.py +295 -0
- mrd_python-2.2.1/mrd/tools/phantom.py +277 -0
- mrd_python-2.2.1/mrd/tools/seq_to_mrd.py +485 -0
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/tools/simulation.py +4 -3
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/tools/stream_recon.py +2 -2
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/types.py +668 -117
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/yardl_types.py +5 -4
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd_python.egg-info/PKG-INFO +5 -3
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd_python.egg-info/SOURCES.txt +5 -0
- mrd_python-2.2.1/mrd_python.egg-info/requires.txt +4 -0
- {mrd_python-2.1.1 → mrd_python-2.2.1}/pyproject.toml +7 -2
- mrd_python-2.2.1/setup.py +7 -0
- mrd_python-2.1.1/mrd/protocols.py +0 -318
- mrd_python-2.1.1/mrd/tools/phantom.py +0 -161
- mrd_python-2.1.1/mrd_python.egg-info/requires.txt +0 -2
- mrd_python-2.1.1/setup.py +0 -7
- {mrd_python-2.1.1 → mrd_python-2.2.1}/README.md +0 -0
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/tools/minimal_example.py +0 -0
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd/tools/transform.py +0 -0
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd_python.egg-info/dependency_links.txt +0 -0
- {mrd_python-2.1.1 → mrd_python-2.2.1}/mrd_python.egg-info/top_level.txt +0 -0
- {mrd_python-2.1.1 → mrd_python-2.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: mrd-python
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Library and tools for working with data in the ISMRM Raw Data (MRD) format.
|
|
5
5
|
Project-URL: Homepage, https://ismrmrd.github.io/mrd
|
|
6
6
|
Project-URL: Documentation, https://ismrmrd.github.io/mrd
|
|
@@ -11,8 +11,10 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Intended Audience :: Science/Research
|
|
13
13
|
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
14
|
-
Requires-Python: >=3.
|
|
14
|
+
Requires-Python: >=3.12
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: h5py>=3.15.1
|
|
17
|
+
Requires-Dist: ismrmrd>=1.14.2
|
|
16
18
|
Requires-Dist: numpy>=1.22.0
|
|
17
19
|
Requires-Dist: pillow>=9.2.0
|
|
18
20
|
|
|
@@ -26,6 +26,8 @@ from .types import (
|
|
|
26
26
|
AcquisitionData,
|
|
27
27
|
AcquisitionFlags,
|
|
28
28
|
AcquisitionHeader,
|
|
29
|
+
AcquisitionPhase,
|
|
30
|
+
AcquisitionPrototype,
|
|
29
31
|
AcquisitionSystemInformationType,
|
|
30
32
|
AnyImage,
|
|
31
33
|
Array,
|
|
@@ -70,6 +72,14 @@ from .types import (
|
|
|
70
72
|
ParallelImagingType,
|
|
71
73
|
PatientGender,
|
|
72
74
|
PatientPosition,
|
|
75
|
+
PulseqADCEvent,
|
|
76
|
+
PulseqArbitraryGradient,
|
|
77
|
+
PulseqBlock,
|
|
78
|
+
PulseqDefinitions,
|
|
79
|
+
PulseqRFEvent,
|
|
80
|
+
PulseqShape,
|
|
81
|
+
PulseqTrapezoidalGradient,
|
|
82
|
+
RFPulseUse,
|
|
73
83
|
ReconAssembly,
|
|
74
84
|
ReconBuffer,
|
|
75
85
|
ReconData,
|
|
@@ -632,7 +632,7 @@ class Complex32Serializer(StructSerializer[ComplexFloat, np.complex64]):
|
|
|
632
632
|
stream.write(self._struct, value.real, value.imag)
|
|
633
633
|
|
|
634
634
|
def read(self, stream: CodedInputStream) -> ComplexFloat:
|
|
635
|
-
return
|
|
635
|
+
return complex(*stream.read(self._struct))
|
|
636
636
|
|
|
637
637
|
def read_numpy(self, stream: CodedInputStream) -> np.complex64:
|
|
638
638
|
real, imag = stream.read(self._struct)
|
|
@@ -656,7 +656,7 @@ class Complex64Serializer(StructSerializer[ComplexDouble, np.complex128]):
|
|
|
656
656
|
stream.write(self._struct, value.real, value.imag)
|
|
657
657
|
|
|
658
658
|
def read(self, stream: CodedInputStream) -> ComplexDouble:
|
|
659
|
-
return
|
|
659
|
+
return complex(*stream.read(self._struct))
|
|
660
660
|
|
|
661
661
|
def read_numpy(self, stream: CodedInputStream) -> np.complex128:
|
|
662
662
|
real, imag = stream.read(self._struct)
|
|
@@ -687,7 +687,7 @@ class StringSerializer(TypeSerializer[str, np.object_]):
|
|
|
687
687
|
return str(view, "utf-8")
|
|
688
688
|
|
|
689
689
|
def read_numpy(self, stream: CodedInputStream) -> np.object_:
|
|
690
|
-
return np.object_(self.read(stream))
|
|
690
|
+
return np.object_(self.read(stream)) # pyright: ignore [reportReturnType]
|
|
691
691
|
|
|
692
692
|
|
|
693
693
|
string_serializer = StringSerializer()
|
|
@@ -770,7 +770,7 @@ class TimeSerializer(TypeSerializer[Time, np.timedelta64]):
|
|
|
770
770
|
time_serializer = TimeSerializer()
|
|
771
771
|
|
|
772
772
|
DATETIME_NANOSECONDS_DTYPE = np.dtype("datetime64[ns]")
|
|
773
|
-
EPOCH_DATETIME = datetime.datetime.
|
|
773
|
+
EPOCH_DATETIME = datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc)
|
|
774
774
|
|
|
775
775
|
|
|
776
776
|
class DateTimeSerializer(TypeSerializer[DateTime, np.datetime64]):
|
|
@@ -1034,7 +1034,7 @@ class VectorSerializer(Generic[T, T_NP], TypeSerializer[list[T], np.object_]):
|
|
|
1034
1034
|
return [self._element_serializer.read(stream) for _ in range(length)]
|
|
1035
1035
|
|
|
1036
1036
|
def read_numpy(self, stream: CodedInputStream) -> np.object_:
|
|
1037
|
-
return np.object_(self.read(stream))
|
|
1037
|
+
return np.object_(self.read(stream)) # pyright: ignore [reportReturnType]
|
|
1038
1038
|
|
|
1039
1039
|
|
|
1040
1040
|
TKey = TypeVar("TKey")
|
|
@@ -1073,7 +1073,7 @@ class MapSerializer(
|
|
|
1073
1073
|
}
|
|
1074
1074
|
|
|
1075
1075
|
def read_numpy(self, stream: CodedInputStream) -> np.object_:
|
|
1076
|
-
return np.object_(self.read(stream))
|
|
1076
|
+
return np.object_(self.read(stream)) # pyright: ignore [reportReturnType]
|
|
1077
1077
|
|
|
1078
1078
|
|
|
1079
1079
|
class NDArraySerializerBase(
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import datetime
|
|
5
5
|
from types import GenericAlias
|
|
6
|
+
from typing import Annotated, Any
|
|
6
7
|
import sys
|
|
7
8
|
|
|
8
9
|
if sys.version_info >= (3, 10):
|
|
@@ -15,10 +16,13 @@ from . import yardl_types as yardl
|
|
|
15
16
|
|
|
16
17
|
def make_get_dtype_func(
|
|
17
18
|
dtype_map: dict[
|
|
18
|
-
Union[type, GenericAlias],
|
|
19
|
+
Union[type, GenericAlias, Annotated[Any, Any]],
|
|
19
20
|
Union[np.dtype[Any], Callable[[tuple[type, ...]], np.dtype[Any]]],
|
|
20
|
-
]
|
|
21
|
-
) -> Callable[
|
|
21
|
+
],
|
|
22
|
+
) -> Callable[
|
|
23
|
+
[Union[type, GenericAlias, Annotated[Any, Any]]],
|
|
24
|
+
np.dtype[Any],
|
|
25
|
+
]:
|
|
22
26
|
dtype_map[bool] = np.dtype(np.bool_)
|
|
23
27
|
dtype_map[yardl.Int8] = np.dtype(np.int8)
|
|
24
28
|
dtype_map[yardl.UInt8] = np.dtype(np.uint8)
|
|
@@ -50,7 +54,7 @@ def make_get_dtype_func(
|
|
|
50
54
|
|
|
51
55
|
def get_dtype_impl(
|
|
52
56
|
dtype_map: dict[
|
|
53
|
-
Union[type, GenericAlias],
|
|
57
|
+
Union[type, GenericAlias, Annotated[Any, Any]],
|
|
54
58
|
Union[np.dtype[Any], Callable[[tuple[type, ...]], np.dtype[Any]]],
|
|
55
59
|
],
|
|
56
60
|
t: Union[type, GenericAlias],
|
|
@@ -65,7 +69,8 @@ def make_get_dtype_func(
|
|
|
65
69
|
origin = get_origin(t)
|
|
66
70
|
|
|
67
71
|
if origin == Union or (
|
|
68
|
-
sys.version_info >= (3, 10)
|
|
72
|
+
sys.version_info >= (3, 10)
|
|
73
|
+
and isinstance(t, UnionType) # pyright: ignore[reportUnnecessaryIsInstance]
|
|
69
74
|
):
|
|
70
75
|
return _get_union_dtype(get_args(t))
|
|
71
76
|
|
|
@@ -568,7 +568,7 @@ class StringConverter(JsonConverter[str, np.object_]):
|
|
|
568
568
|
return cast(str, json_object)
|
|
569
569
|
|
|
570
570
|
def from_json_to_numpy(self, json_object: object) -> np.object_:
|
|
571
|
-
return np.object_(json_object)
|
|
571
|
+
return np.object_(json_object) # pyright: ignore [reportReturnType]
|
|
572
572
|
|
|
573
573
|
|
|
574
574
|
string_converter = StringConverter()
|
|
@@ -34,7 +34,7 @@ class BinaryMrdWriter(_binary.BinaryProtocolWriter, MrdWriterBase):
|
|
|
34
34
|
_binary.OptionalSerializer(HeaderSerializer()).write(self._stream, value)
|
|
35
35
|
|
|
36
36
|
def _write_data(self, value: collections.abc.Iterable[StreamItem]) -> None:
|
|
37
|
-
_binary.StreamSerializer(_binary.UnionSerializer(StreamItem, [(StreamItem.Acquisition, AcquisitionSerializer()), (StreamItem.WaveformUint32, WaveformSerializer(_binary.uint32_serializer)), (StreamItem.ImageUint16, ImageSerializer(_binary.uint16_serializer)), (StreamItem.ImageInt16, ImageSerializer(_binary.int16_serializer)), (StreamItem.ImageUint32, ImageSerializer(_binary.uint32_serializer)), (StreamItem.ImageInt32, ImageSerializer(_binary.int32_serializer)), (StreamItem.ImageFloat, ImageSerializer(_binary.float32_serializer)), (StreamItem.ImageDouble, ImageSerializer(_binary.float64_serializer)), (StreamItem.ImageComplexFloat, ImageSerializer(_binary.complexfloat32_serializer)), (StreamItem.ImageComplexDouble, ImageSerializer(_binary.complexfloat64_serializer)), (StreamItem.AcquisitionBucket, AcquisitionBucketSerializer()), (StreamItem.ReconData, ReconDataSerializer()), (StreamItem.ArrayComplexFloat, _binary.DynamicNDArraySerializer(_binary.complexfloat32_serializer)), (StreamItem.ImageArray, ImageArraySerializer())])).write(self._stream, value)
|
|
37
|
+
_binary.StreamSerializer(_binary.UnionSerializer(StreamItem, [(StreamItem.Acquisition, AcquisitionSerializer()), (StreamItem.AcquisitionPrototype, AcquisitionPrototypeSerializer()), (StreamItem.WaveformUint32, WaveformSerializer(_binary.uint32_serializer)), (StreamItem.ImageUint16, ImageSerializer(_binary.uint16_serializer)), (StreamItem.ImageInt16, ImageSerializer(_binary.int16_serializer)), (StreamItem.ImageUint32, ImageSerializer(_binary.uint32_serializer)), (StreamItem.ImageInt32, ImageSerializer(_binary.int32_serializer)), (StreamItem.ImageFloat, ImageSerializer(_binary.float32_serializer)), (StreamItem.ImageDouble, ImageSerializer(_binary.float64_serializer)), (StreamItem.ImageComplexFloat, ImageSerializer(_binary.complexfloat32_serializer)), (StreamItem.ImageComplexDouble, ImageSerializer(_binary.complexfloat64_serializer)), (StreamItem.AcquisitionBucket, AcquisitionBucketSerializer()), (StreamItem.ReconData, ReconDataSerializer()), (StreamItem.ArrayComplexFloat, _binary.DynamicNDArraySerializer(_binary.complexfloat32_serializer)), (StreamItem.ImageArray, ImageArraySerializer()), (StreamItem.PulseqDefinitions, PulseqDefinitionsSerializer()), (StreamItem.PulseqBlocks, _binary.VectorSerializer(PulseqBlockSerializer())), (StreamItem.PulseqRfEvent, PulseqRFEventSerializer()), (StreamItem.PulseqArbitraryGradient, PulseqArbitraryGradientSerializer()), (StreamItem.PulseqTrapezoidalGradient, PulseqTrapezoidalGradientSerializer()), (StreamItem.PulseqAdcEvent, PulseqADCEventSerializer()), (StreamItem.PulseqShape, PulseqShapeSerializer())])).write(self._stream, value)
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
class BinaryMrdReader(_binary.BinaryProtocolReader, MrdReaderBase):
|
|
@@ -44,15 +44,15 @@ class BinaryMrdReader(_binary.BinaryProtocolReader, MrdReaderBase):
|
|
|
44
44
|
"""
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None:
|
|
48
|
-
MrdReaderBase.__init__(self)
|
|
47
|
+
def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str], skip_completed_check: bool = False) -> None:
|
|
48
|
+
MrdReaderBase.__init__(self, skip_completed_check)
|
|
49
49
|
_binary.BinaryProtocolReader.__init__(self, stream, MrdReaderBase.schema)
|
|
50
50
|
|
|
51
51
|
def _read_header(self) -> typing.Optional[Header]:
|
|
52
52
|
return _binary.OptionalSerializer(HeaderSerializer()).read(self._stream)
|
|
53
53
|
|
|
54
54
|
def _read_data(self) -> collections.abc.Iterable[StreamItem]:
|
|
55
|
-
return _binary.StreamSerializer(_binary.UnionSerializer(StreamItem, [(StreamItem.Acquisition, AcquisitionSerializer()), (StreamItem.WaveformUint32, WaveformSerializer(_binary.uint32_serializer)), (StreamItem.ImageUint16, ImageSerializer(_binary.uint16_serializer)), (StreamItem.ImageInt16, ImageSerializer(_binary.int16_serializer)), (StreamItem.ImageUint32, ImageSerializer(_binary.uint32_serializer)), (StreamItem.ImageInt32, ImageSerializer(_binary.int32_serializer)), (StreamItem.ImageFloat, ImageSerializer(_binary.float32_serializer)), (StreamItem.ImageDouble, ImageSerializer(_binary.float64_serializer)), (StreamItem.ImageComplexFloat, ImageSerializer(_binary.complexfloat32_serializer)), (StreamItem.ImageComplexDouble, ImageSerializer(_binary.complexfloat64_serializer)), (StreamItem.AcquisitionBucket, AcquisitionBucketSerializer()), (StreamItem.ReconData, ReconDataSerializer()), (StreamItem.ArrayComplexFloat, _binary.DynamicNDArraySerializer(_binary.complexfloat32_serializer)), (StreamItem.ImageArray, ImageArraySerializer())])).read(self._stream)
|
|
55
|
+
return _binary.StreamSerializer(_binary.UnionSerializer(StreamItem, [(StreamItem.Acquisition, AcquisitionSerializer()), (StreamItem.AcquisitionPrototype, AcquisitionPrototypeSerializer()), (StreamItem.WaveformUint32, WaveformSerializer(_binary.uint32_serializer)), (StreamItem.ImageUint16, ImageSerializer(_binary.uint16_serializer)), (StreamItem.ImageInt16, ImageSerializer(_binary.int16_serializer)), (StreamItem.ImageUint32, ImageSerializer(_binary.uint32_serializer)), (StreamItem.ImageInt32, ImageSerializer(_binary.int32_serializer)), (StreamItem.ImageFloat, ImageSerializer(_binary.float32_serializer)), (StreamItem.ImageDouble, ImageSerializer(_binary.float64_serializer)), (StreamItem.ImageComplexFloat, ImageSerializer(_binary.complexfloat32_serializer)), (StreamItem.ImageComplexDouble, ImageSerializer(_binary.complexfloat64_serializer)), (StreamItem.AcquisitionBucket, AcquisitionBucketSerializer()), (StreamItem.ReconData, ReconDataSerializer()), (StreamItem.ArrayComplexFloat, _binary.DynamicNDArraySerializer(_binary.complexfloat32_serializer)), (StreamItem.ImageArray, ImageArraySerializer()), (StreamItem.PulseqDefinitions, PulseqDefinitionsSerializer()), (StreamItem.PulseqBlocks, _binary.VectorSerializer(PulseqBlockSerializer())), (StreamItem.PulseqRfEvent, PulseqRFEventSerializer()), (StreamItem.PulseqArbitraryGradient, PulseqArbitraryGradientSerializer()), (StreamItem.PulseqTrapezoidalGradient, PulseqTrapezoidalGradientSerializer()), (StreamItem.PulseqAdcEvent, PulseqADCEventSerializer()), (StreamItem.PulseqShape, PulseqShapeSerializer())])).read(self._stream)
|
|
56
56
|
|
|
57
57
|
class BinaryMrdNoiseCovarianceWriter(_binary.BinaryProtocolWriter, MrdNoiseCovarianceWriterBase):
|
|
58
58
|
"""Binary writer for the MrdNoiseCovariance protocol.
|
|
@@ -76,8 +76,8 @@ class BinaryMrdNoiseCovarianceReader(_binary.BinaryProtocolReader, MrdNoiseCovar
|
|
|
76
76
|
"""
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None:
|
|
80
|
-
MrdNoiseCovarianceReaderBase.__init__(self)
|
|
79
|
+
def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str], skip_completed_check: bool = False) -> None:
|
|
80
|
+
MrdNoiseCovarianceReaderBase.__init__(self, skip_completed_check)
|
|
81
81
|
_binary.BinaryProtocolReader.__init__(self, stream, MrdNoiseCovarianceReaderBase.schema)
|
|
82
82
|
|
|
83
83
|
def _read_noise_covariance(self) -> NoiseCovariance:
|
|
@@ -103,38 +103,56 @@ class EncodingCountersSerializer(_binary.RecordSerializer[EncodingCounters]):
|
|
|
103
103
|
|
|
104
104
|
class AcquisitionHeaderSerializer(_binary.RecordSerializer[AcquisitionHeader]):
|
|
105
105
|
def __init__(self) -> None:
|
|
106
|
-
super().__init__([("flags", _binary.EnumSerializer(_binary.uint64_serializer, AcquisitionFlags)), ("idx", EncodingCountersSerializer()), ("measurement_uid", _binary.uint32_serializer), ("scan_counter", _binary.OptionalSerializer(_binary.uint32_serializer)), ("
|
|
106
|
+
super().__init__([("flags", _binary.EnumSerializer(_binary.uint64_serializer, AcquisitionFlags)), ("idx", EncodingCountersSerializer()), ("measurement_uid", _binary.uint32_serializer), ("scan_counter", _binary.OptionalSerializer(_binary.uint32_serializer)), ("acquisition_center_frequency", _binary.OptionalSerializer(_binary.uint64_serializer)), ("acquisition_time_stamp_ns", _binary.OptionalSerializer(_binary.uint64_serializer)), ("physiology_time_stamp_ns", _binary.VectorSerializer(_binary.uint64_serializer)), ("channel_order", _binary.VectorSerializer(_binary.uint32_serializer)), ("discard_pre", _binary.OptionalSerializer(_binary.uint32_serializer)), ("discard_post", _binary.OptionalSerializer(_binary.uint32_serializer)), ("center_sample", _binary.OptionalSerializer(_binary.uint32_serializer)), ("encoding_space_ref", _binary.OptionalSerializer(_binary.uint32_serializer)), ("sample_time_ns", _binary.OptionalSerializer(_binary.uint64_serializer)), ("position", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("read_dir", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("phase_dir", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("slice_dir", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("patient_table_position", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("user_int", _binary.VectorSerializer(_binary.int32_serializer)), ("user_float", _binary.VectorSerializer(_binary.float32_serializer))])
|
|
107
107
|
|
|
108
108
|
def write(self, stream: _binary.CodedOutputStream, value: AcquisitionHeader) -> None:
|
|
109
109
|
if isinstance(value, np.void):
|
|
110
110
|
self.write_numpy(stream, value)
|
|
111
111
|
return
|
|
112
|
-
self._write(stream, value.flags, value.idx, value.measurement_uid, value.scan_counter, value.
|
|
112
|
+
self._write(stream, value.flags, value.idx, value.measurement_uid, value.scan_counter, value.acquisition_center_frequency, value.acquisition_time_stamp_ns, value.physiology_time_stamp_ns, value.channel_order, value.discard_pre, value.discard_post, value.center_sample, value.encoding_space_ref, value.sample_time_ns, value.position, value.read_dir, value.phase_dir, value.slice_dir, value.patient_table_position, value.user_int, value.user_float)
|
|
113
113
|
|
|
114
114
|
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
115
|
-
self._write(stream, value['flags'], value['idx'], value['measurement_uid'], value['scan_counter'], value['
|
|
115
|
+
self._write(stream, value['flags'], value['idx'], value['measurement_uid'], value['scan_counter'], value['acquisition_center_frequency'], value['acquisition_time_stamp_ns'], value['physiology_time_stamp_ns'], value['channel_order'], value['discard_pre'], value['discard_post'], value['center_sample'], value['encoding_space_ref'], value['sample_time_ns'], value['position'], value['read_dir'], value['phase_dir'], value['slice_dir'], value['patient_table_position'], value['user_int'], value['user_float'])
|
|
116
116
|
|
|
117
117
|
def read(self, stream: _binary.CodedInputStream) -> AcquisitionHeader:
|
|
118
118
|
field_values = self._read(stream)
|
|
119
|
-
return AcquisitionHeader(flags=field_values[0], idx=field_values[1], measurement_uid=field_values[2], scan_counter=field_values[3],
|
|
119
|
+
return AcquisitionHeader(flags=field_values[0], idx=field_values[1], measurement_uid=field_values[2], scan_counter=field_values[3], acquisition_center_frequency=field_values[4], acquisition_time_stamp_ns=field_values[5], physiology_time_stamp_ns=field_values[6], channel_order=field_values[7], discard_pre=field_values[8], discard_post=field_values[9], center_sample=field_values[10], encoding_space_ref=field_values[11], sample_time_ns=field_values[12], position=field_values[13], read_dir=field_values[14], phase_dir=field_values[15], slice_dir=field_values[16], patient_table_position=field_values[17], user_int=field_values[18], user_float=field_values[19])
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
class AcquisitionSerializer(_binary.RecordSerializer[Acquisition]):
|
|
123
123
|
def __init__(self) -> None:
|
|
124
|
-
super().__init__([("head", AcquisitionHeaderSerializer()), ("data", _binary.NDArraySerializer(_binary.complexfloat32_serializer, 2)), ("trajectory", _binary.NDArraySerializer(_binary.float32_serializer, 2))])
|
|
124
|
+
super().__init__([("head", AcquisitionHeaderSerializer()), ("data", _binary.NDArraySerializer(_binary.complexfloat32_serializer, 2)), ("phase", _binary.OptionalSerializer(_binary.NDArraySerializer(_binary.float32_serializer, 1))), ("trajectory", _binary.NDArraySerializer(_binary.float32_serializer, 2))])
|
|
125
125
|
|
|
126
126
|
def write(self, stream: _binary.CodedOutputStream, value: Acquisition) -> None:
|
|
127
127
|
if isinstance(value, np.void):
|
|
128
128
|
self.write_numpy(stream, value)
|
|
129
129
|
return
|
|
130
|
-
self._write(stream, value.head, value.data, value.trajectory)
|
|
130
|
+
self._write(stream, value.head, value.data, value.phase, value.trajectory)
|
|
131
131
|
|
|
132
132
|
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
133
|
-
self._write(stream, value['head'], value['data'], value['trajectory'])
|
|
133
|
+
self._write(stream, value['head'], value['data'], value['phase'], value['trajectory'])
|
|
134
134
|
|
|
135
135
|
def read(self, stream: _binary.CodedInputStream) -> Acquisition:
|
|
136
136
|
field_values = self._read(stream)
|
|
137
|
-
return Acquisition(head=field_values[0], data=field_values[1],
|
|
137
|
+
return Acquisition(head=field_values[0], data=field_values[1], phase=field_values[2], trajectory=field_values[3])
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class AcquisitionPrototypeSerializer(_binary.RecordSerializer[AcquisitionPrototype]):
|
|
141
|
+
def __init__(self) -> None:
|
|
142
|
+
super().__init__([("head", AcquisitionHeaderSerializer()), ("data_sample_counts", _binary.NDArraySerializer(_binary.uint32_serializer, 1))])
|
|
143
|
+
|
|
144
|
+
def write(self, stream: _binary.CodedOutputStream, value: AcquisitionPrototype) -> None:
|
|
145
|
+
if isinstance(value, np.void):
|
|
146
|
+
self.write_numpy(stream, value)
|
|
147
|
+
return
|
|
148
|
+
self._write(stream, value.head, value.data_sample_counts)
|
|
149
|
+
|
|
150
|
+
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
151
|
+
self._write(stream, value['head'], value['data_sample_counts'])
|
|
152
|
+
|
|
153
|
+
def read(self, stream: _binary.CodedInputStream) -> AcquisitionPrototype:
|
|
154
|
+
field_values = self._read(stream)
|
|
155
|
+
return AcquisitionPrototype(head=field_values[0], data_sample_counts=field_values[1])
|
|
138
156
|
|
|
139
157
|
|
|
140
158
|
class SubjectInformationTypeSerializer(_binary.RecordSerializer[SubjectInformationType]):
|
|
@@ -679,20 +697,20 @@ class HeaderSerializer(_binary.RecordSerializer[Header]):
|
|
|
679
697
|
|
|
680
698
|
class ImageHeaderSerializer(_binary.RecordSerializer[ImageHeader]):
|
|
681
699
|
def __init__(self) -> None:
|
|
682
|
-
super().__init__([("flags", _binary.EnumSerializer(_binary.uint64_serializer, ImageFlags)), ("measurement_uid", _binary.uint32_serializer), ("field_of_view", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("position", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("col_dir", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("line_dir", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("slice_dir", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("patient_table_position", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("average", _binary.OptionalSerializer(_binary.uint32_serializer)), ("slice", _binary.OptionalSerializer(_binary.uint32_serializer)), ("contrast", _binary.OptionalSerializer(_binary.uint32_serializer)), ("phase", _binary.OptionalSerializer(_binary.uint32_serializer)), ("repetition", _binary.OptionalSerializer(_binary.uint32_serializer)), ("set", _binary.OptionalSerializer(_binary.uint32_serializer)), ("
|
|
700
|
+
super().__init__([("flags", _binary.EnumSerializer(_binary.uint64_serializer, ImageFlags)), ("measurement_uid", _binary.uint32_serializer), ("field_of_view", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("position", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("col_dir", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("line_dir", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("slice_dir", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("patient_table_position", _binary.FixedNDArraySerializer(_binary.float32_serializer, (3,))), ("average", _binary.OptionalSerializer(_binary.uint32_serializer)), ("slice", _binary.OptionalSerializer(_binary.uint32_serializer)), ("contrast", _binary.OptionalSerializer(_binary.uint32_serializer)), ("phase", _binary.OptionalSerializer(_binary.uint32_serializer)), ("repetition", _binary.OptionalSerializer(_binary.uint32_serializer)), ("set", _binary.OptionalSerializer(_binary.uint32_serializer)), ("acquisition_time_stamp_ns", _binary.OptionalSerializer(_binary.uint64_serializer)), ("physiology_time_stamp_ns", _binary.VectorSerializer(_binary.uint64_serializer)), ("image_type", _binary.EnumSerializer(_binary.int32_serializer, ImageType)), ("image_index", _binary.OptionalSerializer(_binary.uint32_serializer)), ("image_series_index", _binary.OptionalSerializer(_binary.uint32_serializer)), ("user_int", _binary.VectorSerializer(_binary.int32_serializer)), ("user_float", _binary.VectorSerializer(_binary.float32_serializer))])
|
|
683
701
|
|
|
684
702
|
def write(self, stream: _binary.CodedOutputStream, value: ImageHeader) -> None:
|
|
685
703
|
if isinstance(value, np.void):
|
|
686
704
|
self.write_numpy(stream, value)
|
|
687
705
|
return
|
|
688
|
-
self._write(stream, value.flags, value.measurement_uid, value.field_of_view, value.position, value.col_dir, value.line_dir, value.slice_dir, value.patient_table_position, value.average, value.slice, value.contrast, value.phase, value.repetition, value.set, value.
|
|
706
|
+
self._write(stream, value.flags, value.measurement_uid, value.field_of_view, value.position, value.col_dir, value.line_dir, value.slice_dir, value.patient_table_position, value.average, value.slice, value.contrast, value.phase, value.repetition, value.set, value.acquisition_time_stamp_ns, value.physiology_time_stamp_ns, value.image_type, value.image_index, value.image_series_index, value.user_int, value.user_float)
|
|
689
707
|
|
|
690
708
|
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
691
|
-
self._write(stream, value['flags'], value['measurement_uid'], value['field_of_view'], value['position'], value['col_dir'], value['line_dir'], value['slice_dir'], value['patient_table_position'], value['average'], value['slice'], value['contrast'], value['phase'], value['repetition'], value['set'], value['
|
|
709
|
+
self._write(stream, value['flags'], value['measurement_uid'], value['field_of_view'], value['position'], value['col_dir'], value['line_dir'], value['slice_dir'], value['patient_table_position'], value['average'], value['slice'], value['contrast'], value['phase'], value['repetition'], value['set'], value['acquisition_time_stamp_ns'], value['physiology_time_stamp_ns'], value['image_type'], value['image_index'], value['image_series_index'], value['user_int'], value['user_float'])
|
|
692
710
|
|
|
693
711
|
def read(self, stream: _binary.CodedInputStream) -> ImageHeader:
|
|
694
712
|
field_values = self._read(stream)
|
|
695
|
-
return ImageHeader(flags=field_values[0], measurement_uid=field_values[1], field_of_view=field_values[2], position=field_values[3], col_dir=field_values[4], line_dir=field_values[5], slice_dir=field_values[6], patient_table_position=field_values[7], average=field_values[8], slice=field_values[9], contrast=field_values[10], phase=field_values[11], repetition=field_values[12], set=field_values[13],
|
|
713
|
+
return ImageHeader(flags=field_values[0], measurement_uid=field_values[1], field_of_view=field_values[2], position=field_values[3], col_dir=field_values[4], line_dir=field_values[5], slice_dir=field_values[6], patient_table_position=field_values[7], average=field_values[8], slice=field_values[9], contrast=field_values[10], phase=field_values[11], repetition=field_values[12], set=field_values[13], acquisition_time_stamp_ns=field_values[14], physiology_time_stamp_ns=field_values[15], image_type=field_values[16], image_index=field_values[17], image_series_index=field_values[18], user_int=field_values[19], user_float=field_values[20])
|
|
696
714
|
|
|
697
715
|
|
|
698
716
|
class ImageSerializer(typing.Generic[T, T_NP], _binary.RecordSerializer[Image[T_NP]]):
|
|
@@ -715,38 +733,38 @@ class ImageSerializer(typing.Generic[T, T_NP], _binary.RecordSerializer[Image[T_
|
|
|
715
733
|
|
|
716
734
|
class NoiseCovarianceSerializer(_binary.RecordSerializer[NoiseCovariance]):
|
|
717
735
|
def __init__(self) -> None:
|
|
718
|
-
super().__init__([("coil_labels", _binary.VectorSerializer(CoilLabelTypeSerializer())), ("receiver_noise_bandwidth", _binary.float32_serializer), ("
|
|
736
|
+
super().__init__([("coil_labels", _binary.VectorSerializer(CoilLabelTypeSerializer())), ("receiver_noise_bandwidth", _binary.float32_serializer), ("noise_dwell_time_ns", _binary.uint64_serializer), ("sample_count", _binary.size_serializer), ("matrix", _binary.NDArraySerializer(_binary.complexfloat32_serializer, 2))])
|
|
719
737
|
|
|
720
738
|
def write(self, stream: _binary.CodedOutputStream, value: NoiseCovariance) -> None:
|
|
721
739
|
if isinstance(value, np.void):
|
|
722
740
|
self.write_numpy(stream, value)
|
|
723
741
|
return
|
|
724
|
-
self._write(stream, value.coil_labels, value.receiver_noise_bandwidth, value.
|
|
742
|
+
self._write(stream, value.coil_labels, value.receiver_noise_bandwidth, value.noise_dwell_time_ns, value.sample_count, value.matrix)
|
|
725
743
|
|
|
726
744
|
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
727
|
-
self._write(stream, value['coil_labels'], value['receiver_noise_bandwidth'], value['
|
|
745
|
+
self._write(stream, value['coil_labels'], value['receiver_noise_bandwidth'], value['noise_dwell_time_ns'], value['sample_count'], value['matrix'])
|
|
728
746
|
|
|
729
747
|
def read(self, stream: _binary.CodedInputStream) -> NoiseCovariance:
|
|
730
748
|
field_values = self._read(stream)
|
|
731
|
-
return NoiseCovariance(coil_labels=field_values[0], receiver_noise_bandwidth=field_values[1],
|
|
749
|
+
return NoiseCovariance(coil_labels=field_values[0], receiver_noise_bandwidth=field_values[1], noise_dwell_time_ns=field_values[2], sample_count=field_values[3], matrix=field_values[4])
|
|
732
750
|
|
|
733
751
|
|
|
734
752
|
class WaveformSerializer(typing.Generic[T, T_NP], _binary.RecordSerializer[Waveform[T_NP]]):
|
|
735
753
|
def __init__(self, t_serializer: _binary.TypeSerializer[T, T_NP]) -> None:
|
|
736
|
-
super().__init__([("flags", _binary.uint64_serializer), ("measurement_uid", _binary.uint32_serializer), ("scan_counter", _binary.uint32_serializer), ("
|
|
754
|
+
super().__init__([("flags", _binary.uint64_serializer), ("measurement_uid", _binary.uint32_serializer), ("scan_counter", _binary.uint32_serializer), ("time_stamp_ns", _binary.uint64_serializer), ("sample_time_ns", _binary.uint64_serializer), ("waveform_id", _binary.uint32_serializer), ("data", _binary.NDArraySerializer(t_serializer, 2))])
|
|
737
755
|
|
|
738
756
|
def write(self, stream: _binary.CodedOutputStream, value: Waveform[T_NP]) -> None:
|
|
739
757
|
if isinstance(value, np.void):
|
|
740
758
|
self.write_numpy(stream, value)
|
|
741
759
|
return
|
|
742
|
-
self._write(stream, value.flags, value.measurement_uid, value.scan_counter, value.
|
|
760
|
+
self._write(stream, value.flags, value.measurement_uid, value.scan_counter, value.time_stamp_ns, value.sample_time_ns, value.waveform_id, value.data)
|
|
743
761
|
|
|
744
762
|
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
745
|
-
self._write(stream, value['flags'], value['measurement_uid'], value['scan_counter'], value['
|
|
763
|
+
self._write(stream, value['flags'], value['measurement_uid'], value['scan_counter'], value['time_stamp_ns'], value['sample_time_ns'], value['waveform_id'], value['data'])
|
|
746
764
|
|
|
747
765
|
def read(self, stream: _binary.CodedInputStream) -> Waveform[T_NP]:
|
|
748
766
|
field_values = self._read(stream)
|
|
749
|
-
return Waveform[T_NP](flags=field_values[0], measurement_uid=field_values[1], scan_counter=field_values[2],
|
|
767
|
+
return Waveform[T_NP](flags=field_values[0], measurement_uid=field_values[1], scan_counter=field_values[2], time_stamp_ns=field_values[3], sample_time_ns=field_values[4], waveform_id=field_values[5], data=field_values[6])
|
|
750
768
|
|
|
751
769
|
|
|
752
770
|
class AcquisitionBucketSerializer(_binary.RecordSerializer[AcquisitionBucket]):
|
|
@@ -875,3 +893,129 @@ class ImageArraySerializer(_binary.RecordSerializer[ImageArray]):
|
|
|
875
893
|
return ImageArray(data=field_values[0], headers=field_values[1], meta=field_values[2], waveforms=field_values[3])
|
|
876
894
|
|
|
877
895
|
|
|
896
|
+
class PulseqDefinitionsSerializer(_binary.RecordSerializer[PulseqDefinitions]):
|
|
897
|
+
def __init__(self) -> None:
|
|
898
|
+
super().__init__([("gradient_raster_time", _binary.float64_serializer), ("radiofrequency_raster_time", _binary.float64_serializer), ("adc_raster_time", _binary.float64_serializer), ("block_duration_raster", _binary.float64_serializer), ("name", _binary.OptionalSerializer(_binary.string_serializer)), ("fov", _binary.OptionalSerializer(ThreeDimensionalFloatSerializer())), ("total_duration", _binary.OptionalSerializer(_binary.float64_serializer)), ("custom", _binary.MapSerializer(_binary.string_serializer, _binary.string_serializer))])
|
|
899
|
+
|
|
900
|
+
def write(self, stream: _binary.CodedOutputStream, value: PulseqDefinitions) -> None:
|
|
901
|
+
if isinstance(value, np.void):
|
|
902
|
+
self.write_numpy(stream, value)
|
|
903
|
+
return
|
|
904
|
+
self._write(stream, value.gradient_raster_time, value.radiofrequency_raster_time, value.adc_raster_time, value.block_duration_raster, value.name, value.fov, value.total_duration, value.custom)
|
|
905
|
+
|
|
906
|
+
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
907
|
+
self._write(stream, value['gradient_raster_time'], value['radiofrequency_raster_time'], value['adc_raster_time'], value['block_duration_raster'], value['name'], value['fov'], value['total_duration'], value['custom'])
|
|
908
|
+
|
|
909
|
+
def read(self, stream: _binary.CodedInputStream) -> PulseqDefinitions:
|
|
910
|
+
field_values = self._read(stream)
|
|
911
|
+
return PulseqDefinitions(gradient_raster_time=field_values[0], radiofrequency_raster_time=field_values[1], adc_raster_time=field_values[2], block_duration_raster=field_values[3], name=field_values[4], fov=field_values[5], total_duration=field_values[6], custom=field_values[7])
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
class PulseqBlockSerializer(_binary.RecordSerializer[PulseqBlock]):
|
|
915
|
+
def __init__(self) -> None:
|
|
916
|
+
super().__init__([("id", _binary.int32_serializer), ("duration", _binary.uint64_serializer), ("rf", _binary.int32_serializer), ("gx", _binary.int32_serializer), ("gy", _binary.int32_serializer), ("gz", _binary.int32_serializer), ("adc", _binary.int32_serializer), ("ext", _binary.int32_serializer)])
|
|
917
|
+
|
|
918
|
+
def write(self, stream: _binary.CodedOutputStream, value: PulseqBlock) -> None:
|
|
919
|
+
if isinstance(value, np.void):
|
|
920
|
+
self.write_numpy(stream, value)
|
|
921
|
+
return
|
|
922
|
+
self._write(stream, value.id, value.duration, value.rf, value.gx, value.gy, value.gz, value.adc, value.ext)
|
|
923
|
+
|
|
924
|
+
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
925
|
+
self._write(stream, value['id'], value['duration'], value['rf'], value['gx'], value['gy'], value['gz'], value['adc'], value['ext'])
|
|
926
|
+
|
|
927
|
+
def read(self, stream: _binary.CodedInputStream) -> PulseqBlock:
|
|
928
|
+
field_values = self._read(stream)
|
|
929
|
+
return PulseqBlock(id=field_values[0], duration=field_values[1], rf=field_values[2], gx=field_values[3], gy=field_values[4], gz=field_values[5], adc=field_values[6], ext=field_values[7])
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
class PulseqRFEventSerializer(_binary.RecordSerializer[PulseqRFEvent]):
|
|
933
|
+
def __init__(self) -> None:
|
|
934
|
+
super().__init__([("id", _binary.int32_serializer), ("amp", _binary.float64_serializer), ("mag_id", _binary.int32_serializer), ("phase_id", _binary.int32_serializer), ("time_id", _binary.int32_serializer), ("center", _binary.float64_serializer), ("delay", _binary.uint64_serializer), ("freq_ppm", _binary.float64_serializer), ("phase_ppm", _binary.float64_serializer), ("freq_offset", _binary.float64_serializer), ("phase_offset", _binary.float64_serializer), ("use", _binary.EnumSerializer(_binary.int32_serializer, RFPulseUse))])
|
|
935
|
+
|
|
936
|
+
def write(self, stream: _binary.CodedOutputStream, value: PulseqRFEvent) -> None:
|
|
937
|
+
if isinstance(value, np.void):
|
|
938
|
+
self.write_numpy(stream, value)
|
|
939
|
+
return
|
|
940
|
+
self._write(stream, value.id, value.amp, value.mag_id, value.phase_id, value.time_id, value.center, value.delay, value.freq_ppm, value.phase_ppm, value.freq_offset, value.phase_offset, value.use)
|
|
941
|
+
|
|
942
|
+
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
943
|
+
self._write(stream, value['id'], value['amp'], value['mag_id'], value['phase_id'], value['time_id'], value['center'], value['delay'], value['freq_ppm'], value['phase_ppm'], value['freq_offset'], value['phase_offset'], value['use'])
|
|
944
|
+
|
|
945
|
+
def read(self, stream: _binary.CodedInputStream) -> PulseqRFEvent:
|
|
946
|
+
field_values = self._read(stream)
|
|
947
|
+
return PulseqRFEvent(id=field_values[0], amp=field_values[1], mag_id=field_values[2], phase_id=field_values[3], time_id=field_values[4], center=field_values[5], delay=field_values[6], freq_ppm=field_values[7], phase_ppm=field_values[8], freq_offset=field_values[9], phase_offset=field_values[10], use=field_values[11])
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
class PulseqArbitraryGradientSerializer(_binary.RecordSerializer[PulseqArbitraryGradient]):
|
|
951
|
+
def __init__(self) -> None:
|
|
952
|
+
super().__init__([("id", _binary.int32_serializer), ("amp", _binary.float64_serializer), ("first", _binary.float64_serializer), ("last", _binary.float64_serializer), ("shape_id", _binary.int32_serializer), ("time_id", _binary.int32_serializer), ("delay", _binary.uint64_serializer)])
|
|
953
|
+
|
|
954
|
+
def write(self, stream: _binary.CodedOutputStream, value: PulseqArbitraryGradient) -> None:
|
|
955
|
+
if isinstance(value, np.void):
|
|
956
|
+
self.write_numpy(stream, value)
|
|
957
|
+
return
|
|
958
|
+
self._write(stream, value.id, value.amp, value.first, value.last, value.shape_id, value.time_id, value.delay)
|
|
959
|
+
|
|
960
|
+
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
961
|
+
self._write(stream, value['id'], value['amp'], value['first'], value['last'], value['shape_id'], value['time_id'], value['delay'])
|
|
962
|
+
|
|
963
|
+
def read(self, stream: _binary.CodedInputStream) -> PulseqArbitraryGradient:
|
|
964
|
+
field_values = self._read(stream)
|
|
965
|
+
return PulseqArbitraryGradient(id=field_values[0], amp=field_values[1], first=field_values[2], last=field_values[3], shape_id=field_values[4], time_id=field_values[5], delay=field_values[6])
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
class PulseqTrapezoidalGradientSerializer(_binary.RecordSerializer[PulseqTrapezoidalGradient]):
|
|
969
|
+
def __init__(self) -> None:
|
|
970
|
+
super().__init__([("id", _binary.int32_serializer), ("amp", _binary.float64_serializer), ("rise", _binary.uint64_serializer), ("flat", _binary.uint64_serializer), ("fall", _binary.uint64_serializer), ("delay", _binary.uint64_serializer)])
|
|
971
|
+
|
|
972
|
+
def write(self, stream: _binary.CodedOutputStream, value: PulseqTrapezoidalGradient) -> None:
|
|
973
|
+
if isinstance(value, np.void):
|
|
974
|
+
self.write_numpy(stream, value)
|
|
975
|
+
return
|
|
976
|
+
self._write(stream, value.id, value.amp, value.rise, value.flat, value.fall, value.delay)
|
|
977
|
+
|
|
978
|
+
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
979
|
+
self._write(stream, value['id'], value['amp'], value['rise'], value['flat'], value['fall'], value['delay'])
|
|
980
|
+
|
|
981
|
+
def read(self, stream: _binary.CodedInputStream) -> PulseqTrapezoidalGradient:
|
|
982
|
+
field_values = self._read(stream)
|
|
983
|
+
return PulseqTrapezoidalGradient(id=field_values[0], amp=field_values[1], rise=field_values[2], flat=field_values[3], fall=field_values[4], delay=field_values[5])
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
class PulseqADCEventSerializer(_binary.RecordSerializer[PulseqADCEvent]):
|
|
987
|
+
def __init__(self) -> None:
|
|
988
|
+
super().__init__([("id", _binary.int32_serializer), ("num", _binary.uint64_serializer), ("dwell", _binary.float32_serializer), ("delay", _binary.uint64_serializer), ("freq_ppm", _binary.float64_serializer), ("phase_ppm", _binary.float64_serializer), ("freq", _binary.float64_serializer), ("phase", _binary.float64_serializer), ("phase_shape_id", _binary.int32_serializer)])
|
|
989
|
+
|
|
990
|
+
def write(self, stream: _binary.CodedOutputStream, value: PulseqADCEvent) -> None:
|
|
991
|
+
if isinstance(value, np.void):
|
|
992
|
+
self.write_numpy(stream, value)
|
|
993
|
+
return
|
|
994
|
+
self._write(stream, value.id, value.num, value.dwell, value.delay, value.freq_ppm, value.phase_ppm, value.freq, value.phase, value.phase_shape_id)
|
|
995
|
+
|
|
996
|
+
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
997
|
+
self._write(stream, value['id'], value['num'], value['dwell'], value['delay'], value['freq_ppm'], value['phase_ppm'], value['freq'], value['phase'], value['phase_shape_id'])
|
|
998
|
+
|
|
999
|
+
def read(self, stream: _binary.CodedInputStream) -> PulseqADCEvent:
|
|
1000
|
+
field_values = self._read(stream)
|
|
1001
|
+
return PulseqADCEvent(id=field_values[0], num=field_values[1], dwell=field_values[2], delay=field_values[3], freq_ppm=field_values[4], phase_ppm=field_values[5], freq=field_values[6], phase=field_values[7], phase_shape_id=field_values[8])
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
class PulseqShapeSerializer(_binary.RecordSerializer[PulseqShape]):
|
|
1005
|
+
def __init__(self) -> None:
|
|
1006
|
+
super().__init__([("id", _binary.int32_serializer), ("num_samples", _binary.uint64_serializer), ("data", _binary.NDArraySerializer(_binary.float64_serializer, 1))])
|
|
1007
|
+
|
|
1008
|
+
def write(self, stream: _binary.CodedOutputStream, value: PulseqShape) -> None:
|
|
1009
|
+
if isinstance(value, np.void):
|
|
1010
|
+
self.write_numpy(stream, value)
|
|
1011
|
+
return
|
|
1012
|
+
self._write(stream, value.id, value.num_samples, value.data)
|
|
1013
|
+
|
|
1014
|
+
def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None:
|
|
1015
|
+
self._write(stream, value['id'], value['num_samples'], value['data'])
|
|
1016
|
+
|
|
1017
|
+
def read(self, stream: _binary.CodedInputStream) -> PulseqShape:
|
|
1018
|
+
field_values = self._read(stream)
|
|
1019
|
+
return PulseqShape(id=field_values[0], num_samples=field_values[1], data=field_values[2])
|
|
1020
|
+
|
|
1021
|
+
|