mckib2 / pygrappa Goto Github PK
View Code? Open in Web Editor NEWPython implementations of GRAPPA-like algorithms.
Home Page: https://pygrappa.readthedocs.io/en/latest/
License: MIT License
Python implementations of GRAPPA-like algorithms.
Home Page: https://pygrappa.readthedocs.io/en/latest/
License: MIT License
First, thanks for such a great project. I really love using this toolbox.
I noticed this problem when using kernel size (5,5) at high acceleration factor (R), because the results were too poor. After increasing the kernel size to about R times, the results became normal. Then I checked the code, and found the kernel size is used as a region? Then the actual number of data points used to interpolate may be far less than the "kernel size". I believe that in most published papers, the kernel size means exactly how many points are used to interpolate the missing point.
Am I right?
Cropping shepp_logan to an odd number in one dimension (i.e., 128x127
) in examples seems to break GRAPPA recon.
Hi,
so I was trying to use grappa
which worked as intented at first. But as soon as I started to create error images abs(reconstructed_image - reference_image)
, I realized that grappa
is producing aliasing artifacts.
The error is also reproducible with the example provided in examples/basic_grappa.py
. Therefore you only have to add the following code at the end of the example:
reference_img = np.zeros((2*N, 2*N))
kk = 0
for idx in np.ndindex((2, 2)):
ii, jj = idx[:]
reference_img[ii*N:(ii+1)*N, jj*N:(jj+1)*N] = abs(imspace[..., kk])
kk += 1
plt.imshow(abs(reference_img-res0), cmap='gray')
plt.show()
Before using pygrappa I was using PULSAR which is a grappa implementation for matlab and aliasing artifacts weren't a problem.
So my question is, am I missing something or is this a bug.
(I also tried using cgrappa
and mdgrappa
which led to the same results.)
Thanks so much for sharing this code - it's just what I've been looking for as I'm trying to migrate my projects away from being tied to MATLAB.
For my particular application I have a whole series of 3D volumes that need 2D GRAPPA reconstruction using the same calibration pre-scan. Do you already have a way of handling this, so the weights don't need to be recalculated for each volume? - I couldn't spot this by scanning through the code.
Hi,
I just found that after pip installing this package, all my projects' local submodules located in ./utils cannot be imported properly. After uninstalling pygrappa they worked again. So I think this might because the utils package in grappa get the highest priority.
So I'm wondering is there any way to fix this instead of staying away from subfolder named 'utils' in all of my local projects? Thanks!
Recent install fails due to the latest scikit-image release: https://github.com/scikit-image/scikit-image/releases which dropped skimage.util.pad
.
Should be possible to fix this by replacing it with np.pad
.
I am trying to have pygrappa
installed in a singularity image, and I have the following error when installing:
Building wheels for collected packages: pygrappa
Building wheel for pygrappa (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c7s46can/pygrappa/setup.py'"'"'; __file__='"'"'/tmp/pip-install-c7s46can/pygrappa/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-vq3t3qkm
cwd: /tmp/pip-install-c7s46can/pygrappa/
Complete output (109 lines):
running bdist_wheel
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "pygrappa.cgrappa" sources
building extension "pygrappa.grog_powers" sources
building extension "pygrappa.grog_gridding" sources
build_src: building npy-pkg config files
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/benchmarks
copying benchmarks/__init__.py -> build/lib.linux-x86_64-3.6/benchmarks
copying benchmarks/benchmark.py -> build/lib.linux-x86_64-3.6/benchmarks
creating build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/cgsense.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grappa_kdtree.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/igrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/lustig_grappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/simple_pruno.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/ttgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/__init__.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/gfactor.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/radialgrappaop.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/seggrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/pruno.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/mdgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/kernels.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/nlgrappa_matlab.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/nlgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/hpgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/slicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/sense1d.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/splitslicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/ncgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/tgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/pars.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/kspa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grappaop.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grog.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/vcgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grappa.py -> build/lib.linux-x86_64-3.6/pygrappa
creating build/lib.linux-x86_64-3.6/utils
copying utils/__init__.py -> build/lib.linux-x86_64-3.6/utils
copying utils/radial_sms_sim.py -> build/lib.linux-x86_64-3.6/utils
copying utils/gridder.py -> build/lib.linux-x86_64-3.6/utils
copying utils/find_acs.py -> build/lib.linux-x86_64-3.6/utils
copying utils/disjoint_csm.py -> build/lib.linux-x86_64-3.6/utils
copying utils/findRectangle2d.py -> build/lib.linux-x86_64-3.6/utils
copying utils/gaussian_csm.py -> build/lib.linux-x86_64-3.6/utils
creating build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_mdgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/__init__.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_igrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_vcgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_hpgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_cgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/helpers.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_grappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
creating build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_splitslicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_gfactor.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_nlgrappa_matlab.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_gridding.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/mdgrappa_autofind_calib.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/inverse_grog.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_tgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_cgsense.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_grappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/__init__.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_mdgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_pars.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/primefac_grog_cardiac.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/primefac_grog.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_hpgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/use_memmap.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_grappaop.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_radialgrappaop.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/bart_pars.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/7t_knee_data.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_vcgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_nlgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/tikhonov_regularization.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_ttgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/bart_kspa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_ncgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_seggrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_sense1d.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_cgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_igrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_slicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
building 'pygrappa.cgrappa' extension
compiling C++ sources
C compiler: x86_64-linux-gnu-g++ -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC
creating build/temp.linux-x86_64-3.6/src
compile options: '-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I./src/ -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/include/python3.6m -c'
x86_64-linux-gnu-g++: ./src/cgrappa.cpp
x86_64-linux-gnu-g++: ./src/get_sampling_patterns.cpp
error: Command "x86_64-linux-gnu-g++ -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I./src/ -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/include/python3.6m -c ./src/cgrappa.cpp -o build/temp.linux-x86_64-3.6/src/cgrappa.o -MMD -MF build/temp.linux-x86_64-3.6/src/cgrappa.o.d" failed with exit status 127
----------------------------------------
ERROR: Failed building wheel for pygrappa
Running setup.py clean for pygrappa
Failed to build pygrappa
Installing collected packages: scipy, six, cycler, kiwisolver, pyparsing, python-dateutil, matplotlib, tqdm, pillow, imageio, tifffile, PyWavelets, decorator, networkx, scikit-image, ssfp, phantominator, pygrappa
Running setup.py install for pygrappa ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c7s46can/pygrappa/setup.py'"'"'; __file__='"'"'/tmp/pip-install-c7s46can/pygrappa/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7hvszict/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/pygrappa
cwd: /tmp/pip-install-c7s46can/pygrappa/
Complete output (109 lines):
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "pygrappa.cgrappa" sources
building extension "pygrappa.grog_powers" sources
building extension "pygrappa.grog_gridding" sources
build_src: building npy-pkg config files
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/benchmarks
copying benchmarks/__init__.py -> build/lib.linux-x86_64-3.6/benchmarks
copying benchmarks/benchmark.py -> build/lib.linux-x86_64-3.6/benchmarks
creating build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/cgsense.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grappa_kdtree.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/igrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/lustig_grappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/simple_pruno.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/ttgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/__init__.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/gfactor.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/radialgrappaop.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/seggrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/pruno.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/mdgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/kernels.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/nlgrappa_matlab.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/nlgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/hpgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/slicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/sense1d.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/splitslicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/ncgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/tgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/pars.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/kspa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grappaop.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grog.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/vcgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grappa.py -> build/lib.linux-x86_64-3.6/pygrappa
creating build/lib.linux-x86_64-3.6/utils
copying utils/__init__.py -> build/lib.linux-x86_64-3.6/utils
copying utils/radial_sms_sim.py -> build/lib.linux-x86_64-3.6/utils
copying utils/gridder.py -> build/lib.linux-x86_64-3.6/utils
copying utils/find_acs.py -> build/lib.linux-x86_64-3.6/utils
copying utils/disjoint_csm.py -> build/lib.linux-x86_64-3.6/utils
copying utils/findRectangle2d.py -> build/lib.linux-x86_64-3.6/utils
copying utils/gaussian_csm.py -> build/lib.linux-x86_64-3.6/utils
creating build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_mdgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/__init__.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_igrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_vcgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_hpgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_cgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/helpers.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
copying pygrappa/tests/test_grappa.py -> build/lib.linux-x86_64-3.6/pygrappa/tests
creating build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_splitslicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_gfactor.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_nlgrappa_matlab.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_gridding.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/mdgrappa_autofind_calib.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/inverse_grog.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_tgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_cgsense.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_grappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/__init__.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_mdgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_pars.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/primefac_grog_cardiac.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/primefac_grog.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_hpgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/use_memmap.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_grappaop.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_radialgrappaop.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/bart_pars.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/7t_knee_data.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_vcgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_nlgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/tikhonov_regularization.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_ttgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/bart_kspa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_ncgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_seggrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_sense1d.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_cgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_igrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
copying pygrappa/examples/basic_slicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa/examples
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
building 'pygrappa.cgrappa' extension
compiling C++ sources
C compiler: x86_64-linux-gnu-g++ -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC
creating build/temp.linux-x86_64-3.6/src
compile options: '-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I./src/ -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/include/python3.6m -c'
x86_64-linux-gnu-g++: ./src/cgrappa.cpp
x86_64-linux-gnu-g++: ./src/get_sampling_patterns.cpp
error: Command "x86_64-linux-gnu-g++ -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I./src/ -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/include/python3.6m -c ./src/cgrappa.cpp -o build/temp.linux-x86_64-3.6/src/cgrappa.o -MMD -MF build/temp.linux-x86_64-3.6/src/cgrappa.o.d" failed with exit status 127
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c7s46can/pygrappa/setup.py'"'"'; __file__='"'"'/tmp/pip-install-c7s46can/pygrappa/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7hvszict/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/pygrappa Check the logs for full command output.
I find it very hard to read and I am wondering whether this error rings a bell for anyone.
This is the singularity recipe file I used:
Bootstrap: docker
From: ubuntu:16.04
%help
Singularity container for GRAPPA.
%post
apt update -y
apt install software-properties-common curl -y
apt update -y
add-apt-repository ppa:deadsnakes/ppa -y
apt update -y
apt install python3.6 python3.6-dev -y
curl https://bootstrap.pypa.io/get-pip.py | python3.6
pip3 install numpy
pip3 install pygrappa
Compiling using new distutils branch on Windows 10 and running python -m pygrappa.examples.basic_radialgrappaop
gives the following error:
ValueError: Buffer dtype mismatch, expected 'const long' but got 'long long'
Currently setup.py enforces python version >= 3.6, could be lower.
Because cython needs location of numpy includes, numpy is imported by setup.py. This means installation will fail when numpy is not previously installed.
igrappa
moves coil axis to back but never returns it to original positionGiven the assumption that the ACS region is a hyper-rectangle with origin at the center, we would like to be able to able to detect it inside of kspace
instead of passing it separately in calib
.
cgsense
can only handle 2d images currently, would be easy and useful to extent to n-dimensional reconstruction.
Hi Nicholas,
thank you for this amazing python implementation!
I tried to use the grog and got an error, when changing the location of the coil axis.
This is because using np.moveaxis to move the coils to the back makes the ndarray not C-contiguous.
A fix would be to apply np.ascontiguousarray() after the np.moveaxis()-operation.
Best regards,
Olli
validP array sometimes turns out to be a 0-d array and can't be iterated over. I don't know why this happens.
Need a better C++ implementation
complex128
(see #79)When an even kernel dimension is used, e.g., kernel_size=(4, 4), grappa function breaks. lustig_grappa can deal with this, however.
use_primefac option uses library which is not pip installable and which includes libraries not generally present on linux systems. Find another way to get prime factorizations?
pygrappa/pygrappa/igrappa.py:128: RuntimeWarning: invalid value encountered in double_scalars
p = Tp/(k*Fp)
pygrappa/pygrappa/radialgrappaop.py
Line 131 in 025ed54
Please add the line
version = "0.26.1" to the [project] section of your pyproject.toml file
When I try to install your package using pip I get the following error:
pip install ./pygrappa
Processing ./pygrappa
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [53 lines of output]
+ meson setup /Users/doug/Documents/Development/Python/pygrappa /Users/doug/Documents/Development/Python/pygrappa/.mesonpy-mjp94sf1 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/Users/doug/Documents/Development/Python/pygrappa/.mesonpy-mjp94sf1/meson-python-native-file.ini
The Meson build system
Version: 1.3.2
Source dir: /Users/doug/Documents/Development/Python/pygrappa
Build dir: /Users/doug/Documents/Development/Python/pygrappa/.mesonpy-mjp94sf1
Build type: native build
Project name: pygrappa
Project version: 0.26.1
C compiler for the host machine: cc (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.1.0.2.5)")
C linker for the host machine: cc ld64 1022.1
C++ compiler for the host machine: c++ (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.1.0.2.5)")
C++ linker for the host machine: c++ ld64 1022.1
Host machine cpu family: aarch64
Host machine cpu: aarch64
Program cython found: YES (/private/var/folders/rf/h90r9kfj6gj7qtt8csjzlhgc0000gn/T/pip-build-env-5xrqw7ue/overlay/bin/cython)
Program python found: YES (/opt/homebrew/Caskroom/miniforge/base/bin/python3.10)
Found pkg-config: YES (/opt/homebrew/bin/pkg-config) 0.29.2
Run-time dependency python found: YES 3.10
Program pygrappa/utils/cythoner.py found: YES (/opt/homebrew/Caskroom/miniforge/base/bin/python3.10 /Users/doug/Documents/Development/Python/pygrappa/pygrappa/utils/cythoner.py)
Compiler for C supports arguments -Wno-maybe-uninitialized: NO
Compiler for C supports arguments -Wno-discarded-qualifiers: NO
Compiler for C supports arguments -Wno-empty-body: YES
Compiler for C supports arguments -Wno-implicit-function-declaration: YES
Compiler for C supports arguments -Wno-parentheses: YES
Compiler for C supports arguments -Wno-switch: YES
Compiler for C supports arguments -Wno-unused-label: YES
Compiler for C supports arguments -Wno-unused-variable: YES
Compiler for C++ supports arguments -Wno-cpp: YES
Compiler for C++ supports arguments -Wno-deprecated-declarations: YES
Compiler for C++ supports arguments -Wno-class-memaccess: NO
Compiler for C++ supports arguments -Wno-format-truncation: NO
Compiler for C++ supports arguments -Wno-non-virtual-dtor: YES
Compiler for C++ supports arguments -Wno-sign-compare: YES
Compiler for C++ supports arguments -Wno-switch: YES
Compiler for C++ supports arguments -Wno-terminate: NO
Compiler for C++ supports arguments -Wno-unused-but-set-variable: YES
Compiler for C++ supports arguments -Wno-unused-function: YES
Compiler for C++ supports arguments -Wno-unused-local-typedefs: YES
Compiler for C++ supports arguments -Wno-unused-variable: YES
Compiler for C++ supports arguments -Wno-int-in-bool-context: YES
Build targets in project: 4
pygrappa 0.26.1
User defined options
Native files: /Users/doug/Documents/Development/Python/pygrappa/.mesonpy-mjp94sf1/meson-python-native-file.ini
buildtype : release
b_ndebug : if-release
b_vscrt : md
Found ninja-1.11.1.git.kitware.jobserver-1 at /private/var/folders/rf/h90r9kfj6gj7qtt8csjzlhgc0000gn/T/pip-build-env-5xrqw7ue/overlay/bin/ninja
('\x1b[31m',)meson-python: error: Required "project.version" field is missing and not declared as dynamic
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Adding the version line to my local copy allows the build to proceed.
Thanks.
GROG should be be written as a templated function to deal with multiple datatypes, currently coded only for double types.
@zaccharieramzi, some of the issues you've been noticing with runtime might be due to the extra work pygrappa does to make sure it works for any arbitrarily sampling pattern. A lot of work is spent finding out what the unique sampling patterns (geometries) are and where the targets need to be interpolated -- this could be done away with if regular under-sampling was assumed.
I do like that pygrappa can "just work": if you hand it a set of under-sampled data it will do a reasonable thing (with the newest addition of an ACS region finder, the user doesn't even need to supply a calibration region if it is embedded in the data). But for users that need more efficiency/speed, it would be nice to provide a GRAPPA implementation more in line with regular under-sampling, e.g. similar to the GRAPPA Recon Tools found here.
There's a consistency check meant to ensure that (kx, ky) is shaped correctly, but this dies on real traj data (usually single precision). Maybe add an option to skip check? Lower tolerance?
Add link to readme pointing to the readthedocs page
Hi, thanks very much for this implementation.
I tried to use cgrappa
with np.complex64
data and got the following error:
ValueError Traceback (most recent call last)
<ipython-input-4-2802ffa5c73b> in <module>
12 # coil_axis=-1 is default, so if coil dimension is last we don't
13 # need to explicity provide it
---> 14 res = cgrappa(kspace, calib, kernel_size=(5, 5))
15 sx, sy, ncoils = res.shape[:]
src/cgrappa.pyx in cgrappa.cgrappa()
ValueError: Buffer dtype mismatch, expected 'double complex' but got 'complex float'
The code to reproduce the error is the following:
from pygrappa import cgrappa
import numpy as np
kspace = np.random.normal(size=[640, 372, 15])
kspace = kspace.astype(np.complex64)
sx, sy, ncoils = kspace.shape[:] # center 20 lines are ACS
ctr, pd = int(sy/2), 10
calib = kspace[:, ctr-pd:ctr+pd, :].copy() # call copy()!
# coil_axis=-1 is default, so if coil dimension is last we don't
# need to explicity provide it
res = cgrappa(kspace, calib, kernel_size=(5, 5))
sx, sy, ncoils = res.shape[:]
Basic unit tests to make sure things don't break too bad during development/maintenance
Hi,
I wanted to have some clarifications on the kernel_size
argument of the grappa methods.
Let's say that I undersample in the y direction, with a rate of 5, meaning that one line out of 5 in the y direction is sampled.
How should I set ky
if I want to consider only the 2 neighbouring sampled lines to fill in a non-sampled line? I thought it should be 5, but with this number I am having weird results where not all the kspace undersampled lines are filled.
In the figure, the first image is the kspace grappa reconstruction, the second is the (retrospectively) undersampled kspace, and the third is the original ground truth kspace.
I used cgrappa
with a kernel size of (5, 5)
.
If you want I can try to give you a reproducible example with the data I am using (fastMRI).
First, I am very impressed with your implementations.
However, when applying the grappa for my data which has image size of 300x192
And I found out that neither grappa.py or cgrappa.py (except for lustig_grappa) works on these images.
Thank you.
utils module not included in pip install, breaks imports in init.py
pygrappa/igrappa.py:151: in igrappa
W = {key:(1 - p)*Wn0 + p*W0 for (key, Wn0), (_, W0) in zip(Wn.items(), W.items())}
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <zip object at 0x7fd4b073ce88>
> W = {key:(1 - p)*Wn0 + p*W0 for (key, Wn0), (_, W0) in zip(Wn.items(), W.items())}
E ValueError: operands could not be broadcast together with shapes (24,4) (40,4)
pygrappa/igrappa.py:151: ValueError
_ TestiGRAPPA.test_recon_shepp_logan2d_M30_N32_nc4_calib2d_cM10_cN10_undersample_y2_complex64 _
Mimic numpy/scipy style for building C/C++ sources
Hello,
I tried to use your code to reconstruct 3D anatomical brain MRI data of 1mm iso resolution with the mdgrappa function, it works well even if it is time-consuming, however when going to 0.7mm data with a large matrix (252, 52, 350, 256), and 52 the number of coils. ACS built-in (252, 52, 33, 256), the program crashes as it tries to allocate 471 GB of Ram. Do you please have an optimized version of your code to manage better the compute server resources?
The configuration I have:
Thank you,
Zakaria
Command: pip3 install pygrappa --user
Problems:
Windows 10, python 3.7.3, pygrappa v0.4.0.
In clean virtual environment
command: pip install pygrappa
Output:
...
building 'pygrappa.cgrappa' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
env: macOS 1015.4
acOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.4.0
(base) abu:~ abu$ pip install pygrappa
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pygrappa
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/5c/c2/fd4532079321ae7cc88f8cf5fc96a96b00f918b162d803011d8f83e017c4/pygrappa-0.21.1.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/my/s_lbvtcn6nb3mylc5cvtp0240000gn/T/pip-install-xg7ghxo8/pygrappa/setup.py", line 8, in
from setup_helpers import get_build_ext_override
ModuleNotFoundError: No module named 'setup_helpers'
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/my/s_lbvtcn6nb3mylc5cvtp0240000gn/T/pip-install-xg7ghxo8/pygrappa/
It would probably be best to group GRAPPA-like functions under one banner and SENSE-like things under another one instead of having a menagerie of functions scattered about the pygrappa namespace
Proposed:
res = pygrappa.grappa(kspace, calib=None, method='grappa', coil_axis=-1, options=None)
method
specifies which flavor of GRAPPA to use for reconstruction:
grappa
: vanilla GRAPPA with mdgrappa
backendtgrappa
: TGRAPPAoptions
is a dictionary containing options specific to the chosen method
, e.g.,:
lamda
time_axis
Similarly, SENSE-like methods go under the umbrella:
res = pygrappa.sense(kspace, sens, coil_axis=-1, options=None)
It appears that everything calling cgrappa
is getting the following the error:
DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
Readthedocs missing pygrappa.cgrappa
Continuous integration tests to make sure builds and unit tests pass before release
PyGrappa Setup Barfs on CentOS 7, python36.
Installing collected packages: pygrappa
Running setup.py install for pygrappa ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python36 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sm_cp7o2/pygrappa/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sm_cp7o2/pygrappa/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vyb4bb48/install-record.txt --single-version-externally-managed --compile --user --prefix=
cwd: /tmp/pip-install-sm_cp7o2/pygrappa/
Complete output (47 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/tests
copying tests/test_basic_recon.py -> build/lib.linux-x86_64-3.6/tests
copying tests/benchmark.py -> build/lib.linux-x86_64-3.6/tests
copying tests/__init__.py -> build/lib.linux-x86_64-3.6/tests
copying tests/test_validP_issue.py -> build/lib.linux-x86_64-3.6/tests
creating build/lib.linux-x86_64-3.6/utils
copying utils/disjoint_csm.py -> build/lib.linux-x86_64-3.6/utils
copying utils/__init__.py -> build/lib.linux-x86_64-3.6/utils
copying utils/gaussian_csm.py -> build/lib.linux-x86_64-3.6/utils
creating build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/tgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grappaop.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/slicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/vcgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/igrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/splitslicegrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/grappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/seggrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/hpgrappa.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/__init__.py -> build/lib.linux-x86_64-3.6/pygrappa
copying pygrappa/lustig_grappa.py -> build/lib.linux-x86_64-3.6/pygrappa
running build_ext
building 'pygrappa.cgrappa' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Isrc/ -I/usr/include/python3.6m -I/xxx/xxx/.local/lib/python3.6/site-packages/numpy/core/include -c src/cgrappa.cpp -o build/temp.linux-x86_64-3.6/src/cgrappa.o
In file included from /xxx/xxx/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830:0,
from /xxx/xxx/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /xxx/xxx/.local/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from src/cgrappa.cpp:636:
/xxx/xxx/.local/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Isrc/ -I/usr/include/python3.6m -I/xxx/xxx/.local/lib/python3.6/site-packages/numpy/core/include -c src/get_sampling_patterns.cpp -o build/temp.linux-x86_64-3.6/src/get_sampling_patterns.o
src/get_sampling_patterns.cpp: In function ‘std::map<long long unsigned int, std::vector<unsigned int> > get_sampling_patterns(int*, unsigned int, unsigned int, unsigned int, unsigned int)’:
src/get_sampling_patterns.cpp:45:17: error: ‘stderr’ was not declared in this scope
fprintf(stderr, "Something wild is happening with kernel size, choosing (ksx, ksy) = (5, 5).\n");
^
src/get_sampling_patterns.cpp:45:104: error: ‘fprintf’ was not declared in this scope
fprintf(stderr, "Something wild is happening with kernel size, choosing (ksx, ksy) = (5, 5).\n");
^
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python36 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sm_cp7o2/pygrappa/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sm_cp7o2/pygrappa/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vyb4bb48/install-record.txt --single-version-externally-managed --compile --user --prefix= Check the logs for full command output.
I think it has to do with get_sampling_patterns.cpp implementation. Not giving expected size patterns back,
Probably a static readthedocs Sphinx documentation
7T knee data R=3 breaks cgrappa
Tried doing a clever thing to quickly compute conjugate coils, but it will break for non-square matrices or square matrix with even size dimension
Hi,
Thank you for making this awesome project! Its has exactly the parts I missed for my project.
Unfortunately, I noticed mdgrappa to be quite slow even on a powerful pc.
Would it be possible to accelerate this function by making use of mkl or openblas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.