26 typedef __int16 int16_t;
27 typedef unsigned __int16 uint16_t;
28 typedef __int32 int32_t;
29 typedef unsigned __int32 uint32_t;
30 typedef __int64 int64_t;
31 typedef unsigned __int64 uint64_t;
41 typedef std::complex<float> complex_float_t;
42 typedef std::complex<double> complex_double_t;
45 typedef struct complex_float_t{
49 typedef struct complex_double_t{
55 typedef float complex complex_float_t;
56 typedef double complex complex_double_t;
62 #if defined (_MSC_VER) && (_MSC_VER < 1800)
77 #include "ismrmrd/export.h"
90 ISMRMRD_USER_INTS = 8,
91 ISMRMRD_USER_FLOATS = 8,
92 ISMRMRD_PHYS_STAMPS = 3,
93 ISMRMRD_CHANNEL_MASKS = 16,
94 ISMRMRD_NDARRAY_MAXDIM = 7,
95 ISMRMRD_POSITION_LENGTH = 3,
96 ISMRMRD_DIRECTION_LENGTH = 3
104 ISMRMRD_BEGINERROR=-1,
109 ISMRMRD_RUNTIMEERROR,
135 ISMRMRD_ACQ_FIRST_IN_ENCODE_STEP1 = 1,
136 ISMRMRD_ACQ_LAST_IN_ENCODE_STEP1 = 2,
137 ISMRMRD_ACQ_FIRST_IN_ENCODE_STEP2 = 3,
138 ISMRMRD_ACQ_LAST_IN_ENCODE_STEP2 = 4,
139 ISMRMRD_ACQ_FIRST_IN_AVERAGE = 5,
140 ISMRMRD_ACQ_LAST_IN_AVERAGE = 6,
141 ISMRMRD_ACQ_FIRST_IN_SLICE = 7,
142 ISMRMRD_ACQ_LAST_IN_SLICE = 8,
143 ISMRMRD_ACQ_FIRST_IN_CONTRAST = 9,
144 ISMRMRD_ACQ_LAST_IN_CONTRAST = 10,
145 ISMRMRD_ACQ_FIRST_IN_PHASE = 11,
146 ISMRMRD_ACQ_LAST_IN_PHASE = 12,
147 ISMRMRD_ACQ_FIRST_IN_REPETITION = 13,
148 ISMRMRD_ACQ_LAST_IN_REPETITION = 14,
149 ISMRMRD_ACQ_FIRST_IN_SET = 15,
150 ISMRMRD_ACQ_LAST_IN_SET = 16,
151 ISMRMRD_ACQ_FIRST_IN_SEGMENT = 17,
152 ISMRMRD_ACQ_LAST_IN_SEGMENT = 18,
153 ISMRMRD_ACQ_IS_NOISE_MEASUREMENT = 19,
154 ISMRMRD_ACQ_IS_PARALLEL_CALIBRATION = 20,
155 ISMRMRD_ACQ_IS_PARALLEL_CALIBRATION_AND_IMAGING = 21,
156 ISMRMRD_ACQ_IS_REVERSE = 22,
157 ISMRMRD_ACQ_IS_NAVIGATION_DATA = 23,
158 ISMRMRD_ACQ_IS_PHASECORR_DATA = 24,
159 ISMRMRD_ACQ_LAST_IN_MEASUREMENT = 25,
160 ISMRMRD_ACQ_IS_HPFEEDBACK_DATA = 26,
161 ISMRMRD_ACQ_IS_DUMMYSCAN_DATA = 27,
162 ISMRMRD_ACQ_IS_RTFEEDBACK_DATA = 28,
163 ISMRMRD_ACQ_IS_SURFACECOILCORRECTIONSCAN_DATA = 29,
166 ISMRMRD_ACQ_COMPRESSION1 = 53,
167 ISMRMRD_ACQ_COMPRESSION2 = 54,
168 ISMRMRD_ACQ_COMPRESSION3 = 55,
169 ISMRMRD_ACQ_COMPRESSION4 = 56,
170 ISMRMRD_ACQ_USER1 = 57,
171 ISMRMRD_ACQ_USER2 = 58,
172 ISMRMRD_ACQ_USER3 = 59,
173 ISMRMRD_ACQ_USER4 = 60,
174 ISMRMRD_ACQ_USER5 = 61,
175 ISMRMRD_ACQ_USER6 = 62,
176 ISMRMRD_ACQ_USER7 = 63,
177 ISMRMRD_ACQ_USER8 = 64
184 ISMRMRD_IMTYPE_MAGNITUDE = 1,
185 ISMRMRD_IMTYPE_PHASE = 2,
186 ISMRMRD_IMTYPE_REAL = 3,
187 ISMRMRD_IMTYPE_IMAG = 4,
188 ISMRMRD_IMTYPE_COMPLEX = 5
195 ISMRMRD_IMAGE_IS_NAVIGATION_DATA = 1,
196 ISMRMRD_IMAGE_USER1 = 57,
197 ISMRMRD_IMAGE_USER2 = 58,
198 ISMRMRD_IMAGE_USER3 = 59,
199 ISMRMRD_IMAGE_USER4 = 60,
200 ISMRMRD_IMAGE_USER5 = 61,
201 ISMRMRD_IMAGE_USER6 = 62,
202 ISMRMRD_IMAGE_USER7 = 63,
203 ISMRMRD_IMAGE_USER8 = 64
219 uint16_t
user[ISMRMRD_USER_INTS];
263 complex_float_t *data;
324 char *attribute_string;
337 EXPORTISMRMRD
int ismrmrd_make_consistent_image(
ISMRMRD_Image *im);
338 EXPORTISMRMRD
size_t ismrmrd_size_of_image_attribute_string(
const ISMRMRD_Image *im);
339 EXPORTISMRMRD
size_t ismrmrd_size_of_image_data(
const ISMRMRD_Image *im);
353 size_t dims[ISMRMRD_NDARRAY_MAXDIM];
365 EXPORTISMRMRD
int ismrmrd_make_consistent_ndarray(
ISMRMRD_NDArray *arr);
366 EXPORTISMRMRD
size_t ismrmrd_size_of_ndarray_data(
const ISMRMRD_NDArray *arr);
375 EXPORTISMRMRD
bool ismrmrd_is_flag_set(
const uint64_t flags,
const uint64_t val);
376 EXPORTISMRMRD
int ismrmrd_set_flag(uint64_t *flags,
const uint64_t val);
377 EXPORTISMRMRD
int ismrmrd_set_flags(uint64_t *flags,
const uint64_t val);
378 EXPORTISMRMRD
int ismrmrd_clear_flag(uint64_t *flags,
const uint64_t val);
379 EXPORTISMRMRD
int ismrmrd_clear_all_flags(uint64_t *flags);
388 EXPORTISMRMRD
bool ismrmrd_is_channel_on(
const uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS],
const uint16_t chan);
389 EXPORTISMRMRD
int ismrmrd_set_channel_on(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS],
const uint16_t chan);
390 EXPORTISMRMRD
int ismrmrd_set_channel_off(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS],
const uint16_t chan);
391 EXPORTISMRMRD
int ismrmrd_set_all_channels_off(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS]);
400 typedef void (*ismrmrd_error_handler_t)(
const char *file,
int line,
401 const char *
function,
int code,
const char *msg);
402 #define ISMRMRD_PUSH_ERR(code, msg) ismrmrd_push_error(__FILE__, __LINE__, \
403 __func__, (code), (msg))
405 const int code,
const char *msg);
415 int *code,
char **msg);
466 bitmask_ = (bitmask_ << (b-1));
470 bool isSet(
const uint64_t& m)
const {
471 return ((m & bitmask_)>0);
491 void clearAllFlags();
494 bool isChannelActive(uint16_t channel_id)
const;
495 void setChannelActive(uint16_t channel_id);
496 void setChannelNotActive(uint16_t channel_id);
497 void setAllChannelsNotActive();
507 Acquisition(uint16_t num_samples, uint16_t active_channels=1, uint16_t trajectory_dimensions=0);
513 const uint16_t &version();
514 const uint64_t &flags();
515 uint32_t &measurement_uid();
516 uint32_t &scan_counter();
517 uint32_t &acquisition_time_stamp();
518 uint32_t (&physiology_time_stamp())[ISMRMRD_PHYS_STAMPS];
519 const uint16_t &number_of_samples();
520 uint16_t &available_channels();
521 const uint16_t &active_channels();
522 const uint64_t (&channel_mask())[ISMRMRD_CHANNEL_MASKS];
523 uint16_t &discard_pre();
524 uint16_t &discard_post();
525 uint16_t ¢er_sample();
526 uint16_t &encoding_space_ref();
527 const uint16_t &trajectory_dimensions();
528 float &sample_time_us();
529 float (&position())[3];
530 float (&read_dir())[3];
531 float (&phase_dir())[3];
532 float (&slice_dir())[3];
533 float (&patient_table_position())[3];
535 int32_t (&user_int())[ISMRMRD_USER_INTS];
536 float (&user_float())[ISMRMRD_USER_FLOATS];
539 void resize(uint16_t num_samples, uint16_t active_channels=1, uint16_t trajectory_dimensions=0);
540 size_t getNumberOfDataElements()
const;
541 size_t getNumberOfTrajElements()
const;
542 size_t getDataSize()
const;
543 size_t getTrajSize()
const;
552 const complex_float_t * getDataPtr()
const;
553 complex_float_t * getDataPtr();
558 complex_float_t & data(uint16_t sample, uint16_t channel);
563 void setData(complex_float_t * data);
568 complex_float_t * data_begin()
const;
573 complex_float_t * data_end()
const;
578 const float * getTrajPtr()
const;
579 float * getTrajPtr();
584 float & traj(uint16_t dimension, uint16_t sample);
589 void setTraj(
float * traj);
594 float * traj_begin()
const;
599 float * traj_end()
const;
602 bool isFlagSet(
const uint64_t val);
603 void setFlag(
const uint64_t val);
604 void clearFlag(
const uint64_t val);
605 void clearAllFlags();
607 bool isFlagSet(
const FlagBit &val) {
return isFlagSet(val.bitmask_); }
608 void setFlag(
const FlagBit &val) { setFlag(val.bitmask_); }
609 void clearFlag(
const FlagBit &val) { clearFlag(val.bitmask_); }
612 bool isChannelActive(uint16_t channel_id);
613 void setChannelActive(uint16_t channel_id);
614 void setChannelNotActive(uint16_t channel_id);
615 void setAllChannelsNotActive();
628 bool isFlagSet(
const uint64_t val);
629 void setFlag(
const uint64_t val);
630 void clearFlag(
const uint64_t val);
631 void clearAllFlags();
636 template <
typename T>
class EXPORTISMRMRD
Image {
640 Image(uint16_t matrix_size_x = 0, uint16_t matrix_size_y = 1,
641 uint16_t matrix_size_z = 1, uint16_t channels = 1);
647 void resize(uint16_t matrix_size_x, uint16_t matrix_size_y, uint16_t matrix_size_z, uint16_t channels);
648 uint16_t getMatrixSizeX()
const;
649 void setMatrixSizeX(uint16_t matrix_size_x);
650 uint16_t getMatrixSizeY()
const;
651 void setMatrixSizeY(uint16_t matrix_size_y);
652 uint16_t getMatrixSizeZ()
const;
653 void setMatrixSizeZ(uint16_t matrix_size_z);
654 uint16_t getNumberOfChannels()
const;
655 void setNumberOfChannels(uint16_t channels);
658 void setFieldOfView(
float fov_x,
float fov_y,
float fov_z);
659 float getFieldOfViewX()
const;
660 void setFieldOfViewX(
float f);
661 float getFieldOfViewY()
const;
662 void setFieldOfViewY(
float f);
663 float getFieldOfViewZ()
const;
664 void setFieldOfViewZ(
float f);
667 void setPosition(
float x,
float y,
float z);
668 float getPositionX()
const;
669 void setPositionX(
float x);
670 float getPositionY()
const;
671 void setPositionY(
float y);
672 float getPositionZ()
const;
673 void setPositionZ(
float z);
675 void setReadDirection(
float x,
float y,
float z);
676 float getReadDirectionX()
const;
677 void setReadDirectionX(
float x);
678 float getReadDirectionY()
const;
679 void setReadDirectionY(
float y);
680 float getReadDirectionZ()
const;
681 void setReadDirectionZ(
float z);
683 void setPhaseDirection(
float x,
float y,
float z);
684 float getPhaseDirectionX()
const;
685 void setPhaseDirectionX(
float x);
686 float getPhaseDirectionY()
const;
687 void setPhaseDirectionY(
float y);
688 float getPhaseDirectionZ()
const;
689 void setPhaseDirectionZ(
float z);
691 void setSliceDirection(
float x,
float y,
float z);
692 float getSliceDirectionX()
const;
693 void setSliceDirectionX(
float x);
694 float getSliceDirectionY()
const;
695 void setSliceDirectionY(
float y);
696 float getSliceDirectionZ()
const;
697 void setSliceDirectionZ(
float z);
699 void setPatientTablePosition(
float x,
float y,
float z);
700 float getPatientTablePositionX()
const;
701 void setPatientTablePositionX(
float x);
702 float getPatientTablePositionY()
const;
703 void setPatientTablePositionY(
float y);
704 float getPatientTablePositionZ()
const;
705 void setPatientTablePositionZ(
float z);
709 uint16_t getVersion()
const;
713 uint32_t getMeasurementUid()
const;
714 void setMeasurementUid(uint32_t measurement_uid);
716 uint16_t getAverage()
const;
717 void setAverage(uint16_t average);
719 uint16_t getSlice()
const;
720 void setSlice(uint16_t slice);
722 uint16_t getContrast()
const;
723 void setContrast(uint16_t contrast);
725 uint16_t getPhase()
const;
726 void setPhase(uint16_t phase);
728 uint16_t getRepetition()
const;
729 void setRepetition(uint16_t repetition);
731 uint16_t getSet()
const;
732 void setSet(uint16_t set);
734 uint32_t getAcquisitionTimeStamp()
const;
735 void setAcquisitionTimeStamp(uint32_t acquisition_time_stamp);
737 uint32_t getPhysiologyTimeStamp(
unsigned int stamp_id)
const;
738 void setPhysiologyTimeStamp(
unsigned int stamp_id, uint32_t value);
740 uint16_t getImageType()
const;
741 void setImageType(uint16_t image_type);
743 uint16_t getImageIndex()
const;
744 void setImageIndex(uint16_t image_index);
746 uint16_t getImageSeriesIndex()
const;
747 void setImageSeriesIndex(uint16_t image_series_index);
750 float getUserFloat(
unsigned int index)
const;
751 void setUserFloat(
unsigned int index,
float value);
753 int32_t getUserInt(
unsigned int index)
const;
754 void setUserInt(
unsigned int index, int32_t value);
757 uint64_t getFlags()
const;
758 void setFlags(
const uint64_t flags);
759 bool isFlagSet(
const uint64_t val)
const;
760 void setFlag(
const uint64_t val);
761 void clearFlag(
const uint64_t val);
762 void clearAllFlags();
770 void getAttributeString(std::string &attr)
const;
771 const char *getAttributeString()
const;
772 void setAttributeString(
const std::string &attr);
773 void setAttributeString(
const char *attr);
774 size_t getAttributeStringLength()
const;
778 const T * getDataPtr()
const;
780 size_t getNumberOfDataElements()
const;
782 size_t getDataSize()
const;
791 T & operator () (uint16_t x, uint16_t y=0, uint16_t z=0 , uint16_t channel =0);
798 template <
typename T>
class EXPORTISMRMRD
NDArray {
803 NDArray(
const std::vector<size_t> dimvec);
809 uint16_t getVersion()
const;
811 uint16_t getNDim()
const;
812 const size_t (&getDims())[ISMRMRD_NDARRAY_MAXDIM];
813 size_t getDataSize()
const;
814 void resize(
const std::vector<size_t> dimvec);
815 size_t getNumberOfElements()
const;
817 const T * getDataPtr()
const;
826 T & operator () (uint16_t x, uint16_t y=0, uint16_t z=0, uint16_t w=0, uint16_t n=0, uint16_t m=0, uint16_t l=0);