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

Add Reconstructors and API for easier MR reconstruction #57

Merged
merged 32 commits into from
Dec 17, 2019

Conversation

chaithyagr
Copy link
Contributor

This is the final PR in #36 .
Hopefully this completes the Code refactoring process.
I have moved certain utils around to more sensible places.

@zaccharieramzi , Majorly in this PR I have added new reconstructors in mri/reconstructors, which will need maximum reviewing.

@chaithyagr chaithyagr self-assigned this Nov 14, 2019
@chaithyagr chaithyagr mentioned this pull request Nov 15, 2019
Copy link
Contributor

@zaccharieramzi zaccharieramzi left a comment

Choose a reason for hiding this comment

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

This review is not finished because I want to first come back on a point regarding the new reconstructor API. I have written it in the calibrationless.py file, so we should discuss that point and clear it before I go any further on the review.

mri/reconstructors/tests/test_reconstructors.py Outdated Show resolved Hide resolved
mri/reconstructors/tests/test_reconstructors.py Outdated Show resolved Hide resolved
mri/reconstructors/tests/test_reconstructors.py Outdated Show resolved Hide resolved
mri/reconstructors/tests/test_reconstructors.py Outdated Show resolved Hide resolved
mri/reconstructors/base.py Outdated Show resolved Hide resolved
mri/reconstructors/base.py Outdated Show resolved Hide resolved
mri/reconstructors/base.py Outdated Show resolved Hide resolved
mri/reconstructors/calibrationless.py Outdated Show resolved Hide resolved
mri/reconstructors/calibrationless.py Outdated Show resolved Hide resolved
mri/reconstructors/calibrationless.py Outdated Show resolved Hide resolved
mri/optimizers/forward_backward.py Outdated Show resolved Hide resolved
mri/reconstructors/calibrationless.py Outdated Show resolved Hide resolved
@chaithyagr
Copy link
Contributor Author

@zaccharieramzi , I have taken in most of the review comments in latest push, or have placed my opinions / comments / asked for help.
Could you please clean up the comments by resolving? In the meantime, I will be working on #57 (comment)

mri/reconstructors/tests/test_reconstructors.py Outdated Show resolved Hide resolved
mri/reconstructors/tests/test_reconstructors.py Outdated Show resolved Hide resolved
mri/reconstructors/tests/test_reconstructors.py Outdated Show resolved Hide resolved
mri/reconstructors/tests/test_reconstructors.py Outdated Show resolved Hide resolved
kspace_loc: np.ndarray
the mask samples in the Fourier domain.
uniform_data_shape: tuplet
the shape of the matrix containing the uniform data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it just data shape? or rather image shape if we don't want to confuse with k-space measurements?

verbosity level for debug, please check dervied class for details
on verbosity levels
"""
def __init__(self, kspace_loc, uniform_data_shape, n_coils,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you think it makes the code less readable? Maybe you mean the docs?

If you look at libraries like for example matplotlib, they have to do this all the time because their objects are so deeply derived or reused, they can't afford to explicitly expose all the arguments to every function.
Look at for example the docs to the plot function: https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.plot.html
You can see that they have a huge amount of kwargs (here the docs are super nice because they also list the kwargs directly and automatially but generally it's fine to just point to the corresponding function or class). This eases the maintaining of the docs and code because when you change a function somewhere you don't need to change the docs and code everywhere.

mri/reconstructors/base.py Outdated Show resolved Hide resolved
mri/reconstructors/base.py Outdated Show resolved Hide resolved
"""

# Package import
from mri.reconstruct.cost import DualGapCost, GenericCost

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is direct copy, the earlier movewas done to a shortcut file, (which just had imports)

@chaithyagr
Copy link
Contributor Author

In my opinion, all required coding is done, and I expect the tests to pass. Added back @zaccharieramzi for review. Please do yell out if I missed anything.

@chaithyagr
Copy link
Contributor Author

I think I have covered mostly all the comments. @LElgueddari can you please do a final review and check if I missed something?

Copy link
Contributor

@zaccharieramzi zaccharieramzi left a comment

Choose a reason for hiding this comment

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

Very small changes imho so you are good to go.

examples/cartesian_reconstruction.py Show resolved Hide resolved
examples/non_cartesian_reconstruction.py Outdated Show resolved Hide resolved
mri/reconstructors/base.py Outdated Show resolved Hide resolved
mri/reconstructors/base.py Outdated Show resolved Hide resolved
mri/reconstructors/single_channel.py Outdated Show resolved Hide resolved
mri/reconstructors/single_channel.py Outdated Show resolved Hide resolved
Copy link
Contributor

@LElgueddari LElgueddari left a comment

Choose a reason for hiding this comment

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

Still few changes

examples/cartesian_reconstruction.py Show resolved Hide resolved
mri/operators/fourier/utils.py Outdated Show resolved Hide resolved
mri/operators/fourier/utils.py Outdated Show resolved Hide resolved
mri/reconstructors/base.py Show resolved Hide resolved
mri/reconstructors/base.py Outdated Show resolved Hide resolved
mri/reconstructors/single_channel.py Outdated Show resolved Hide resolved
mri/reconstructors/single_channel.py Outdated Show resolved Hide resolved
mri/reconstructors/single_channel.py Outdated Show resolved Hide resolved
mri/reconstructors/single_channel.py Outdated Show resolved Hide resolved
Copy link
Contributor

@zaccharieramzi zaccharieramzi left a comment

Choose a reason for hiding this comment

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

Some documentation on the gradient arguments and the regularizer_op to be put in the kwargs. I would even be in favor of putting the other ops in the kwargs but I understand they are used for some other things in the derived classes so I am not against their current state.

**kwargs : Extra keyword arguments for gradient initialization.
Please refer to mri.operators.gradient.base for information
"""
def __init__(self, fourier_op, linear_op=None, regularizer_op=None,
Copy link
Contributor

Choose a reason for hiding this comment

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

regularizer_op can also be part of the kwargs

Copy link
Contributor

Choose a reason for hiding this comment

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

True for the other classes.

mri/reconstructors/base.py Show resolved Hide resolved
Copy link
Contributor

@zaccharieramzi zaccharieramzi left a comment

Choose a reason for hiding this comment

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

Probably the best way to specify which class to look for is to specify it in each derived class.

mri/reconstructors/base.py Show resolved Hide resolved
Copy link
Contributor

@zaccharieramzi zaccharieramzi left a comment

Choose a reason for hiding this comment

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

The docs of regularizer are still in the derived classes and the doc isn't gradient-specific (it depends on the gradient used)

operator and adjoint operator. For wavelets, this can be object of
class WaveletN or WaveletUD2 from mri.operators .
If None, sym8 wavelet with nb_scale=3 is chosen.
regularizer_op: operator, (optional default None)
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not in the params anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Im confused where to have this, can you please help me here? PLease refer to my next comment

mri/reconstructors/calibrationless.py Show resolved Hide resolved
Copy link
Contributor

@zaccharieramzi zaccharieramzi left a comment

Choose a reason for hiding this comment

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

LGTM

@chaithyagr
Copy link
Contributor Author

Tagging @LElgueddari for final merge, if its good for her..

Copy link
Contributor

@LElgueddari LElgueddari left a comment

Choose a reason for hiding this comment

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

LGTM

@LElgueddari LElgueddari merged commit 3f0874a into CEA-COSMIC:master Dec 17, 2019
@chaithyagr chaithyagr deleted the mv_reconstructors branch January 13, 2020 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants