Skip to content

Commit

Permalink
switched to employing MRAcquisitionData attribute ignore_mask
Browse files Browse the repository at this point in the history
  • Loading branch information
evgueni-ovtchinnikov committed Nov 15, 2023
1 parent b6bdc99 commit 0a0044a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
5 changes: 4 additions & 1 deletion src/xGadgetron/cGadgetron/cgadgetron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,10 @@ cGT_ISMRMRDAcquisitionsFromFile(const char* file, int all, size_t ptr)
mask.show_bits();
shared_ptr<MRAcquisitionData>
acquisitions(new AcquisitionsVector);
acquisitions->read(file, all, mask);
IgnoreMask copy = acquisitions->ignore_mask();
acquisitions->set_ignore_mask(mask);
acquisitions->read(file, all);
acquisitions->set_ignore_mask(copy);
return newObjectHandle<MRAcquisitionData>(acquisitions);
}
CATCH;
Expand Down
12 changes: 6 additions & 6 deletions src/xGadgetron/cGadgetron/gadgetron_data_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ MRAcquisitionData::write(const std::string &filename) const
}

void
MRAcquisitionData::read(const std::string& filename_ismrmrd_with_ext, int all,
const IgnoreMask& ignore_mask)
MRAcquisitionData::read(const std::string& filename_ismrmrd_with_ext, int all)
{
bool const verbose = true;

Expand Down Expand Up @@ -151,6 +150,7 @@ MRAcquisitionData::read(const std::string& filename_ismrmrd_with_ext, int all,
d.readAcquisition( i_acqu, acq);
mtx.unlock();

IgnoreMask ignore_mask = this->ignore_mask();
if (all || !ignore_mask.ignored(acq.flags()))
this->append_acquisition(acq);
}
Expand Down Expand Up @@ -268,7 +268,7 @@ void MRAcquisitionData::get_kspace_dimensions(std::vector<size_t>& dims) const


void
MRAcquisitionData::get_data(complex_float_t* z, int a, IgnoreMask ignore_mask)
MRAcquisitionData::get_data(complex_float_t* z, int a)
{
ISMRMRD::Acquisition acq;
unsigned int na = number();
Expand All @@ -284,7 +284,7 @@ MRAcquisitionData::get_data(complex_float_t* z, int a, IgnoreMask ignore_mask)
return;
}
for (unsigned int a = 0, i = 0; a < na; a++) {
if (!get_acquisition(a, acq, ignore_mask)) {
if (!get_acquisition(a, acq)) {
std::cout << "ignoring acquisition " << a << '\n';
continue;
}
Expand Down Expand Up @@ -1323,13 +1323,13 @@ AcquisitionsVector::conjugate_impl()
}

void
AcquisitionsVector::set_data(const complex_float_t* z, int all,
IgnoreMask ignore_mask)
AcquisitionsVector::set_data(const complex_float_t* z, int all)
{
int na = number();
for (int a = 0, i = 0; a < na; a++) {
int ia = index(a);
ISMRMRD::Acquisition& acq = *acqs_[ia];
IgnoreMask ignore_mask = this->ignore_mask();
if (!all && ignore_mask.ignored(acq.flags())) {
std::cout << "ignoring acquisition " << ia << '\n';
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,7 @@ namespace sirf {
virtual gadgetron::shared_ptr<ISMRMRD::Acquisition>
get_acquisition_sptr(unsigned int num) = 0;
virtual int get_acquisition(unsigned int,
ISMRMRD::Acquisition&,
IgnoreMask ignore_mask = IgnoreMask()) const = 0;
ISMRMRD::Acquisition&) const = 0;
virtual void set_acquisition(unsigned int,
ISMRMRD::Acquisition&) = 0;
virtual void append_acquisition(ISMRMRD::Acquisition& acq) = 0;
Expand All @@ -576,10 +575,8 @@ namespace sirf {
virtual MRAcquisitionData*
same_acquisitions_container(const AcquisitionsInfo& info) const = 0;

virtual void set_data(const complex_float_t* z, int all = 1,
IgnoreMask ignore_mask = IgnoreMask()) = 0;
virtual void get_data(complex_float_t* z, int all = 1,
IgnoreMask ignore_mask = IgnoreMask());
virtual void set_data(const complex_float_t* z, int all = 1) = 0;
virtual void get_data(complex_float_t* z, int all = 1);

virtual void set_user_floats(float const * const z, int const idx);

Expand Down Expand Up @@ -644,6 +641,8 @@ namespace sirf {
AcquisitionsInfo acquisitions_info() const { return acqs_info_; }
void set_acquisitions_info(std::string info) { acqs_info_ = info; }
void set_acquisitions_info(const AcquisitionsInfo info) { acqs_info_ = info;}
IgnoreMask ignore_mask() const { return ignore_mask_; }
void set_ignore_mask(IgnoreMask ignore_mask) const { ignore_mask_= ignore_mask; }

ISMRMRD::TrajectoryType get_trajectory_type() const;

Expand Down Expand Up @@ -712,7 +711,8 @@ namespace sirf {
int index(int i) const
{
const std::size_t ni = index_.size();
if (i < 0 || (ni > 0 && static_cast<std::size_t>(i) >= ni) || static_cast<unsigned>(i) >= number())
if (i < 0 || (ni > 0 && static_cast<std::size_t>(i) >= ni)
|| static_cast<unsigned>(i) >= number())
THROW("Aquisition number is out of range");
if (ni > 0)
return index_[i];
Expand All @@ -728,15 +728,16 @@ namespace sirf {
* To avoid reading noise samples and other calibration data, IgnoreMask may be employed
* to exclude potentially incompatible input.
*/
void read(const std::string& filename_ismrmrd_with_ext, int all = 0,
const IgnoreMask& ignore_mask = IgnoreMask());
void read(const std::string& filename_ismrmrd_with_ext, int all = 0);

protected:
bool sorted_ = false;
std::vector<int> index_;
std::vector<KSpaceSubset> sorting_;
AcquisitionsInfo acqs_info_;

mutable IgnoreMask ignore_mask_= IgnoreMask();

// new MRAcquisitionData objects will be created from this template
// using same_acquisitions_container()
static gadgetron::shared_ptr<MRAcquisitionData> acqs_templ_;
Expand Down Expand Up @@ -782,9 +783,9 @@ namespace sirf {
return acqs_[ind];
}
virtual int get_acquisition(unsigned int num,
ISMRMRD::Acquisition& acq,
IgnoreMask ignore_mask = IgnoreMask()) const
ISMRMRD::Acquisition& acq) const
{
IgnoreMask ignore_mask = this->ignore_mask();
int ind = index(num);
acq = *acqs_[ind];
if (ignore_mask.ignored(acq.flags()))
Expand All @@ -801,8 +802,7 @@ namespace sirf {
acqs_info_ = ac.acquisitions_info();
}
virtual void copy_acquisitions_data(const MRAcquisitionData& ac);
virtual void set_data(const complex_float_t* z, int all = 1,
IgnoreMask ignore_mask = IgnoreMask());
virtual void set_data(const complex_float_t* z, int all = 1);

virtual AcquisitionsVector* same_acquisitions_container
(const AcquisitionsInfo& info) const
Expand Down

0 comments on commit 0a0044a

Please sign in to comment.