mrd-python 2.2.0__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.2.0 → mrd_python-2.2.1}/PKG-INFO +2 -1
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/__init__.py +10 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/binary.py +154 -10
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/ndjson.py +621 -2
- mrd_python-2.2.1/mrd/protocols.py +320 -0
- mrd_python-2.2.1/mrd/tools/fastmri_to_mrd.py +221 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/tools/ismrmrd_to_mrd.py +79 -26
- mrd_python-2.2.1/mrd/tools/mrd_to_seq.py +295 -0
- mrd_python-2.2.1/mrd/tools/seq_to_mrd.py +485 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/types.py +571 -20
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd_python.egg-info/PKG-INFO +2 -1
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd_python.egg-info/SOURCES.txt +3 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd_python.egg-info/requires.txt +1 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/pyproject.toml +1 -0
- mrd_python-2.2.0/mrd/protocols.py +0 -320
- {mrd_python-2.2.0 → mrd_python-2.2.1}/README.md +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/_binary.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/_dtypes.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/_ndjson.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/tools/export_png_images.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/tools/minimal_example.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/tools/mrd_to_ismrmrd.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/tools/phantom.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/tools/simulation.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/tools/stream_recon.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/tools/transform.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd/yardl_types.py +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd_python.egg-info/dependency_links.txt +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/mrd_python.egg-info/top_level.txt +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/setup.cfg +0 -0
- {mrd_python-2.2.0 → mrd_python-2.2.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mrd-python
|
|
3
|
-
Version: 2.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
|
|
@@ -13,6 +13,7 @@ Classifier: Intended Audience :: Science/Research
|
|
|
13
13
|
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
14
14
|
Requires-Python: >=3.12
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: h5py>=3.15.1
|
|
16
17
|
Requires-Dist: ismrmrd>=1.14.2
|
|
17
18
|
Requires-Dist: numpy>=1.22.0
|
|
18
19
|
Requires-Dist: pillow>=9.2.0
|
|
@@ -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,
|
|
@@ -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):
|
|
@@ -52,7 +52,7 @@ class BinaryMrdReader(_binary.BinaryProtocolReader, MrdReaderBase):
|
|
|
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.
|
|
@@ -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)), ("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))])
|
|
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.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)
|
|
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['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'])
|
|
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]):
|
|
@@ -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
|
+
|