Skip to content

Commit c807f0f

Browse files
astewartauclaude
andauthored
Fix compatibility with ismrmrd-python 1.14.2+ (#13)
The function `ismrmrd.get_dtype_from_data_type()` was removed from the public API in ismrmrd-python PR #82 (merged Sep 2025) when wildcard imports were replaced with explicit imports to clean up the public API. This change replaces all calls to `ismrmrd.get_dtype_from_data_type(image.data_type)` with `image.data.dtype`, which is functionally equivalent since the Image class already calls `get_dtype_from_data_type()` internally during initialization to create the data array with the correct dtype. Changes: - connection.py: Fixed 3 occurrences in read_image() - invertcontrast.py: Fixed logging statement - analyzeflow.py: Fixed logging statement - custom/filter.py: Fixed logging statement 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent dbb3e58 commit c807f0f

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

analyzeflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def process_image(imgGroup, connection, config, mrdHeader):
116116
os.makedirs(debugFolder)
117117
logging.debug("Created folder " + debugFolder + " for debug output files")
118118

119-
logging.debug("Processing data with %d images of type %s", len(imgGroup), ismrmrd.get_dtype_from_data_type(imgGroup[0].data_type))
119+
logging.debug("Processing data with %d images of type %s", len(imgGroup), imgGroup[0].data.dtype)
120120

121121
# Display MetaAttributes for first image
122122
tmpMeta = ismrmrd.Meta.deserialize(imgGroup[0].attribute_string)

connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,17 @@ def read_image(self):
372372

373373
image = ismrmrd.Image(header_bytes, attribute_bytes.split(b'\x00',1)[0].decode('utf-8')) # Strip off null teminator
374374

375-
logging.info(" Image is size %d x %d x %d with %d channels of type %s", image.getHead().matrix_size[0], image.getHead().matrix_size[1], image.getHead().matrix_size[2], image.channels, ismrmrd.get_dtype_from_data_type(image.data_type))
375+
logging.info(" Image is size %d x %d x %d with %d channels of type %s", image.getHead().matrix_size[0], image.getHead().matrix_size[1], image.getHead().matrix_size[2], image.channels, image.data.dtype)
376376
def calculate_number_of_entries(nchannels, xs, ys, zs):
377377
return nchannels * xs * ys * zs
378378

379379
nentries = calculate_number_of_entries(image.channels, *image.getHead().matrix_size)
380-
nbytes = nentries * ismrmrd.get_dtype_from_data_type(image.data_type).itemsize
380+
nbytes = nentries * image.data.dtype.itemsize
381381

382382
logging.debug("Reading in %d bytes of image data", nbytes)
383383
data_bytes = self.read(nbytes)
384384

385-
image.data.ravel()[:] = np.frombuffer(data_bytes, dtype=ismrmrd.get_dtype_from_data_type(image.data_type))
385+
image.data.ravel()[:] = np.frombuffer(data_bytes, dtype=image.data.dtype)
386386

387387
if self.savedata is True:
388388
if self.dset is None:

custom/filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def process_image(imgGroup, connection, config, mrdHeader):
264264
os.makedirs(debugFolder)
265265
logging.debug("Created folder " + debugFolder + " for debug output files")
266266

267-
logging.debug("Processing data with %d images of type %s", len(imgGroup), ismrmrd.get_dtype_from_data_type(imgGroup[0].data_type))
267+
logging.debug("Processing data with %d images of type %s", len(imgGroup), imgGroup[0].data.dtype)
268268

269269
# Note: The MRD Image class stores data as [cha z y x]
270270

invertcontrast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def process_image(imgGroup, connection, config, mrdHeader):
263263
os.makedirs(debugFolder)
264264
logging.debug("Created folder " + debugFolder + " for debug output files")
265265

266-
logging.debug("Processing data with %d images of type %s", len(imgGroup), ismrmrd.get_dtype_from_data_type(imgGroup[0].data_type))
266+
logging.debug("Processing data with %d images of type %s", len(imgGroup), imgGroup[0].data.dtype)
267267

268268
# Note: The MRD Image class stores data as [cha z y x]
269269

0 commit comments

Comments
 (0)