Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mrdata dimensions #1161

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/xGadgetron/cGadgetron/gadgetron_data_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,17 @@ MRAcquisitionData::get_acquisitions_dimensions(size_t ptr_dim) const
int* dim = (int*)ptr_dim;
ISMRMRD::Acquisition acq;
get_acquisition(0, acq);
int counter_first_valid_acq = 1;
while(TO_BE_IGNORED(acq) && counter_first_valid_acq < this->number())
{
get_acquisition(counter_first_valid_acq, acq);
counter_first_valid_acq++;
}

int ns = acq.number_of_samples();
int nc = acq.active_channels();

for(int i=1; i<na; ++i)
for(int i=counter_first_valid_acq; i<na; ++i)
Comment on lines +196 to +206
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same edits for get_trajectory_dimensions and get_kspace_dimensions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the situation is more complicated, I am afraid. If some acquisitions are to be ignored, dim[2] needs to be reduced accordingly in order for fill and as-array to work with correct dimensions, and all computations with acquisition data must do TO_BE_IGNORED checks, which makes it rather pointless to keep ignored acquisitions at all. And if we do not keep them, then TO_BE_IGNORED would only be needed when reading from file, and I believe we should issue warning message for every ignored acquisition to make the users aware that the data SIRF reads is not identical to the data in the file.

This all should be well thought through and discussed, so I suggest we postpone this PR and PR #1158 until after Release 3.4.

Copy link
Member Author

@johannesmayer johannesmayer Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if we do not keep them, then TO_BE_IGNORED would only be needed when reading from file, and I believe we should issue warning message for every ignored acquisition to make the users aware that the data SIRF reads is not identical to the data in the file.

Yes, I agree, but as mentioned in #1156 then gadgetron reconstructions seem not to work any more without the noise sample readouts, which was the reason for trying to drop the macro.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that gadgetron_ismrmrd_client using Generic_Cartesian_Grappa.xml without conversion to unsigned shorts produces expected images.

Apparently, the pixel values of the reconstructed images are too small to be represented by non-zero unsigned shorts, which suggests Gadgetron scaling problems in the absence of noise calibration data. I will create a Gadgetron issue for this bug when we switch to using up-to-date Gadgetron.

Meanwhile I suggest adding second int/bool argument all to MRAcquisitionData::read, defaulting to false, that would allow the user to disable ignoring acquisitions, and the same argument to AcquisitionsVector constructor-from-file etc. I volunteer to do that and also fix dimensions bugs (in fact, it looks like ignoring acquisitions in MRAcquisitionData::read was merely my quick fix for those bugs, so a proper fix is on me).

@johannesmayer are you joining our tomorrow zoom?

{
get_acquisition(i, acq);
ASSERT(acq.number_of_samples() == ns, "One of your acquisitions has a different number of samples. Please make sure the dimensions are consistent.");
Expand Down
4 changes: 2 additions & 2 deletions src/xGadgetron/pGadgetron/Gadgetron.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ def dimensions(self):
if self.number() < 1:
return numpy.zeros((MAX_ACQ_DIMENSIONS,), dtype=cpp_int_dtype())
dim = numpy.ones((MAX_ACQ_DIMENSIONS,), dtype=cpp_int_dtype())
hv = pygadgetron.cGT_getAcquisitionDataDimensions\
(self.handle, dim.ctypes.data)
hv = try_calling(pygadgetron.cGT_getAcquisitionDataDimensions\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try_calling has no return value (so the next line is no longer needed) - see src/common/Utilities.py

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be sure, by the next line I mean line 967 (try_calling takes care about the handles returned by C interface functions)

(self.handle, dim.ctypes.data))
pyiutil.deleteDataHandle(hv)
dim[2] = numpy.prod(dim[2:])
return tuple(dim[2::-1])
Expand Down