Skip to content

Commit

Permalink
Making read-all default for reading MR acquisitions from file. (#1227)
Browse files Browse the repository at this point in the history
Warning: the following 36 commits are "inherited" from PR #1207:

* implemented a more flexible alternative to TO_BE_IGNORED macro

* moved IgnoreMask to optional arguments of set_data etc.

* defined ISMRMRD acquisition flags in Gadgetron.py

* implemented acquisition ignoring helper class IgnoreMask in Python

* provided example of user-set acquisition ignoring in acquisition_data.py

* changed default IgnoreMask for reading from file to ~13bffff

* have to use int for ignore mask instead of size_t as SWIG rejects int64

* [ci skip] small amendment in cGT_ISMRMRDAcquisitionsFromFile

* changed default value for all_ in AcquisitionData.__init__ to True

* put debug prints in test_pSynergistic.py

* trying reading MR acquisitions with all_=False

* trying reading MR acquisitions with all_=False in noncartesian_recon.py

* trying literal_eval instead of eval to placate Codacy

* small edit in test_pSynergistic.py to trigger GitHub Actions

* small corrections in MR/acquisition_data.py

* switched to 64-bit acquisition ignore masks

* made some white space adjustments

* switched to employing MRAcquisitionData attribute ignore_mask

* implemented set_ignore_mask method for MR AcquisitionData Python class

* covered all acquisitions ignored cases, fixes #1220

* corrected previous commit

* got rid of object_mask

* attended to the reviewer comments and suggestions

* Update build-test.yml

remove `-e` from the ctest line preventing unit test to complete.

* interfaced MRAcquisitionData::ignore_mask() into Python

* implemented setter for smoothing (convolution) kernel size

* updated CHANGES.md

* replaced C-style casts with reinterpret_cast in cgadgetron.cpp

* if this commit builds, the source of build failures is localised

* corrected AcquisitionData.ignore_mask in Gadgetron.py

* added missing initialisations of MRAcquisitionData.ignore_mask_ in constructors

* switched to defalt value False for all_ in AcquisitionData constructor

* smoothness->smoothing_iterations, smth_kernel_size->conv_kernel_halfsize

* [ci skip] removed some commented-out and unused stuff

* added method size() to C++ ImageData class

The remaining 4 commits are the only ones that are actually from this PR:

* Managed to switch to read-all-acquisitions default for MR AcquisitionData

Failures cased by noise calibration data forced ignoring it, which was
a poor solution. It turned out that ignoring these data just on the
preliminary test run in AcquisitionProcessor chain (to find out whether
the chain needs AcquisitionFinishGadget) appears to fix the problem
save for grappa2_1rep.h5 an grappa2_6rep.h5 data. Possible reason for
failures with the latter data is the absence of the measurementInformation
in xml headers. Assuming this is true, we can now use the proper
read-all-acquisition default when reading MR acquisition data, fixing
grappa2 data to be addressed by a separate issue.

* applied the bugfix from fix-mr2nifti

* corrected synergistic complex resampling test (wrong input data)

* synchronized Reg.py with fix-mr2nifti to avoid possible merge conflicts

---------

Co-authored-by: Edoardo Pasca <edo.paskino@gmail.com>
  • Loading branch information
evgueni-ovtchinnikov and paskino authored Jan 16, 2024
1 parent 51f649f commit 22e8fc1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/Registration/pReg/Reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,11 @@ def construct_from_complex_image(complex_im):
im_real.handle = \
pyreg.cReg_NiftiImageData_from_complex_ImageData_real_component(
complex_im.handle)
check_status(im_real.handle)
im_imag.handle = \
pyreg.cReg_NiftiImageData_from_complex_ImageData_imag_component(
complex_im.handle)
check_status(im_imag.handle)
return [im_real, im_imag]

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion src/Synergistic/tests/test_pSynergistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test():

mr_data_path = examples_data_path('MR')
reg_data_path = examples_data_path('Registration')
raw_mr_filename = mr_data_path + "/grappa2_1rep.h5"
raw_mr_filename = mr_data_path + "/simulated_MR_2D_cartesian.h5"
if os.path.isfile(mr_data_path + "/zenodo/dicom_as_nifti.nii"):
nifti_filename = mr_data_path + "/zenodo/dicom_as_nifti.nii"
mr_recon_h5_filename = mr_data_path + "/zenodo/SIRF_recon.h5"
Expand Down
2 changes: 1 addition & 1 deletion src/xGadgetron/cGadgetron/gadgetron_data_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2386,7 +2386,7 @@ GadgetronImagesVector::set_up_geom_info()

for (unsigned im=1; im<number(); ++im) {
ISMRMRD::ImageHeader &ih = image_wrap(im).head();

// record which is the largest slice index
// this allows to differentiate between slice number and this->number() as the
// latter also includes different contrasts, phases, repetitions etc. that have
Expand Down
10 changes: 9 additions & 1 deletion src/xGadgetron/cGadgetron/gadgetron_x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ AcquisitionsProcessor::process(MRAcquisitionData& acquisitions)
// quick fix: checking if AcquisitionFinishGadget is needed (= running old Gadgetron)
shared_ptr<MRAcquisitionData> sptr_acqs = acquisitions.new_acquisitions_container();
{
IgnoreMask im = acquisitions.ignore_mask();
acquisitions.set_ignore_mask(IgnoreMask());
GTConnector conn;
conn().register_reader(GADGET_MESSAGE_ISMRMRD_ACQUISITION,
shared_ptr<GadgetronClientMessageReader>
Expand All @@ -196,7 +198,12 @@ AcquisitionsProcessor::process(MRAcquisitionData& acquisitions)
conn().connect(host_, port_);
conn().send_gadgetron_configuration_script(config);
conn().send_gadgetron_parameters(acquisitions.acquisitions_info());
acquisitions.get_acquisition(0, acq_tmp);
for (uint32_t i = 0; i < nacq; i++)
if (acquisitions.get_acquisition(i, acq_tmp))
break;
else
std::cout << "ignoring acquisition " << i << '\n';
// acquisitions.get_acquisition(0, acq_tmp);
conn().send_ismrmrd_acquisition(acq_tmp);
conn().send_gadgetron_close();
conn().wait();
Expand All @@ -207,6 +214,7 @@ AcquisitionsProcessor::process(MRAcquisitionData& acquisitions)
THROW("Server running Gadgetron not accessible");
}
}
acquisitions.set_ignore_mask(im);
}

uint32_t na = sptr_acqs->number();
Expand Down
2 changes: 1 addition & 1 deletion src/xGadgetron/pGadgetron/Gadgetron.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ class AcquisitionData(DataContainer):
Class for an MR acquisitions container.
Each item is a 2D complex array of acquisition samples for each coil.
'''
def __init__(self, file=None, all_=False, ignored=IgnoreMask()):
def __init__(self, file=None, all_=True, ignored=IgnoreMask(0)):
self.handle = None
self.sorted = False
self.info = None
Expand Down

0 comments on commit 22e8fc1

Please sign in to comment.