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

[WIP] Adding b-tensor encoding scripts like compute_fodf/frf and metrics #425

Merged
merged 80 commits into from
Mar 18, 2023

Conversation

karanphil
Copy link
Contributor

Here are three scripts scil_compute_memsmt_frf.py, scil_compute_memsmt_fofd.py and scil_compute_divide.py enabling the use of tensor-valued dMRI data. The scripts are almost Scilpy ready, but the side modules are messy. This needs to be cleaned up before the PR is ready.

@pep8speaks
Copy link

pep8speaks commented Mar 2, 2021

Hello @karanphil, Thank you for updating !

Line 101:1: W293 blank line contains whitespace

Comment last updated at 2022-06-30 14:32:43 UTC

Philippe Karan added 2 commits March 8, 2021 10:30
@arnaudbore arnaudbore changed the title Adding b-tensor encoding scripts like compute_fodf/frf and metrics (WIP) [WIP] Adding b-tensor encoding scripts like compute_fodf/frf and metrics Mar 23, 2021
@arnaudbore arnaudbore added this to the Release 1.1.1 milestone Apr 9, 2021
@arnaudbore arnaudbore removed this from the Release 1.1.1 milestone Apr 21, 2021
@scil-admin scil-admin requested a review from arnaudbore May 27, 2021 14:21
@scil-admin
Copy link

@scil-admin
Copy link

@scil-admin
Copy link

@scil-admin
Copy link

@scil-admin
Copy link

@scil-admin
Copy link

@scil-admin
Copy link

@scil-admin
Copy link

@scil-admin
Copy link

@arnaudbore
Copy link
Contributor

@arnaudbore
Copy link
Contributor

@arnaudbore
Copy link
Contributor

@arnaudbore
Copy link
Contributor

@arnaudbore
Copy link
Contributor

@arnaudbore
Copy link
Contributor

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore arnaudbore requested a review from mdesco March 9, 2023 00:53
@karanphil
Copy link
Contributor Author

@arnaudbore @mdesco I cleaned up the code and changed a few things. I think it's ready for testing. Here is some data.

https://usherbrooke-my.sharepoint.com/:f:/g/personal/karp2601_usherbrooke_ca/EqLMY8wcU85EjGT4J19kAhABBgsdVS3EF3QgVsdDlG23jA?e=TTlnYQ

Here are examples of command lines for the scripts.

scil_compute_memsmt_frf.py wm_frf.txt gm_frf.txt csf_frf.txt --in_dwis dwi_lin_eddy_corrected_n4.nii.gz dwi_sph_eddy_corrected_n4.nii.gz --in_bvals dwi_lin.bval dwi_sph.bval --in_bvecs dwi_lin_eddy_corrected.eddy_rotated_bvecs dwi_sph_eddy_corrected.eddy_rotated_bvecs --in_bdeltas 1 0 --mask mean_b0_lin_topup_bet_mask.nii.gz --mask_wm wm_mask.nii.gz --mask_gm gm_mask.nii.gz --mask_csf csf_mask.nii.gz --roi_center 45 51 29 --wm_frf_mask wm_frf_mask.nii.gz --gm_frf_mask gm_frf_mask.nii.gz --csf_frf_mask csf_frf_mask.nii.gz -f

scil_compute_memsmt_fodf.py wm_frf.txt gm_frf.txt csf_frf.txt --in_dwis dwi_lin_eddy_corrected_n4.nii.gz dwi_sph_eddy_corrected_n4.nii.gz --in_bvals dwi_lin.bval dwi_sph.bval --in_bvecs dwi_lin_eddy_corrected.eddy_rotated_bvecs dwi_sph_eddy_corrected.eddy_rotated_bvecs --in_bdeltas 1 0 --mask mean_b0_lin_topup_bet_mask.nii.gz --processes 8 -f

scil_compute_divide.py --in_dwis dwi_lin_eddy_corrected_n4.nii.gz dwi_sph_eddy_corrected_n4.nii.gz --in_bvals dwi_lin.bval dwi_sph.bval --in_bvecs dwi_lin_eddy_corrected.eddy_rotated_bvecs dwi_sph_eddy_corrected.eddy_rotated_bvecs --in_bdeltas 1 0 --mask mean_b0_lin_topup_bet_mask.nii.gz --fa fa.nii.gz --processes 8 -f

Thanks!

Here is the data.

@arnaudbore arnaudbore requested a review from frheault March 9, 2023 15:17
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

Copy link
Contributor

@mdesco mdesco left a comment

Choose a reason for hiding this comment

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

Minor suggestions for @karanphil
All the CVX errors seem like warnings, the output is created and it looks fine.

docs/source/documentation/btensor_scripts.rst Show resolved Hide resolved
If you want to do DIVIDE with b-tensor data, you should use the following command. It will save files for the MD, uFA, OP, MK_I, MK_A and MK_T. This script should run in about 1-2 hours for a full brain.
::

scil_compute_divide.py --in_dwis dwi_linear.nii.gz dwi_planar.nii.gz dwi_spherical.nii.gz --in_bvals dwi_linear.bval dwi_planar.bval dwi_spherical.bval --in_bvecs dwi_linear.bvec dwi_planar.bvec dwi_spherical.bvec --in_bdeltas 1 -0.5 0 --mask mask.nii.gz --fa fa.nii.gz --processes 8 -f
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also find a way to put this test data somewhere for people to try? Maybe a cropped version so it is light?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have the planar data, this example was very general.

scripts/scil_compute_memsmt_frf.py Show resolved Hide resolved


if __name__ == "__main__":
main()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm getting this weird error when running on my mac:
(CVXPY) Mar 16 01:00:41 PM: Encountered unexpected exception importing solver SCS:
ImportError('dlopen(/Users/desm2239/my_env/scilpy_p10/lib/python3.10/site-packages/_scs_direct.cpython-310-darwin.so, 0x0002): Symbol not found: ___emutls_get_address\n Referenced from: <17C4D491-3B6D-344A-8328-189690282A3A> /Users/desm2239/my_env/scilpy_p10/lib/python3.10/site-packages/scs/.dylibs/libopenblasp-r0.3.21.dylib\n Expected in: /Applications/freesurfer/lib/gcc/lib/libgomp.1.dylib')

Is this a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I never got this error with Linux. This is weird. @arnaudbore what do you think? It looks like cvxpy tries to use some package that Max doesn't have.



if __name__ == "__main__":
main()
Copy link
Contributor

Choose a reason for hiding this comment

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

Same error again.

(CVXPY) Mar 16 01:05:10 PM: Encountered unexpected exception importing solver SCS:

ImportError('dlopen(/Users/desm2239/my_env/scilpy_p10/lib/python3.10/site-packages/_scs_direct.cpython-310-darwin.so, 0x0002): Symbol not found: ___emutls_get_address\n Referenced from: <17C4D491-3B6D-344A-8328-189690282A3A> /Users/desm2239/my_env/scilpy_p10/lib/python3.10/site-packages/scs/.dylibs/libopenblasp-r0.3.21.dylib\n Expected in: /Applications/freesurfer/lib/gcc/lib/libgomp.1.dylib')

Copy link
Contributor

Choose a reason for hiding this comment

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

/Users/desm2239/my_env/scilpy_p10/lib/python3.10/site-packages/cvxpy/problems/problem.py:1385: UserWarning: Solution may be inaccurate. Try another solver, adjusting the solver settings, or solve with verbose=True for more information.
warnings.warn(



if __name__ == "__main__":
main()
Copy link
Contributor

Choose a reason for hiding this comment

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

(CVXPY) Mar 16 03:22:46 PM: Encountered unexpected exception importing solver SCS:
ImportError('dlopen(/Users/desm2239/my_env/scilpy_p10/lib/python3.10/site-packages/_scs_direct.cpython-310-darwin.so, 0x0002): Symbol not found: ___emutls_get_address\n Referenced from: <17C4D491-3B6D-344A-8328-189690282A3A> /Users/desm2239/my_env/scilpy_p10/lib/python3.10/site-packages/scs/.dylibs/libopenblasp-r0.3.21.dylib\n Expected in: /Applications/freesurfer/lib/gcc/lib/libgomp.1.dylib')

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

Copy link
Contributor

@mdesco mdesco left a comment

Choose a reason for hiding this comment

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

Tested on Laurent's mac. The errors and warnings are not there.
Output are the same as mine. So, correct the small edits and good to merge.

Good job!

@arnaudbore arnaudbore merged commit 5845eb2 into scilus:master Mar 18, 2023
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.

5 participants