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,
165 ISMRMRD_ACQ_COMPRESSION1 = 53,
166 ISMRMRD_ACQ_COMPRESSION2 = 54,
167 ISMRMRD_ACQ_COMPRESSION3 = 55,
168 ISMRMRD_ACQ_COMPRESSION4 = 56,
169 ISMRMRD_ACQ_USER1 = 57,
170 ISMRMRD_ACQ_USER2 = 58,
171 ISMRMRD_ACQ_USER3 = 59,
172 ISMRMRD_ACQ_USER4 = 60,
173 ISMRMRD_ACQ_USER5 = 61,
174 ISMRMRD_ACQ_USER6 = 62,
175 ISMRMRD_ACQ_USER7 = 63,
176 ISMRMRD_ACQ_USER8 = 64
183 ISMRMRD_IMTYPE_MAGNITUDE = 1,
184 ISMRMRD_IMTYPE_PHASE = 2,
185 ISMRMRD_IMTYPE_REAL = 3,
186 ISMRMRD_IMTYPE_IMAG = 4,
187 ISMRMRD_IMTYPE_COMPLEX = 5
194 ISMRMRD_IMAGE_IS_NAVIGATION_DATA = 1,
195 ISMRMRD_IMAGE_USER1 = 57,
196 ISMRMRD_IMAGE_USER2 = 58,
197 ISMRMRD_IMAGE_USER3 = 59,
198 ISMRMRD_IMAGE_USER4 = 60,
199 ISMRMRD_IMAGE_USER5 = 61,
200 ISMRMRD_IMAGE_USER6 = 62,
201 ISMRMRD_IMAGE_USER7 = 63,
202 ISMRMRD_IMAGE_USER8 = 64
218 uint16_t
user[ISMRMRD_USER_INTS];
262 complex_float_t *data;
323 char *attribute_string;
336 EXPORTISMRMRD
int ismrmrd_make_consistent_image(
ISMRMRD_Image *im);
337 EXPORTISMRMRD
size_t ismrmrd_size_of_image_attribute_string(
const ISMRMRD_Image *im);
338 EXPORTISMRMRD
size_t ismrmrd_size_of_image_data(
const ISMRMRD_Image *im);
352 size_t dims[ISMRMRD_NDARRAY_MAXDIM];
364 EXPORTISMRMRD
int ismrmrd_make_consistent_ndarray(
ISMRMRD_NDArray *arr);
365 EXPORTISMRMRD
size_t ismrmrd_size_of_ndarray_data(
const ISMRMRD_NDArray *arr);
374 EXPORTISMRMRD
bool ismrmrd_is_flag_set(
const uint64_t flags,
const uint64_t val);
375 EXPORTISMRMRD
int ismrmrd_set_flag(uint64_t *flags,
const uint64_t val);
376 EXPORTISMRMRD
int ismrmrd_set_flags(uint64_t *flags,
const uint64_t val);
377 EXPORTISMRMRD
int ismrmrd_clear_flag(uint64_t *flags,
const uint64_t val);
378 EXPORTISMRMRD
int ismrmrd_clear_all_flags(uint64_t *flags);
387 EXPORTISMRMRD
bool ismrmrd_is_channel_on(
const uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS],
const uint16_t chan);
388 EXPORTISMRMRD
int ismrmrd_set_channel_on(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS],
const uint16_t chan);
389 EXPORTISMRMRD
int ismrmrd_set_channel_off(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS],
const uint16_t chan);
390 EXPORTISMRMRD
int ismrmrd_set_all_channels_off(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS]);
399 typedef void (*ismrmrd_error_handler_t)(
const char *file,
int line,
400 const char *
function,
int code,
const char *msg);
401 #define ISMRMRD_PUSH_ERR(code, msg) ismrmrd_push_error(__FILE__, __LINE__, \
402 __func__, (code), (msg))
404 const int code,
const char *msg);
414 int *code,
char **msg);
461 bitmask_ = (bitmask_ << (b-1));
465 bool isSet(
const uint64_t& m)
const {
466 return ((m & bitmask_)>0);
483 void clearAllFlags();
486 bool isChannelActive(uint16_t channel_id);
487 void setChannelActive(uint16_t channel_id);
488 void setChannelNotActive(uint16_t channel_id);
489 void setAllChannelsNotActive();
499 Acquisition(uint16_t num_samples, uint16_t active_channels=1, uint16_t trajectory_dimensions=0);
505 const uint16_t &version();
506 const uint64_t &flags();
507 uint32_t &measurement_uid();
508 uint32_t &scan_counter();
509 uint32_t &acquisition_time_stamp();
510 uint32_t (&physiology_time_stamp())[ISMRMRD_PHYS_STAMPS];
511 const uint16_t &number_of_samples();
512 uint16_t &available_channels();
513 const uint16_t &active_channels();
514 const uint64_t (&channel_mask())[ISMRMRD_CHANNEL_MASKS];
515 uint16_t &discard_pre();
516 uint16_t &discard_post();
517 uint16_t ¢er_sample();
518 uint16_t &encoding_space_ref();
519 const uint16_t &trajectory_dimensions();
520 float &sample_time_us();
521 float (&position())[3];
522 float (&read_dir())[3];
523 float (&phase_dir())[3];
524 float (&slice_dir())[3];
525 float (&patient_table_position())[3];
527 int32_t (&user_int())[ISMRMRD_USER_INTS];
528 float (&user_float())[ISMRMRD_USER_FLOATS];
531 void resize(uint16_t num_samples, uint16_t active_channels=1, uint16_t trajectory_dimensions=0);
532 size_t getNumberOfDataElements()
const;
533 size_t getNumberOfTrajElements()
const;
534 size_t getDataSize()
const;
535 size_t getTrajSize()
const;
544 const complex_float_t * getDataPtr()
const;
545 complex_float_t * getDataPtr();
550 complex_float_t & data(uint16_t sample, uint16_t channel);
555 void setData(complex_float_t * data);
560 complex_float_t * data_begin()
const;
565 complex_float_t * data_end()
const;
570 const float * getTrajPtr()
const;
571 float * getTrajPtr();
576 float & traj(uint16_t dimension, uint16_t sample);
581 void setTraj(
float * traj);
586 float * traj_begin()
const;
591 float * traj_end()
const;
594 bool isFlagSet(
const uint64_t val);
595 void setFlag(
const uint64_t val);
596 void clearFlag(
const uint64_t val);
597 void clearAllFlags();
599 bool isFlagSet(
const FlagBit &val) {
return isFlagSet(val.bitmask_); }
600 void setFlag(
const FlagBit &val) { setFlag(val.bitmask_); }
601 void clearFlag(
const FlagBit &val) { clearFlag(val.bitmask_); }
604 bool isChannelActive(uint16_t channel_id);
605 void setChannelActive(uint16_t channel_id);
606 void setChannelNotActive(uint16_t channel_id);
607 void setAllChannelsNotActive();
620 bool isFlagSet(
const uint64_t val);
621 void setFlag(
const uint64_t val);
622 void clearFlag(
const uint64_t val);
623 void clearAllFlags();
628 template <
typename T>
class EXPORTISMRMRD
Image {
632 Image(uint16_t matrix_size_x = 0, uint16_t matrix_size_y = 1,
633 uint16_t matrix_size_z = 1, uint16_t channels = 1);
639 void resize(uint16_t matrix_size_x, uint16_t matrix_size_y, uint16_t matrix_size_z, uint16_t channels);
640 uint16_t getMatrixSizeX()
const;
641 void setMatrixSizeX(uint16_t matrix_size_x);
642 uint16_t getMatrixSizeY()
const;
643 void setMatrixSizeY(uint16_t matrix_size_y);
644 uint16_t getMatrixSizeZ()
const;
645 void setMatrixSizeZ(uint16_t matrix_size_z);
646 uint16_t getNumberOfChannels()
const;
647 void setNumberOfChannels(uint16_t channels);
650 void setFieldOfView(
float fov_x,
float fov_y,
float fov_z);
651 float getFieldOfViewX()
const;
652 void setFieldOfViewX(
float f);
653 float getFieldOfViewY()
const;
654 void setFieldOfViewY(
float f);
655 float getFieldOfViewZ()
const;
656 void setFieldOfViewZ(
float f);
659 void setPosition(
float x,
float y,
float z);
660 float getPositionX()
const;
661 void setPositionX(
float x);
662 float getPositionY()
const;
663 void setPositionY(
float y);
664 float getPositionZ()
const;
665 void setPositionZ(
float z);
667 void setReadDirection(
float x,
float y,
float z);
668 float getReadDirectionX()
const;
669 void setReadDirectionX(
float x);
670 float getReadDirectionY()
const;
671 void setReadDirectionY(
float y);
672 float getReadDirectionZ()
const;
673 void setReadDirectionZ(
float z);
675 void setPhaseDirection(
float x,
float y,
float z);
676 float getPhaseDirectionX()
const;
677 void setPhaseDirectionX(
float x);
678 float getPhaseDirectionY()
const;
679 void setPhaseDirectionY(
float y);
680 float getPhaseDirectionZ()
const;
681 void setPhaseDirectionZ(
float z);
683 void setSliceDirection(
float x,
float y,
float z);
684 float getSliceDirectionX()
const;
685 void setSliceDirectionX(
float x);
686 float getSliceDirectionY()
const;
687 void setSliceDirectionY(
float y);
688 float getSliceDirectionZ()
const;
689 void setSliceDirectionZ(
float z);
691 void setPatientTablePosition(
float x,
float y,
float z);
692 float getPatientTablePositionX()
const;
693 void setPatientTablePositionX(
float x);
694 float getPatientTablePositionY()
const;
695 void setPatientTablePositionY(
float y);
696 float getPatientTablePositionZ()
const;
697 void setPatientTablePositionZ(
float z);
701 uint16_t getVersion()
const;
705 uint32_t getMeasurementUid()
const;
706 void setMeasurementUid(uint32_t measurement_uid);
708 uint16_t getAverage()
const;
709 void setAverage(uint16_t average);
711 uint16_t getSlice()
const;
712 void setSlice(uint16_t slice);
714 uint16_t getContrast()
const;
715 void setContrast(uint16_t contrast);
717 uint16_t getPhase()
const;
718 void setPhase(uint16_t phase);
720 uint16_t getRepetition()
const;
721 void setRepetition(uint16_t repetition);
723 uint16_t getSet()
const;
724 void setSet(uint16_t set);
726 uint32_t getAcquisitionTimeStamp()
const;
727 void setAcquisitionTimeStamp(uint32_t acquisition_time_stamp);
729 uint32_t getPhysiologyTimeStamp(
unsigned int stamp_id)
const;
730 void setPhysiologyTimeStamp(
unsigned int stamp_id, uint32_t value);
732 uint16_t getImageType()
const;
733 void setImageType(uint16_t image_type);
735 uint16_t getImageIndex()
const;
736 void setImageIndex(uint16_t image_index);
738 uint16_t getImageSeriesIndex()
const;
739 void setImageSeriesIndex(uint16_t image_series_index);
742 float getUserFloat(
unsigned int index)
const;
743 void setUserFloat(
unsigned int index,
float value);
745 int32_t getUserInt(
unsigned int index)
const;
746 void setUserInt(
unsigned int index, int32_t value);
749 uint64_t getFlags()
const;
750 void setFlags(
const uint64_t flags);
751 bool isFlagSet(
const uint64_t val)
const;
752 void setFlag(
const uint64_t val);
753 void clearFlag(
const uint64_t val);
754 void clearAllFlags();
762 void getAttributeString(std::string &attr)
const;
763 const char *getAttributeString()
const;
764 void setAttributeString(
const std::string &attr);
765 void setAttributeString(
const char *attr);
766 size_t getAttributeStringLength()
const;
770 const T * getDataPtr()
const;
772 size_t getNumberOfDataElements()
const;
774 size_t getDataSize()
const;
783 T & operator () (uint16_t x, uint16_t y=0, uint16_t z=0 , uint16_t channel =0);
790 template <
typename T>
class EXPORTISMRMRD
NDArray {
795 NDArray(
const std::vector<size_t> dimvec);
801 uint16_t getVersion()
const;
803 uint16_t getNDim()
const;
804 const size_t (&getDims())[ISMRMRD_NDARRAY_MAXDIM];
805 size_t getDataSize()
const;
806 void resize(
const std::vector<size_t> dimvec);
807 size_t getNumberOfElements()
const;
809 const T * getDataPtr()
const;
818 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);