Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ismrmrd_to_np(filename):
"""Read ISMRMRD data file to numpy array"""
logger.debug('Loading file {}...'.format(filename))
dataset = ismrmrd.Dataset(filename, create_if_needed=False)
header = ismrmrd.xsd.CreateFromDocument(dataset.read_xml_header())
num_kx = header.encoding[0].encodedSpace.matrixSize.x
num_ky = header.encoding[0].encodingLimits.kspace_encoding_step_1.maximum
num_slices = header.encoding[0].encodingLimits.slice.maximum + 1
num_channels = header.acquisitionSystemInformation.receiverChannels
try:
rec_std = dataset.read_array('rec_std', 0)
rec_weight = 1.0 / (rec_std**2)
rec_weight = np.sqrt(rec_weight / np.sum(rec_weight))
logger.debug(' Using rec std...')
except Exception:
rec_weight = np.ones(num_channels)
opt_mat = np.diag(rec_weight)
kspace = np.zeros([num_channels, num_slices, num_ky, num_kx],
dtype=np.complex64)
def ismrmrd_to_np(filename):
"""Read ISMRMRD data file to numpy array"""
logger.debug('Loading file {}...'.format(filename))
dataset = ismrmrd.Dataset(filename, create_if_needed=False)
header = ismrmrd.xsd.CreateFromDocument(dataset.read_xml_header())
num_kx = header.encoding[0].encodedSpace.matrixSize.x
num_ky = header.encoding[0].encodingLimits.kspace_encoding_step_1.maximum
num_slices = header.encoding[0].encodingLimits.slice.maximum + 1
num_channels = header.acquisitionSystemInformation.receiverChannels
try:
rec_std = dataset.read_array('rec_std', 0)
rec_weight = 1.0 / (rec_std**2)
rec_weight = np.sqrt(rec_weight / np.sum(rec_weight))
logger.debug(' Using rec std...')
except Exception:
rec_weight = np.ones(num_channels)
opt_mat = np.diag(rec_weight)
kspace = np.zeros([num_channels, num_slices, num_ky, num_kx],
dtype=np.complex64)
num_acq = dataset.number_of_acquisitions()