30 #ifndef GADGETRON_EXTENSIONS
31 #define GADGETRON_EXTENSIONS
33 #define WIN32_LEAN_AND_MEAN
39 #include <ismrmrd/ismrmrd.h>
40 #include <ismrmrd/dataset.h>
42 #include "sirf/Gadgetron/cgadgetron_shared_ptr.h"
45 #include "sirf/common/JacobiCG.h"
46 #include "sirf/iUtilities/LocalisedException.h"
47 #include "sirf/Gadgetron/cgadgetron_shared_ptr.h"
52 #if GADGETRON_TOOLBOXES_AVAILABLE
60 class GadgetronClientConnector;
70 gadgetron::shared_ptr<GadgetronClientConnector> sptr();
72 gadgetron::shared_ptr<GadgetronClientConnector> sptr_con_;
83 GadgetHandle(std::string
id, gadgetron::shared_ptr<aGadget> sptr_g) :
84 id_(
id), sptr_g_(sptr_g) {}
85 std::string id()
const
91 return *sptr_g_.get();
95 return *sptr_g_.get();
97 gadgetron::shared_ptr<aGadget> gadget_sptr()
103 gadgetron::shared_ptr<aGadget> sptr_g_;
140 static const char* class_name()
142 return "GadgetChain";
144 void set_host(
const std::string host)
148 void set_port(
const std::string port)
155 void add_reader(std::string
id, gadgetron::shared_ptr<aGadget> sptr_g)
157 readers_.push_back(gadgetron::shared_ptr<GadgetHandle>
161 void add_writer(std::string
id, gadgetron::shared_ptr<aGadget> sptr_g)
163 writers_.push_back(gadgetron::shared_ptr<GadgetHandle>
167 void set_endgadget(gadgetron::shared_ptr<aGadget> sptr_g)
172 void add_gadget(std::string
id, gadgetron::shared_ptr<aGadget> sptr_g)
174 gadgets_.push_back(gadgetron::shared_ptr<GadgetHandle>
177 gadgetron::shared_ptr<aGadget> gadget_sptr(std::string
id);
179 std::string xml()
const;
184 std::list<gadgetron::shared_ptr<GadgetHandle> > readers_;
185 std::list<gadgetron::shared_ptr<GadgetHandle> > writers_;
186 std::list<gadgetron::shared_ptr<GadgetHandle> > gadgets_;
187 gadgetron::shared_ptr<aGadget> endgadget_;
205 add_reader(
"reader", reader_);
206 add_writer(
"writer", writer_);
210 static const char* class_name()
212 return "AcquisitionsProcessor";
216 gadgetron::shared_ptr<MRAcquisitionData> get_output()
218 if(!sptr_acqs_->sorted())
219 sptr_acqs_->sort_by_time();
225 gadgetron::shared_ptr<IsmrmrdAcqMsgReader> reader_;
226 gadgetron::shared_ptr<IsmrmrdAcqMsgWriter> writer_;
227 gadgetron::shared_ptr<MRAcquisitionData> sptr_acqs_;
245 sptr_images_.reset();
246 add_reader(
"reader", reader_);
247 add_writer(
"writer", writer_);
249 set_endgadget(endgadget);
251 static const char* class_name()
253 return "ImagesReconstructor";
262 dcm_prefix_ = dcm_prefix;
264 std::string dcm_prefix()
const
268 bool dcm_output()
const
270 return !dcm_prefix_.empty();
272 void process(MRAcquisitionData& acquisitions);
273 gadgetron::shared_ptr<GadgetronImageData> get_output()
276 THROW(
"Output to both memory and DICOM files not implemented.");
281 std::string dcm_prefix_;
282 gadgetron::shared_ptr<IsmrmrdAcqMsgReader> reader_;
283 gadgetron::shared_ptr<IsmrmrdImgMsgWriter> writer_;
284 gadgetron::shared_ptr<DicomImageMessageWriter> writer_dcm_;
285 gadgetron::shared_ptr<GadgetronImageData> sptr_images_;
298 dicom_(dicom), prefix_(prefix),
303 gadgetron::shared_ptr<aGadget> endgadget;
312 add_reader(
"reader", reader_);
313 add_writer(
"writer", writer_);
314 set_endgadget(endgadget);
316 static const char* class_name()
318 return "ImagesProcessor";
321 void check_connection();
323 gadgetron::shared_ptr<GadgetronImageData> get_output()
333 gadgetron::shared_ptr<IsmrmrdImgMsgReader> reader_;
334 gadgetron::shared_ptr<ImageMessageWriter> writer_;
336 gadgetron::shared_ptr<GadgetronImageData> sptr_images_;
377 BFOperator(gadgetron::shared_ptr<MRAcquisitionModel> sptr_am) : sptr_am_(sptr_am) {}
378 virtual gadgetron::shared_ptr<GadgetronImageData>
381 gadgetron::shared_ptr<MRAcquisitionData> sptr_fwd =
382 sptr_am_->fwd(image_data);
383 gadgetron::shared_ptr<GadgetronImageData> sptr_bwd =
384 sptr_am_->bwd(*sptr_fwd);
388 gadgetron::shared_ptr<MRAcquisitionModel> sptr_am_;
398 gadgetron::shared_ptr<MRAcquisitionData> sptr_ac,
399 gadgetron::shared_ptr<GadgetronImageData> sptr_ic
402 this->set_up(sptr_ac, sptr_ic);
405 gadgetron::shared_ptr<MRAcquisitionData> sptr_ac,
406 gadgetron::shared_ptr<GadgetronImageData> sptr_ic,
407 gadgetron::shared_ptr<CoilSensitivitiesVector> sptr_csms,
408 std::string acqs_info
409 ) : sptr_csms_(sptr_csms), acqs_info_(acqs_info)
411 this->set_up(sptr_ac, sptr_ic);
422 float norm(
int num_iter = 16,
int verb = 0)
424 gadgetron::shared_ptr<MRAcquisitionModel> sptr_am
429 jcg.set_num_iterations(num_iter);
430 gadgetron::unique_ptr<GadgetronImageData> sptr_id = sptr_imgs_->clone();
432 image_data.fill(1.0);
433 float lmd = jcg.largest(bf, image_data, verb);
434 return std::sqrt(lmd);
441 void set_acquisition_template
442 (gadgetron::shared_ptr<MRAcquisitionData> sptr_ac)
444 sptr_acqs_ = sptr_ac;
447 void set_image_template
448 (gadgetron::shared_ptr<GadgetronImageData> sptr_ic)
450 check_data_role(*sptr_ic);
451 sptr_imgs_ = sptr_ic;
454 gadgetron::shared_ptr<const MRAcquisitionData> acq_template_sptr()
const
459 gadgetron::shared_ptr<const GadgetronImageData> image_template_sptr()
const
464 void set_csm(gadgetron::shared_ptr<CoilSensitivitiesVector> sptr_csms)
466 sptr_csms_ = sptr_csms;
469 void set_encoder(gadgetron::shared_ptr<sirf::FourierEncoding> sptr_enc)
471 sptr_enc_ = sptr_enc;
475 void set_up(gadgetron::shared_ptr<MRAcquisitionData> sptr_ac,
476 gadgetron::shared_ptr<GadgetronImageData> sptr_ic);
480 void fwd(
const GadgetronImageData& ic, CoilSensitivitiesVector& cc,
481 MRAcquisitionData& ac);
485 void bwd(GadgetronImageData& ic,
const CoilSensitivitiesVector& cc,
486 const MRAcquisitionData& ac);
490 gadgetron::shared_ptr<MRAcquisitionData> fwd(
const GadgetronImageData& ic)
493 if (!sptr_acqs_.get())
495 (
"Acquisition data template not set", __FILE__, __LINE__);
496 if (!sptr_csms_.get() || sptr_csms_->items() < 1)
498 (
"Coil sensitivity maps not found", __FILE__, __LINE__);
500 gadgetron::unique_ptr<MRAcquisitionData> uptr_acqs =
503 fwd(ic, *sptr_csms_, *uptr_acqs);
505 return gadgetron::shared_ptr<MRAcquisitionData>(std::move(uptr_acqs));
510 gadgetron::shared_ptr<GadgetronImageData> bwd(
const MRAcquisitionData& ac)
512 if (!sptr_imgs_.get())
514 (
"image data template not set", __FILE__, __LINE__);
515 if (!sptr_csms_.get() || sptr_csms_->items() < 1)
517 (
"coil sensitivity maps not found", __FILE__, __LINE__);
518 gadgetron::shared_ptr<GadgetronImageData> sptr_imgs =
519 sptr_imgs_->new_images_container();
520 bwd(*sptr_imgs, *sptr_csms_, ac);
525 std::string acqs_info_;
526 gadgetron::shared_ptr<MRAcquisitionData> sptr_acqs_;
527 gadgetron::shared_ptr<GadgetronImageData> sptr_imgs_;
528 gadgetron::shared_ptr<CoilSensitivitiesVector> sptr_csms_;
529 gadgetron::shared_ptr<FourierEncoding> sptr_enc_;
File for cartesian fourier encoding and trajectory setting.
Specification file for non-cartesian Fourier encoding.
Definition: LocalisedException.h:32
A particular type of Gadget chain that has AcquisitionData on input and output.
Definition: gadgetron_x.h:197
Class for the generator of xml definition of DicomFinishGadget.
Definition: gadget_lib.h:849
Class for DicomImageWriter gadget xml-definition generator.
Definition: gadget_lib.h:219
Shared pointer wrap-up for GadgetronClientConnector.
Definition: gadgetron_x.h:66
Gadget chain class.
Definition: gadgetron_x.h:134
Shared pointer wrap-up for the abstract gadget class aGadget.
Definition: gadgetron_x.h:81
Class for communicating with Gadgetron server.
Definition: gadgetron_client.h:294
Abstract Gadgetron image data container class.
Definition: gadgetron_data_containers.h:785
Class for the generator of xml definition of ImageFinishGadget.
Definition: gadget_lib.h:835
A particular type of Gadget chain that has ImageData on input and output.
Definition: gadgetron_x.h:295
A particular type of Gadget chain that has AcquisitionData on input and ImageData on output.
Definition: gadgetron_x.h:237
void set_dcm_prefix(const std::string &dcm_prefix)
Setting dcm prefix to a non-empty string redirects the output images to DICOM files (cf....
Definition: gadgetron_x.h:260
Class for GadgetIsmrmrdAcquisitionMessageReader gadget xml-definition generator.
Definition: gadget_lib.h:113
Class for GadgetIsmrmrdAcquisitionMessageWriter gadget xml-definition generator.
Definition: gadget_lib.h:139
Class for MRIImageReader gadget xml-definition generator.
Definition: gadget_lib.h:164
Class for MRIImageWriter gadget xml-definition generator.
Definition: gadget_lib.h:195
Definition: JacobiCG.h:37
Abstract MR acquisition data container class.
Definition: gadgetron_data_containers.h:217
Class for the product of backward and forward projectors of the MR acquisition model.
Definition: gadgetron_x.h:375
A class for MR acquisition modelling.
Definition: gadgetron_x.h:366
float norm(int num_iter=16, int verb=0)
Method computing the norm of the MR acquisition model operator A.
Definition: gadgetron_x.h:422
Abstract base class for a gadget xml-definition generator.
Definition: gadget_lib.h:45
Specification file for the library of SIRF generators of xml-definitions of Gadgetron gadgets.
Specification file for data container classes for Gadgetron data.
Abstract data container.
Definition: GeometricalInfo.cpp:141