-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyBucketToBufferGadget.h
72 lines (57 loc) · 3.69 KB
/
MyBucketToBufferGadget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include "Node.h"
#include "gadgetron_mricore_export.h"
#include "hoNDArray.h"
#include "mri_core_acquisition_bucket.h"
#include "mri_core_data.h"
#include <complex>
#include <ismrmrd/ismrmrd.h>
#include <ismrmrd/xml.h>
#include <gadgetron/mri_core_utility.h>
#include <gadgetron/ImageIOAnalyze.h>
#include <csignal>
namespace Gadgetron {
// TODO the ignore_segment_ flag is a hack for some EPI sequences
// should be fixed on the converter side.
// This gadget fills the IsmrmrdReconData structures with kspace readouts and sets up the sampling limits
// For the cartesian sampling, the filled kspace ensures its center (N/2) is aligned with the specified center in
// the encoding limits For the non-cartesian sampling, this "center alignment" constraint is not applied and kspace
// lines are filled as their E1 and E2 indexes
// Since the order of data can be changed from its acquried time order, there is no easy way to resort waveform data
// Therefore, the waveform data was copied and passed with every buffer
class MyBucketToBufferGadget : public Core::ChannelGadget<AcquisitionBucket> {
public:
MyBucketToBufferGadget(const Core::Context& context, const Core::GadgetProperties& props);
enum class Dimension { average, contrast, phase, repetition, set, segment, slice, none };
struct BufferKey {
uint16_t average,slice,contrast,phase,repetition,set,segment;
BufferKey(const BufferKey&) = default;
BufferKey(const ISMRMRD::EncodingCounters& idx) : average{idx.average}, slice{idx.slice},contrast{idx.contrast}, phase{idx.phase},repetition{idx.repetition},set{idx.set},segment{idx.segment}{
}
};
protected:
NODE_PROPERTY(N_dimension, Dimension, "N-Dimensions", Dimension::none);
NODE_PROPERTY(S_dimension, Dimension, "S-Dimensions", Dimension::none);
NODE_PROPERTY(split_slices, bool, "Split slices", false);
NODE_PROPERTY(ignore_segment, bool, "Ignore segment", false);
NODE_PROPERTY(verbose, bool, "Whether to print more information", false);
ISMRMRD::IsmrmrdHeader header;
void process(Core::InputChannel<AcquisitionBucket>& in, Core::OutputChannel& out) override;
BufferKey getKey(const ISMRMRD::EncodingCounters& idx) const;
IsmrmrdDataBuffered makeDataBuffer(const ISMRMRD::AcquisitionHeader& acqhdr, ISMRMRD::Encoding encoding,
const AcquisitionBucketStats& stats, bool forref) const;
IsmrmrdDataBuffered makeRefDataBuffer(const ISMRMRD::AcquisitionHeader& acqhdr,
ISMRMRD::Encoding encoding, const AcquisitionBucketStats& stats) const ;
SamplingDescription createSamplingDescription(const ISMRMRD::Encoding& encoding,
const AcquisitionBucketStats& stats, const ISMRMRD::AcquisitionHeader& acqhdr, bool forref) const ;
void add_acquisition(IsmrmrdDataBuffered& dataBuffer, const Core::Acquisition& acq, ISMRMRD::Encoding encoding,
const AcquisitionBucketStats& stats, bool forref);
void add_RefAcquisition(IsmrmrdDataBuffered& dataBuffer, const Core::Acquisition& acq,
ISMRMRD::Encoding encoding, const AcquisitionBucketStats& stats);
uint16_t getNE0(const ISMRMRD::AcquisitionHeader& acqhdr, const ISMRMRD::Encoding& encoding) const;
uint16_t getNE1(const ISMRMRD::Encoding& encoding, const AcquisitionBucketStats& stats, bool forref) const;
uint16_t getNE2(const ISMRMRD::Encoding& encoding, const AcquisitionBucketStats& stats, bool forref) const;
uint16_t getNLOC(const ISMRMRD::Encoding& encoding, const AcquisitionBucketStats& stats) const;
};
void from_string(const std::string&, MyBucketToBufferGadget::Dimension&);
}