[ismrmrd] 16/177: Get number of acquisitions works
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:57 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 cfe9c2b90b49988c2cdc871c2cbdac628029bd90
Author: Souheil Inati <souheil.inati at nih.gov>
Date: Fri Aug 1 12:50:49 2014 -0400
Get number of acquisitions works
---
ismrmrd_dataset.c | 122 +++++++++++++++++++++++++--------------------------
tests/c/basic_test.c | 72 +++++++++++++++---------------
2 files changed, 98 insertions(+), 96 deletions(-)
diff --git a/ismrmrd_dataset.c b/ismrmrd_dataset.c
index 32e9d27..7b3fa19 100644
--- a/ismrmrd_dataset.c
+++ b/ismrmrd_dataset.c
@@ -52,14 +52,19 @@ static int create_link(const ISMRMRD_Dataset *dset, const char *link_path) {
}
}
-static int delete_var(const ISMRMRD_Dataset *dset, const char *var) {
- herr_t status;
- char *path;
- path = (char *) malloc(strlen(dset->groupname)+strlen(var)+2);
+static char * make_path(const ISMRMRD_Dataset *dset, const char * var) {
+ char *path = (char *) malloc(strlen(dset->groupname)+strlen(var)+2);
memset(path, '\0', strlen(dset->groupname)+strlen(var)+2);
strcat(path, dset->groupname);
strcat(path, "/");
strcat(path, var);
+ return path;
+}
+
+
+static int delete_var(const ISMRMRD_Dataset *dset, const char *var) {
+ herr_t status;
+ char *path = make_path(dset, var);
if (link_exists(dset, path)) {
status = H5Ldelete(dset->fileid, path, H5P_DEFAULT);
// TODO handle errors
@@ -162,16 +167,10 @@ int ismrmrd_write_header(const ISMRMRD_Dataset *dset, const char *xmlstring) {
herr_t status;
/* The path to the xml header */
- const char *var = "xml";
- char *path;
- path = (char *) malloc(strlen(dset->groupname)+strlen(var)+2);
- memset(path, '\0', strlen(dset->groupname)+strlen(var)+2);
- strcat(path, dset->groupname);
- strcat(path, "/");
- strcat(path, var);
+ char *path = make_path(dset, "xml");
/* Delete the old header if it exists */
- status = delete_var(dset, var);
+ status = delete_var(dset, "xml");
/* Create a new dataset for the xmlstring */
/* i.e. create the memory type, data space, and data set */
@@ -204,18 +203,13 @@ char * ismrmrd_read_header(const ISMRMRD_Dataset *dset) {
char * xmlstring;
/* The path to the xml header */
- const char *var = "xml";
- char *path;
- path = (char *) malloc(strlen(dset->groupname)+strlen(var)+2);
- memset(path, '\0', strlen(dset->groupname)+strlen(var)+2);
- strcat(path, dset->groupname);
- strcat(path, "/");
- strcat(path, var);
+ char *path = make_path(dset, "xml");
if (link_exists(dset, path)) {
dataset = H5Dopen(dset->fileid, path, H5P_DEFAULT);
/* Get the datatype */
datatype = H5Dget_type(dataset);
+ printf("datatype: %d\n.", datatype);
/* Read it into a 1D buffer*/
void *buff[1];
status = H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, buff);
@@ -242,18 +236,59 @@ char * ismrmrd_read_header(const ISMRMRD_Dataset *dset) {
};
-/*****************************/
-/* TODO Implement these ones */
-/*****************************/
-int ismrmrd_append_acquisition(const ISMRMRD_Dataset *dset, const ISMRMRD_Acquisition *a) {
- return ISMRMRD_NOERROR;
+unsigned long ismrmrd_get_number_of_acquisitions(const ISMRMRD_Dataset *dset) {
+
+ hid_t dataset, dataspace;
+ hsize_t dims[2], maxdims[2];
+ herr_t h5status;
+ unsigned long numacq;
+
+ /* The path to the acqusition data */
+ char *path = make_path(dset, "data");
+
+ if (link_exists(dset, path)) {
+ dataset = H5Dopen(dset->fileid, path, H5P_DEFAULT);
+ dataspace = H5Dget_space(dataset);
+ h5status = H5Sget_simple_extent_dims(dataspace, dims, maxdims);
+ numacq = dims[0];
+ H5Sclose(dataspace);
+ H5Dclose(dataset);
+ }
+ else {
+ /* none */
+ numacq = 0;
+ }
+
+ return numacq;
};
-int ismrmrd_read_acquisition(const ISMRMRD_Dataset *dset, unsigned long index, ISMRMRD_Acquisition *a) {
+
+int ismrmrd_append_acquisition(const ISMRMRD_Dataset *dset, const ISMRMRD_Acquisition *a) {
+
+ hid_t dataset, dataspace, datatype, props;
+ hsize_t dims[2];
+ herr_t h5status;
+ int status;
+
+ /* The path to the acqusition data */
+ char *path = make_path(dset, "data");
+
+ /* Check the path, open or create if needed */
+ if (link_exists(dset, path)) {
+ /* open */
+ }
+ else {
+ /* create */
+ }
+
+
return ISMRMRD_NOERROR;
};
-unsigned long ismrmrd_get_number_of_acquisitions(const ISMRMRD_Dataset *dset) {
+/*****************************/
+/* TODO Implement these ones */
+/*****************************/
+int ismrmrd_read_acquisition(const ISMRMRD_Dataset *dset, unsigned long index, ISMRMRD_Acquisition *a) {
return ISMRMRD_NOERROR;
};
@@ -294,57 +329,22 @@ int ismrmrd_get_number_of_arrays(const ISMRMRD_Dataset *dset, const char *varnam
#ifdef YOMAMA
-xml_header_path_ = groupname_ + std::string("/xml");
-data_path_ = groupname_ + std::string("/data");
-
-hid_t t;
t = this->type_container_.get_type<float>();
-std::cout << "Type for float: " << t << std::endl;
-
t = this->type_container_.get_type<double>();
-std::cout << "Type for double: " << t << std::endl;
-
t = this->type_container_.get_type<std::complex<float> >();
-std::cout << "Type for complex float: " << t << std::endl;
-
t = this->type_container_.get_type<std::complex<double> >();
-std::cout << "Type for complex double: " << t << std::endl;
-
t = this->type_container_.get_type<EncodingCounters>();
-std::cout << "Type for EncodingCounters: " << t << std::endl;
-
t = this->type_container_.get_type<AcquisitionHeader>();
-std::cout << "Type for AcquisitionHeader: " << t << std::endl;
-
t = this->type_container_.get_type<AcquisitionHeader_with_data>();
-std::cout << "Type for AcquisitionHeader_with_data: " << t << std::endl;
-
t = this->type_container_.get_type<ImageHeader>();
-std::cout << "Type for ImageHeader: " << t << std::endl;
-
t = this->type_container_.get_type<ImageHeader_with_data<float> >();
-std::cout << "Type for ImageHeader_with_data<float>: " << t << std::endl;
-
t = this->type_container_.get_type<ImageHeader_with_data<double> >();
-std::cout << "Type for ImageHeader_with_data<double>: " << t << std::endl;
-
t = this->type_container_.get_type<ImageHeader_with_data<unsigned short> >();
-std::cout << "Type for ImageHeader_with_data<unsigned short>: " << t << std::endl;
-
t = this->type_container_.get_type<ImageHeader_with_data<ccomplex_t> >();
-std::cout << "Type for ImageHeader_with_data<ccomplex_t>: " << t << std::endl;
-
t = this->type_container_.get_type<ImageHeader_with_data<cdouble_complex_t> >();
-std::cout << "Type for ImageHeader_with_data<cdouble_complex_t>: " << t << std::endl;
-
t = this->type_container_.get_type<ImageHeader_with_data<std::complex<float> > >();
-std::cout << "Type for ImageHeader_with_data< std::complex<float> >: " << t << std::endl;
-
t = this->type_container_.get_type<ImageHeader_with_data<std::complex<double> > >();
-std::cout << "Type for ImageHeader_with_data< std::complex<double> >: " << t << std::endl;
-
t = this->type_container_.get_type<std::string>();
-std::cout << "Type for std::string: " << t << std::endl;
#endif
diff --git a/tests/c/basic_test.c b/tests/c/basic_test.c
index dbcd7d4..f88739d 100644
--- a/tests/c/basic_test.c
+++ b/tests/c/basic_test.c
@@ -17,63 +17,65 @@ int main(void)
int status;
ISMRMRD_Dataset dataset, dataset2;
const char *filename = "myfile.h5";
- const char *groupname = "/G1/dataset";
- const char *xmlhdr = "Hello world.";
+ const char *groupname = "/dataset";
+ const char *xmlhdr = "This is some text for the header.";
/* Set the error handler */
ismrmrd_set_error_handler(myerror);
- /* Create a data set */
- ismrmrd_init_dataset(&dataset, filename, groupname);
- status = ismrmrd_open_dataset(&dataset, true);
- printf("Dataset1 open, fileid: %d\n", dataset.fileid);
-
- status = ismrmrd_write_header(&dataset, xmlhdr);
- /* Close the dataset */
- status = ismrmrd_close_dataset(&dataset);
- printf("Dataset1 closed\n");
-
+ if (0) {
+ /* Create a data set */
+ ismrmrd_init_dataset(&dataset, filename, groupname);
+ status = ismrmrd_open_dataset(&dataset, true);
+ //status = ismrmrd_write_header(&dataset, xmlhdr);
+
+ /* Close the dataset */
+ status = ismrmrd_close_dataset(&dataset);
+ }
/* Reopen the file as a different dataset */
ismrmrd_init_dataset(&dataset2, filename, groupname);
- status = ismrmrd_open_dataset(&dataset2, true);
- printf("Dataset2 open, fileid: %d\n", dataset2.fileid);
+ status = ismrmrd_open_dataset(&dataset2, false);
/* Read the header */
char *xmlstring = ismrmrd_read_header(&dataset2);
printf("Header: %s\n", xmlstring);
+ /* Get the number of acquisitions */
+ printf("Number of Acquisitions: %lu\n", ismrmrd_get_number_of_acquisitions(&dataset2));
+
/* Clean up */
free(xmlstring);
/* Close the dataset */
status = ismrmrd_close_dataset(&dataset2);
- printf("Dataset2 closed\n");
-
- ISMRMRD_Acquisition acq;
- ismrmrd_init_acquisition(&acq);
- acq.head.number_of_samples = 128;
- acq.head.active_channels = 4;
- ismrmrd_make_consistent_acquisition(&acq);
- printf("Acq Version: %d\n", acq.head.version);
+ /* TODO */
+ if (0) {
+ ISMRMRD_Acquisition acq;
+ ismrmrd_init_acquisition(&acq);
+ acq.head.number_of_samples = 128;
+ acq.head.active_channels = 4;
+ ismrmrd_make_consistent_acquisition(&acq);
+ printf("Acq Version: %d\n", acq.head.version);
- ismrmrd_set_flag(&(acq.head.flags), ISMRMRD_ACQ_FIRST_IN_SLICE);
- printf("Flags: %llu\n", acq.head.flags);
- printf("ACQ_FIRST_IN_SLICE: %d\n", ismrmrd_is_flag_set(acq.head.flags, ISMRMRD_ACQ_FIRST_IN_SLICE));
- ismrmrd_clear_flag(&(acq.head.flags), ISMRMRD_ACQ_FIRST_IN_SLICE);
- printf("Flags: %llu\n", acq.head.flags);
- printf("ACQ_FIRST_IN_SLICE: %d\n", ismrmrd_is_flag_set(acq.head.flags, ISMRMRD_ACQ_FIRST_IN_SLICE));
+ ismrmrd_set_flag(&(acq.head.flags), ISMRMRD_ACQ_FIRST_IN_SLICE);
+ printf("Flags: %llu\n", acq.head.flags);
+ printf("ACQ_FIRST_IN_SLICE: %d\n", ismrmrd_is_flag_set(acq.head.flags, ISMRMRD_ACQ_FIRST_IN_SLICE));
+ ismrmrd_clear_flag(&(acq.head.flags), ISMRMRD_ACQ_FIRST_IN_SLICE);
+ printf("Flags: %llu\n", acq.head.flags);
+ printf("ACQ_FIRST_IN_SLICE: %d\n", ismrmrd_is_flag_set(acq.head.flags, ISMRMRD_ACQ_FIRST_IN_SLICE));
- // Image im;
- //initImage(&im);
- //printf("Image Version: %d\n", im.head.version);
+ // Image im;
+ //initImage(&im);
+ //printf("Image Version: %d\n", im.head.version);
- //NDArray arr;
- //initNDArray(&arr);
- //printf("Array ndim: %d\n", arr.ndim);
- //printf("Array dim[0]: %d\n", arr.dims[0]);
+ //NDArray arr;
+ //initNDArray(&arr);
+ //printf("Array ndim: %d\n", arr.ndim);
+ //printf("Array dim[0]: %d\n", arr.dims[0]);
+ }
return 0;
}
--
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