[ismrmrd] 169/177: Added channel mask stuff to c-api.
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:02:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag v1.1.0.beta.1
in repository ismrmrd.
commit 49dcd11463c13a16e4c0de0b0735a557e7a7e7e8
Author: Souheil Inati <souheil.inati at nih.gov>
Date: Tue Nov 4 12:43:38 2014 -0500
Added channel mask stuff to c-api.
---
examples/c/main.c | 9 +++++++++
include/ismrmrd/ismrmrd.h | 12 +++++++++++-
libsrc/ismrmrd.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/examples/c/main.c b/examples/c/main.c
index 9a5e5b9..892bdf2 100644
--- a/examples/c/main.c
+++ b/examples/c/main.c
@@ -54,6 +54,10 @@ int main(void)
ismrmrd_init_acquisition(&acq);
acq.head.number_of_samples = 128;
acq.head.active_channels = 4;
+ ismrmrd_clear_all_channels(acq.head.channel_mask);
+ for (k=0; k<acq.head.active_channels; k++) {
+ ismrmrd_set_channel_on(acq.head.channel_mask, k);
+ }
ismrmrd_make_consistent_acquisition(&acq);
for (k=0; k<acq.head.number_of_samples; k++) {
for (c=0; c<acq.head.active_channels; c++) {
@@ -106,6 +110,11 @@ int main(void)
ismrmrd_read_acquisition(&dataset2, index, &acq2);
printf("Number of samples: %u\n", acq2.head.number_of_samples);
printf("Flags: %llu\n", acq2.head.flags);
+ printf("Channel Mask[0]: %llu\n", acq2.head.channel_mask[0]);
+ printf("Channel Mask[1]: %llu\n", acq2.head.channel_mask[1]);
+ printf("Channel 3 is %d\n", ismrmrd_is_channel_on(acq2.head.channel_mask, 3));
+ printf("Channel 5 is %d\n", ismrmrd_is_channel_on(acq2.head.channel_mask, 5));
+
#ifdef _MSC_VER
/* Windows C compilers don't have a good complex type */
printf("Data 3: %f\t 2: %f\n", acq2.data[4].real, acq2.data[4].imag);
diff --git a/include/ismrmrd/ismrmrd.h b/include/ismrmrd/ismrmrd.h
index 6eb7110..0d3178a 100644
--- a/include/ismrmrd/ismrmrd.h
+++ b/include/ismrmrd/ismrmrd.h
@@ -368,7 +368,17 @@ EXPORTISMRMRD int ismrmrd_clear_flag(uint64_t *flags, const uint64_t val);
EXPORTISMRMRD int ismrmrd_clear_all_flags(uint64_t *flags);
/** @} */
-/** TODO: add helper functions for channel mask */
+/*****************/
+/* Channel Masks */
+/*****************/
+/** @addtogroup capi
+ * @{
+ */
+EXPORTISMRMRD bool ismrmrd_is_channel_on(const uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS], const uint16_t chan);
+EXPORTISMRMRD int ismrmrd_set_channel_on(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS], const uint16_t chan);
+EXPORTISMRMRD int ismrmrd_set_channel_off(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS], const uint16_t chan);
+EXPORTISMRMRD int ismrmrd_clear_all_channels(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS]);
+/** @} */
/******************/
/* Error Handling */
diff --git a/libsrc/ismrmrd.c b/libsrc/ismrmrd.c
index 6797fe6..e8b7905 100644
--- a/libsrc/ismrmrd.c
+++ b/libsrc/ismrmrd.c
@@ -513,6 +513,52 @@ int ismrmrd_clear_all_flags(uint64_t *flags) {
return ISMRMRD_NOERROR;
}
+bool ismrmrd_is_channel_on(const uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS], const uint16_t chan) {
+ uint64_t bitmask;
+ size_t offset;
+ if (channel_mask==NULL) {
+ ISMRMRD_PUSH_ERR(ISMRMRD_RUNTIMEERROR, "Pointer to channel_mask should not be NULL.");
+ }
+ bitmask = 1 << (chan % 64);
+ offset = chan / 64;
+ return (channel_mask[offset] & bitmask) > 0;
+}
+
+int ismrmrd_set_channel_on(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS], const uint16_t chan) {
+ uint64_t bitmask;
+ size_t offset;
+ if (channel_mask==NULL) {
+ return ISMRMRD_PUSH_ERR(ISMRMRD_RUNTIMEERROR, "Pointer to channel_mask should not be NULL.");
+ }
+ bitmask = 1 << (chan % ISMRMRD_CHANNEL_MASKS);
+ offset = chan / ISMRMRD_CHANNEL_MASKS;
+ channel_mask[offset] |= bitmask;
+ return ISMRMRD_NOERROR;
+}
+
+int ismrmrd_set_channel_off(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS], const uint16_t chan) {
+ uint64_t bitmask;
+ size_t offset;
+ if (channel_mask==NULL) {
+ return ISMRMRD_PUSH_ERR(ISMRMRD_RUNTIMEERROR, "Pointer to channel_mask should not be NULL.");
+ }
+ bitmask = 1 << (chan % 64);
+ offset = chan / 64;
+ channel_mask[offset] &= ~bitmask;
+ return ISMRMRD_NOERROR;
+}
+
+int ismrmrd_clear_all_channels(uint64_t channel_mask[ISMRMRD_CHANNEL_MASKS]) {
+ size_t offset;
+ if (channel_mask==NULL) {
+ return ISMRMRD_PUSH_ERR(ISMRMRD_RUNTIMEERROR, "Pointer to channel_mask should not be NULL.");
+ }
+ for (offset = 0; offset<ISMRMRD_CHANNEL_MASKS; offset++) {
+ channel_mask[offset] = 0;
+ }
+ return ISMRMRD_NOERROR;
+}
+
int ismrmrd_sign_of_directions(float read_dir[3], float phase_dir[3], float slice_dir[3]) {
float r11 = read_dir[0], r12 = phase_dir[0], r13 = slice_dir[0];
float r21 = read_dir[1], r22 = phase_dir[1], r23 = slice_dir[1];
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ismrmrd.git
More information about the debian-science-commits
mailing list