Imported Upstream version 1.2.3

parent 487bca10
......@@ -51,7 +51,7 @@ endif (WIN32)
#in the utility libraries, that don't affect the data format itself.
set(ISMRMRD_VERSION_MAJOR 1)
set(ISMRMRD_VERSION_MINOR 2)
set(ISMRMRD_VERSION_PATCH 1)
set(ISMRMRD_VERSION_PATCH 3)
set(ISMRMRD_XML_SCHEMA_SHA1 "99a63f4e8cf08ffc268f5ee8b8c8b2a1edf69412")
......
ismrmrd.c
*.so
*.h5
MANIFEST
build/
dist/
cismrmrd.pxd
ismrmrd.pyx
setup.py
ISMRMRD_HOME ?= /usr/local
CPPFLAGS = -I$(ISMRMRD_HOME)/include
LDFLAGS = -L$(ISMRMRD_HOME)/lib
ismrmrd.so: ismrmrd.pyx cismrmrd.pxd setup.py
python setup.py build_ext -i
install: ismrmrd.so
install -d $(ISMRMRD_HOME)/python
install $< $(ISMRMRD_HOME)/python/
clean:
rm ismrmrd.c ismrmrd.so
Python bindings to ISMRMRD
This diff is collapsed.
import ismrmrd
acq = ismrmrd.Acquisition()
acq.head.version = 42
print(acq.head.version)
img = ismrmrd.Image()
f = ismrmrd.Dataset('./testdata.h5', '/dataset', True)
print f.filename
# xml = f.readHeader()
This diff is collapsed.
import os
from distutils.core import setup
from distutils.command.build import build
from distutils.command.build_py import build_py
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy
ismrmrd_home = os.environ.get('ISMRMRD_HOME', '')
schema_file = os.path.join(ismrmrd_home,'share','ismrmrd','schema','ismrmrd.xsd')
class my_build(build):
def run(self):
self.run_command("build_ext")
self.run_command("build_py")
build.run(self)
class my_build_py(build_py):
def run(self):
print "Hello"
# honor the --dry-run flag
if not self.dry_run:
os.system('pyxbgen -u '+schema_file+' -m ismrmrd_xsd --binding-root="'+self.build_lib+'"')
# distutils uses old-style classes, so no super()
build_py.run(self)
ext = Extension(
"ismrmrd",
["cismrmrd.pxd", "ismrmrd.pyx"],
include_dirs=[os.path.join(ismrmrd_home, 'include'),
'/usr/local/include', '/usr/include',
numpy.get_include()],
library_dirs=[os.path.join(ismrmrd_home, 'lib'),
'/usr/local/lib', '/usr/lib'],
libraries=["ismrmrd"],
extra_link_args=[],
)
setup(
name='ismrmrd',
version='1.2.1',
author='ISMRMRD Developers',
author_email='ismrmrd@googlegroups.com',
description='Python bindings to ISMRMRD',
license='Public Domain',
keywords='ismrmrd',
url='https://ismrmrd.github.io',
packages=[],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
'License :: Public Domain',
'Operating System :: OS Independent',
'Programming Language :: Cython',
'Topic :: Scientific/Engineering :: Medical Science Apps.'
],
requires=['Cython', 'numpy', 'PyXB'],
ext_modules=[ext],
cmdclass={'build_ext':build_ext,'build_py':my_build_py,'build':my_build}
)
......@@ -31,3 +31,8 @@ set(DEBIAN_PACKAGE_DEPENDS "libhdf5-7, libfftw3-3, libboost-program-options-dev"
# where the package metadata are
set(ISMRMRD_CPACK_CFG_FILE "${PROJECT_BINARY_DIR}/cpack_options.cmake")
# Where the package to be installed
#set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
message("CPACK_PACKAGING_INSTALL_PREFIX: " ${CPACK_PACKAGING_INSTALL_PREFIX})
......@@ -97,6 +97,7 @@ Mac OSX Installation
There are numerous different package management systems for Mac. In this example, we have used Homebrew (http://brew.sh/). First install the dependencies::
brew tap homebrew/science
brew install wget hdf5 boost cmake doxygen fftw
Then download and compile:
......
......@@ -156,6 +156,7 @@ int main(void)
numim = ismrmrd_get_number_of_images(&dataset2, "testimages");
printf("Number of images stored = %d\n", numim);
ismrmrd_init_image(&im2);
ismrmrd_read_image(&dataset2, "testimages", 1, &im2);
printf("Image 1 attribute string = %s\n", im2.attribute_string);
printf("Image 1 at position 10 has value = %f\n", ((float*)im2.data)[10]);
......@@ -175,6 +176,7 @@ int main(void)
printf("Number of arrays stored = %d\n", ismrmrd_get_number_of_arrays(&dataset2, "testarray"));
/* Read it back in */
ismrmrd_init_ndarray(&arr2);
ismrmrd_read_array(&dataset2, "testarray", 0, &arr2);
printf("Array 2 at position 10 has value = %f\n", ((float*)arr2.data)[10]);
......
......@@ -12,9 +12,9 @@ filename = 'testdata.h5'
if not os.path.isfile(filename):
print("%s is not a valid file" % filename)
raise SystemExit
dset = ismrmrd.IsmrmrdDataset(filename, 'dataset', create_if_needed=False)
dset = ismrmrd.Dataset(filename, 'dataset', create_if_needed=False)
header = ismrmrd_xsd.CreateFromDocument(dset.readHeader())
header = ismrmrd_xsd.CreateFromDocument(dset.read_header())
enc = header.encoding[0]
# Matrix size
......@@ -34,65 +34,72 @@ rFOVy = enc.reconSpace.fieldOfView_mm.y
rFOVz = enc.reconSpace.fieldOfView_mm.z
# Number of Slices, Reps, Contrasts, etc.
nslices = enc.encodingLimits.slice.maximum + 1
ncoils = header.acquisitionSystemInformation.receiverChannels
nreps = enc.encodingLimits.repetition.maximum + 1
ncontrasts = enc.encodingLimits.contrast.maximum + 1
# TODO: Ignore noise scans
for acqnum in range(dset.getNumberOfAcquisitions()):
acq = dset.readAcquisition(acqnum)
if acq.getHead().flags & ismrmrd.ACQ_IS_NOISE_MEASUREMENT:
print("Found noise measurement @ %d" % acqnum)
all_data = np.zeros((eNx, eNy, eNz, ncoils, nslices, ncontrasts, nreps), dtype=np.complex64)
for acqnum in range(dset.getNumberOfAcquisitions()):
acq = dset.readAcquisition(acqnum)
head = acq.getHead()
rep = head.idx.repetition
contrast = head.idx.contrast
slice = head.idx.slice
y = head.idx.kspace_encode_step_1
z = head.idx.kspace_encode_step_2
floatdata = acq.getData()
data = np.array([complex(elem[0], elem[1]) for elem in zip(floatdata[::2], floatdata[1::2])])
data = data.reshape((eNx, ncoils))
all_data[:, y, z, :, slice, contrast, rep] = data
fig = plt.figure()
h, w = nreps * ncontrasts, eNz * nslices
i = 0
for rep in range(nreps):
for contrast in range(ncontrasts):
for slice in range(nslices):
for z in range(eNz):
K = all_data[:,:,z,:,slice, contrast, rep]
comb = np.sqrt(np.sum(np.abs(K) ** 2, 2))
a = fig.add_subplot(h, w, i)
plt.imshow(comb)
i += 1
fig.set_size_inches(16, 16)
if enc.encodingLimits.slice != None:
nslices = enc.encodingLimits.slice.maximum + 1
else:
nslices = 1
if enc.encodingLimits.repetition != None:
nreps = enc.encodingLimits.repetition.maximum + 1
else:
nreps = 1
if enc.encodingLimits.contrast != None:
ncontrasts = enc.encodingLimits.contrast.maximum + 1
else:
ncontrasts = 1
all_data = np.zeros((nreps, ncontrasts, nslices, ncoils, eNz, eNy, eNx), dtype=np.complex64)
for acqnum in range(dset.number_of_acquisitions):
acq = dset.read_acquisition(acqnum)
# TODO: Currently ignoring noise scans
if acq.head.flags & ismrmrd.ACQ_IS_NOISE_MEASUREMENT:
continue
rep = acq.head.idx.repetition
contrast = acq.head.idx.contrast
slice = acq.head.idx.slice
y = acq.head.idx.kspace_encode_step_1
z = acq.head.idx.kspace_encode_step_2
all_data[rep, contrast, slice, :, z, y, :] = acq.data
#fig = plt.figure()
#h, w = nreps * ncontrasts, eNz * nslices
#i = 0
#for rep in range(nreps):
# for contrast in range(ncontrasts):
# for slice in range(nslices):
# for z in range(eNz):
# K = all_data[rep,contrast,slice,:,z,:,:]
# comb = np.sqrt(np.squeeze(np.sum(np.abs(K) ** 2, 2)))
# a = fig.add_subplot(h, w, i)
# plt.imshow(comb)
# i += 1
#fig.set_size_inches(16, 16)
images = []
for rep in range(nreps):
for contrast in range(ncontrasts):
for slice in range(nslices):
K = all_data[:,:,:,:,slice, contrast, rep]
K = fftshift(ifft(fftshift(K, axes=0), axis=0), axes=0)
K = all_data[rep,contrast,slice,:,:,:,:]
K = fftshift(ifft(fftshift(K, axes=3), axis=3), axes=3)
# chop if needed
if eNx != rNx:
i0 = (eNx - rNx) / 2
i1 = (eNx - rNx) / 2 + rNx
im = K[i0:i1,:,:,:]
im = K[:,:,:,i0:i1]
else:
im = K
im = fftshift(ifft(fftshift(im, axes=1), axis=1), axes=1)
if np.size(im, 2) > 1:
im = fftshift(ifft(fftshift(im, axes=2), axis=2), axes=2)
im = fftshift(ifft(fftshift(im, axes=2), axis=2), axes=2)
if np.size(im, 1) > 1:
im = fftshift(ifft(fftshift(im, axes=1), axis=1), axes=1)
im = np.squeeze(np.sqrt(np.sum(np.abs(im) ** 2, 3)))
im = np.squeeze(np.sqrt(np.sum(np.abs(im) ** 2, 0)))
images.append(im)
l = len(images)
......@@ -102,24 +109,24 @@ for n, im in enumerate(images):
plt.imshow(im)
fig.set_size_inches(16, 4)
# grab the first acquisition for extra info
acqh = dset.readAcquisition(0).getHead()
for n, img in enumerate(images):
hdr = ismrmrd.ImageHeader()
hdr.acquisition_time_stamp = acqh.acquisition_time_stamp
hdr.flags = 0
hdr.measurement_uid = acqh.measurement_uid
hdr.phase_dir = acqh.phase_dir
hdr.physiology_time_stamp = acqh.physiology_time_stamp
hdr.position = acqh.position
hdr.read_dir = acqh.read_dir
hdr.slice_dir = acqh.slice_dir
hdr.channels = 1
hdr.image_data_type = ismrmrd.DATA_FLOAT
hdr.image_type = ismrmrd.TYPE_MAGNITUDE
hdr.image_index = n
hdr.slice = n
dset.appendImageHeader(hdr, "image_%d.hdr" % n)
dset.appendArray(img, "image_%d.img" % n)
## # grab the first acquisition for extra info
## acqh = dset.read_acquisition(0).head
## for n, img in enumerate(images):
## hdr = ismrmrd.ImageHeader()
## hdr.acquisition_time_stamp = acqh.acquisition_time_stamp
## hdr.flags = 0
## hdr.measurement_uid = acqh.measurement_uid
## hdr.phase_dir = acqh.phase_dir
## hdr.physiology_time_stamp = acqh.physiology_time_stamp
## hdr.position = acqh.position
## hdr.read_dir = acqh.read_dir
## hdr.slice_dir = acqh.slice_dir
## hdr.channels = 1
## hdr.image_data_type = ismrmrd.DATA_FLOAT
## hdr.image_type = ismrmrd.TYPE_MAGNITUDE
## hdr.image_index = n
## hdr.slice = n
## dset.appendImageHeader(hdr, "image_%d.hdr" % n)
## dset.appendArray(img, "image_%d.img" % n)
......@@ -22,12 +22,14 @@
/* Language and cross platform section for defining types */
/* integers */
#ifdef _MSC_VER /* MS compiler */
#ifndef HAS_INT_TYPE
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif
#else /* non MS C or C++ compiler */
#include <stdint.h>
#include <stddef.h> /* for size_t */
......@@ -367,6 +369,7 @@ EXPORTISMRMRD size_t ismrmrd_size_of_ndarray_data(const ISMRMRD_NDArray *arr);
*/
EXPORTISMRMRD bool ismrmrd_is_flag_set(const uint64_t flags, const uint64_t val);
EXPORTISMRMRD int ismrmrd_set_flag(uint64_t *flags, const uint64_t val);
EXPORTISMRMRD int ismrmrd_set_flags(uint64_t *flags, const uint64_t val);
EXPORTISMRMRD int ismrmrd_clear_flag(uint64_t *flags, const uint64_t val);
EXPORTISMRMRD int ismrmrd_clear_all_flags(uint64_t *flags);
/** @} */
......@@ -522,19 +525,20 @@ public:
// Sizes
void resize(uint16_t num_samples, uint16_t active_channels=1, uint16_t trajectory_dimensions=0);
const size_t getNumberOfDataElements();
const size_t getNumberOfTrajElements();
const size_t getDataSize();
const size_t getTrajSize();
size_t getNumberOfDataElements() const;
size_t getNumberOfTrajElements() const;
size_t getDataSize() const;
size_t getTrajSize() const;
// Header, data and trajectory accessors
const AcquisitionHeader &getHead();
void setHead(const AcquisitionHeader other);
const AcquisitionHeader &getHead() const;
void setHead(const AcquisitionHeader &other);
/**
* Returns a pointer to the data
*/
const complex_float_t * const getDataPtr() const ;
const complex_float_t * getDataPtr() const;
complex_float_t * getDataPtr();
/**
* Returns a reference to the data
......@@ -559,7 +563,8 @@ public:
/**
* Returns a pointer to the trajectory
*/
const float * const getTrajPtr() const;
const float * getTrajPtr() const;
float * getTrajPtr();
/**
* Returns a reference to the trajectory
......@@ -587,6 +592,10 @@ public:
void clearFlag(const uint64_t val);
void clearAllFlags();
bool isFlagSet(const FlagBit &val) { return isFlagSet(val.bitmask_); }
void setFlag(const FlagBit &val) { setFlag(val.bitmask_); }
void clearFlag(const FlagBit &val) { clearFlag(val.bitmask_); }
// Channel mask methods
bool isChannelActive(uint16_t channel_id);
void setChannelActive(uint16_t channel_id);
......@@ -742,15 +751,17 @@ public:
// Header
ImageHeader & getHead();
const ImageHeader & getHead() const;
void setHead(const ImageHeader& head);
// Attribute string
void getAttributeString(std::string &atrr) const;
void setAttributeString(const std::string attr);
const size_t getAttributeStringLength();
void setAttributeString(const std::string &attr);
size_t getAttributeStringLength() const;
// Data
T * const getDataPtr() const;
T * getDataPtr();
const T * getDataPtr() const;
/** Returns the number of elements in the image data **/
size_t getNumberOfDataElements() const;
/** Returns the size of the image data in bytes **/
......@@ -781,14 +792,15 @@ public:
NDArray<T> & operator= (const NDArray<T> &other);
// Accessors and mutators
const uint16_t getVersion();
const ISMRMRD_DataTypes getDataType();
const uint16_t getNDim();
uint16_t getVersion() const;
ISMRMRD_DataTypes getDataType() const;
uint16_t getNDim() const;
const size_t (&getDims())[ISMRMRD_NDARRAY_MAXDIM];
const size_t getDataSize();
size_t getDataSize() const;
void resize(const std::vector<size_t> dimvec);
const size_t getNumberOfElements();
size_t getNumberOfElements() const;
T * getDataPtr();
const T * getDataPtr() const;
/** Returns iterator to the beginning of the array **/
T * begin();
......
This diff is collapsed.
......@@ -426,7 +426,7 @@ size_t ismrmrd_size_of_ndarray_data(const ISMRMRD_NDArray *arr) {
}
for (n = 0; n < arr->ndim; n++) {
num_data *= arr->dims[n];
num_data *= (int) (arr->dims[n]);
}
data_size = num_data * ismrmrd_sizeof_data_type(arr->data_type);
......@@ -485,6 +485,14 @@ int ismrmrd_set_flag(uint64_t *flags, const uint64_t val) {
return ISMRMRD_NOERROR;
}
int ismrmrd_set_flags(uint64_t *flags, const uint64_t val) {
if (flags==NULL) {
return ISMRMRD_PUSH_ERR(ISMRMRD_RUNTIMEERROR, "Pointer should not be NULL.");
}
*flags = val;
return ISMRMRD_NOERROR;
}
int ismrmrd_clear_flag(uint64_t *flags, const uint64_t val) {
uint64_t bitmask;
if (flags==NULL) {
......@@ -507,7 +515,7 @@ bool ismrmrd_is_channel_on(const uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS], c
uint64_t bitmask;
size_t offset;
if (channel_mask==NULL) {
ISMRMRD_PUSH_ERR(ISMRMRD_RUNTIMEERROR, "Pointer to channel_mask should not be NULL.");
return ISMRMRD_PUSH_ERR(ISMRMRD_RUNTIMEERROR, "Pointer to channel_mask should not be NULL.");
}
bitmask = 1 << (chan % 64);
offset = chan / 64;
......@@ -585,13 +593,13 @@ void ismrmrd_directions_to_quaternion(float read_dir[3], float phase_dir[3],
/* Compute quaternion parameters */
/* http://www.cs.princeton.edu/~gewang/projects/darth/stuff/quat_faq.html#Q55 */
trace = 1.0l + r11 + r22 + r33;
if (trace > 0.00001l) { /* simplest case */
trace = 1.0 + r11 + r22 + r33;
if (trace > 0.00001) { /* simplest case */
s = sqrt(trace) * 2;
a = (r32 - r23) / s;
b = (r13 - r31) / s;
c = (r21 - r12) / s;
d = 0.25l * s;
d = 0.25 * s;
} else {
/* trickier case...
* determine which major diagonal element has
......@@ -602,7 +610,7 @@ void ismrmrd_directions_to_quaternion(float read_dir[3], float phase_dir[3],
/* if r11 is the greatest */
if (xd > 1.0) {
s = 2.0 * sqrt(xd);
a = 0.25l * s;
a = 0.25 * s;
b = (r21 + r12) / s;
c = (r31 + r13) / s;
d = (r32 - r23) / s;
......@@ -611,7 +619,7 @@ void ismrmrd_directions_to_quaternion(float read_dir[3], float phase_dir[3],
else if (yd > 1.0) {
s = 2.0 * sqrt(yd);
a = (r21 + r12) / s;
b = 0.25l * s;
b = 0.25 * s;
c = (r32 + r23) / s;
d = (r13 - r31) / s;
}
......@@ -620,11 +628,11 @@ void ismrmrd_directions_to_quaternion(float read_dir[3], float phase_dir[3],
s = 2.0 * sqrt(zd);
a = (r13 + r31) / s;
b = (r23 + r32) / s;
c = 0.25l * s;
c = 0.25 * s;
d = (r21 - r12) / s;
}
if (a < 0.0l) {
if (a < 0.0) {
b = -b;
c = -c;
d = -d;
......
......@@ -3,6 +3,7 @@
#include <sstream>
#include <stdexcept>
#include <iostream>
#include "ismrmrd/ismrmrd.h"
namespace ISMRMRD {
......@@ -201,33 +202,33 @@ float (&Acquisition::user_float()) [ISMRMRD_USER_FLOATS] {
}
// Sizes
const size_t Acquisition::getNumberOfDataElements() {
size_t Acquisition::getNumberOfDataElements() const {
size_t num = acq.head.number_of_samples * acq.head.active_channels;
return num;
}
const size_t Acquisition::getDataSize() {
size_t Acquisition::getDataSize() const {
size_t num = acq.head.number_of_samples * acq.head.active_channels;
return num*sizeof(complex_float_t);
}
const size_t Acquisition::getNumberOfTrajElements() {
size_t Acquisition::getNumberOfTrajElements() const {
size_t num = acq.head.number_of_samples * acq.head.trajectory_dimensions;
return num;
}
const size_t Acquisition::getTrajSize() {
size_t Acquisition::getTrajSize() const {
size_t num = acq.head.number_of_samples * acq.head.trajectory_dimensions;
return num*sizeof(float);
}
// Data and Trajectory accessors
const AcquisitionHeader & Acquisition::getHead() {
const AcquisitionHeader & Acquisition::getHead() const {
// This returns a reference
return *static_cast<AcquisitionHeader *>(&acq.head);
return *static_cast<const AcquisitionHeader *>(&acq.head);
}
void Acquisition::setHead(const AcquisitionHeader other) {
void Acquisition::setHead(const AcquisitionHeader &other) {
memcpy(&acq.head, &other, sizeof(AcquisitionHeader));
if (ismrmrd_make_consistent_acquisition(&acq) != ISMRMRD_NOERROR) {
throw std::runtime_error(build_exception_string());
......@@ -243,7 +244,11 @@ void Acquisition::resize(uint16_t num_samples, uint16_t active_channels, uint16_
}
}
const complex_float_t * const Acquisition::getDataPtr() const {
const complex_float_t * Acquisition::getDataPtr() const {
return acq.data;
}
complex_float_t * Acquisition::getDataPtr() {
return acq.data;
}
......@@ -256,7 +261,11 @@ complex_float_t & Acquisition::data(uint16_t sample, uint16_t channel){
return acq.data[index];
}
const float * const Acquisition::getTrajPtr() const {
const float * Acquisition::getTrajPtr() const {
return acq.traj;
}
float * Acquisition::getTrajPtr() {
return acq.traj;
}
......@@ -355,7 +364,7 @@ template <typename T> Image<T>::Image(uint16_t matrix_size_x,
if (ismrmrd_init_image(&im) != ISMRMRD_NOERROR) {
throw std::runtime_error(build_exception_string());
}
im.head.data_type = get_data_type<T>();
im.head.data_type = static_cast<uint16_t>(get_data_type<T>());
resize(matrix_size_x, matrix_size_y, matrix_size_z, channels);
}
......@@ -879,6 +888,10 @@ template <typename T> void Image<T>::setFlag(const uint64_t val) {
ismrmrd_set_flag(&(im.head.flags), val);
}
template <typename T> void Image<T>::setFlags(const uint64_t val) {
ismrmrd_set_flags(&(im.head.flags), val);
}
template <typename T> void Image<T>::clearFlag(const uint64_t val) {
ismrmrd_clear_flag(&(im.head.flags), val);
}
......@@ -893,6 +906,11 @@ template <typename T> ImageHeader &Image<T>::getHead() {
return *static_cast<ImageHeader *>(&im.head);
}
template <typename T> const ImageHeader &Image<T>::getHead() const {
// This returns a reference
return *static_cast<const ImageHeader *>(&im.head);
}
template <typename T> void Image<T>::setHead(const ImageHeader &other) {
if (other.data_type != im.head.data_type) {
throw std::runtime_error("Cannot assign a header of a different data type.");
......@@ -907,34 +925,48 @@ template <typename T> void Image<T>::setHead(const ImageHeader &other) {
// Attribute string
template <typename T> void Image<T>::getAttributeString(std::string &attr) const
{
attr = std::string(im.attribute_string);
if (im.attribute_string)
attr.assign(im.attribute_string);
else
attr.assign("");
}
template <typename T> void Image<T>::setAttributeString(const std::string attr)
template <typename T> void Image<T>::setAttributeString(const std::string &attr)
{
im.head.attribute_string_len = attr.length();
im.attribute_string = (char *)realloc(im.attribute_string, attr.length()+1);
// TODO error check?
strcpy(im.attribute_string, attr.c_str());
size_t length = attr.length();
im.head.attribute_string_len = static_cast<uint32_t>(length);
// Add null terminating character
length++;
im.attribute_string = (char *)realloc(im.attribute_string, length);
if (NULL==im.attribute_string) {
throw std::runtime_error(build_exception_string());
}
strncpy(im.attribute_string, attr.c_str(), length);
}
template <typename T> const size_t Image<T>::getAttributeStringLength()
template <typename T> size_t Image<T>::getAttributeStringLength() const
{
return im.head.attribute_string_len;
}
// Data
template <typename T> T * const Image<T>::getDataPtr() const {
template <typename T> T * Image<T>::getDataPtr() {
return static_cast<T*>(im.data);
}
template <typename T> const T * Image<T>::getDataPtr() const {
return static_cast<const T*>(im.data);
}
template <typename T> size_t Image<T>::getNumberOfDataElements() const {
size_t num = 1;
num *= im.head.matrix_size[0];
num *= im.head.matrix_size[1];
num *= im.head.matrix_size[2];
num *= im.head.channels;
return ismrmrd_size_of_image_data(&im);
return num;
}
template <typename T> size_t Image<T>::getDataSize() const {
......@@ -965,7 +997,7 @@ template <typename T> NDArray<T>::NDArray()
if (ismrmrd_init_ndarray(&arr) != ISMRMRD_NOERROR) {
throw std::runtime_error(build_exception_string());
}
arr.data_type = get_data_type<T>();
arr.data_type = static_cast<uint16_t>(get_data_type<T>());
}
template <typename T> NDArray<T>::NDArray(const std::vector<size_t> dimvec)
......@@ -973,7 +1005,7 @@ template <typename T> NDArray<T>::NDArray(const std::vector<size_t> dimvec)
if (ismrmrd_init_ndarray(&arr) != ISMRMRD_NOERROR) {
throw std::runtime_error(build_exception_string());
}
arr.data_type = get_data_type<T>();
arr.data_type = static_cast<uint16_t>(get_data_type<T>());
resize(dimvec);
}
......@@ -1015,15 +1047,15 @@ template <typename T> NDArray<T> & NDArray<T>::operator= (const NDArray<T> &othe
return *this;
}
template <typename T> const uint16_t NDArray<T>::getVersion() {
template <typename T> uint16_t NDArray<T>::getVersion() const {
return arr.version;
};
template <typename T> const ISMRMRD_DataTypes NDArray<T>::getDataType() {
template <typename T> ISMRMRD_DataTypes NDArray<T>::getDataType() const {
return static_cast<ISMRMRD_DataTypes>( arr.data_type );
}
template <typename T> const uint16_t NDArray<T>::getNDim() {
template <typename T> uint16_t NDArray<T>::