bool GtPlusAccumulatorImageTriggerGadget::storeImage(const ISMRMRD::ImageHeader& imgHeader, const hoNDArray<ValueType>& img, const ISMRMRD::MetaContainer& attrib, ImageBufferType& buf) { try { long long cha = attrib.as_long(GADGETRON_CHA, 0); size_t slc = imgHeader.slice; long long e2 = attrib.as_long(GADGETRON_E2, 0); size_t con = imgHeader.contrast; size_t phs = imgHeader.phase; size_t rep = imgHeader.repetition; size_t set = imgHeader.set; size_t ave = imgHeader.average; // create image ImageType* storedImage = new ImageType(); GADGET_CHECK_RETURN_FALSE(storedImage!=NULL); storedImage->from_NDArray(img); storedImage->attrib_ = attrib; GADGET_CHECK_RETURN_FALSE(gtPlus_util_.setMetaAttributesFromImageHeaderISMRMRD(imgHeader, storedImage->attrib_)); storedImage->attrib_.set(GADGETRON_PASS_IMMEDIATE, (long)0); buf(cha, slc, e2, con, phs, rep, set, ave) = storedImage; if ( pass_image_immediate_ ) { Gadgetron::GadgetContainerMessage<ImageBufferType>* cm1 = new Gadgetron::GadgetContainerMessage<ImageBufferType>(); ImageBufferType& imgBuf = *(cm1->getObjectPtr()); std::vector<size_t> dim2D(num_of_dimensions_, 1); imgBuf.create(dim2D); imgBuf(0) = new ImageType(); *imgBuf(0) = *storedImage; // set the pass_image flag, so next gadget knows imgBuf(0)->attrib_.set(GADGETRON_PASS_IMMEDIATE, (long)1); if (this->next()->putq(cm1) < 0) { cm1->release(); return false; } } } catch(...) { GERROR_STREAM("Error happens in GtPlusAccumulatorImageTriggerGadget::storeImage(const ISMRMRD::ImageHeader& imgHeader, const hoNDArray<ValueType>& img, const ISMRMRD::MetaContainer& attrib, ImageBufferType& buf) ... "); return false; } return true; }
bool getISMRMRMetaValues(const ISMRMRD::MetaContainer& attrib, const std::string& name, std::vector<long>& v) { try { size_t num = attrib.length(name.c_str()); if ( num == 0 ) { v.clear(); GWARN_STREAM("getISMRMRMetaValues, can not find field : " << name); return true; } v.resize(num); size_t ii; for ( ii=0; ii<num; ii++ ) { v[ii] = attrib.as_long(name.c_str(), ii); } } catch(...) { GERROR_STREAM("Error happened in getISMRMRMetaValues(const ISMRMRD::MetaContainer& attrib, const std::string& name, std::vector<long>& v) ... "); return false; } return true; }