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

Connectivity: compute_matrices script #1031

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

EmmaRenauld
Copy link
Contributor

Refactored the scil_connectivity_compute_matrices.py script:

  • Took out the main computation part and put it in connectivity.connectivity file
  • (also renamed connectivity.connectivity_tools to connectivity.matrix_too0ls)
  • Clarified the docstring
    • Note that I already mention the scil_connectivity_compute_simple_matrix.py, which does not exist, but in the end I think that this PR is big enough. Will add it soon in another PR.
    • Please help me describe the --similarity option better.
  • Removed the --maps option, as discussed with François and Arnaud offline.
  • Removed one buggy logging.info: the -len(label_list) could end up in a negative number of total_elem if some diagonal values were not found.

image

  • Now all headers compatibility are done before loading (except for the --similarity folder)

In short, the code is simplified a lot, but the result should be exactly the same, if you want to test with some data!

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 62.03704% with 82 lines in your changes missing coverage. Please review.

Project coverage is 68.99%. Comparing base (546f1a9) to head (a112c4f).
Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1031      +/-   ##
==========================================
+ Coverage   68.89%   68.99%   +0.09%     
==========================================
  Files         434      435       +1     
  Lines       22646    22662      +16     
  Branches     3078     3077       -1     
==========================================
+ Hits        15603    15635      +32     
+ Misses       5727     5710      -17     
- Partials     1316     1317       +1     
Components Coverage Δ
Scripts 69.91% <72.64%> (+0.29%) ⬆️
Library 67.72% <49.49%> (-0.18%) ⬇️

Copy link
Member

@frheault frheault left a comment

Choose a reason for hiding this comment

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

I used the new script on older data to compare before vs after.

My command was scil_connectivity_compute_matrices.py Transform_Data/sub-001_ses-1__decompose_warped_mni.h5 Transform_Data/sub-001_ses-1__labels_warped_mni_int16.nii.gz --volume vol.npy --streamline_count sc.npy --length len.npy --metrics Transform_Metrics/sub-001_ses-1__fa_mni.nii.gz fa.npy --include_dps dps -f (works with the master)

This is my error:

Traceback (most recent call last):
  File "/home/rhef1902/VirtualEnvs/basic_scilpy_3_10/bin/scil_connectivity_compute_matrices.py", line 33, in <module>
    sys.exit(load_entry_point('scilpy', 'console_scripts', 'scil_connectivity_compute_matrices.py')())
  File "/home/rhef1902/Libraries/scilpy/scripts/scil_connectivity_compute_matrices.py", line 260, in main
    outputs.append(compute_connectivity_matrices_from_hdf5(
  File "/home/rhef1902/Libraries/scilpy/scilpy/connectivity/connectivity.py", line 188, in compute_connectivity_matrices_from_hdf5
    for dps_key in hdf5_file[key].keys():
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/rhef1902/VirtualEnvs/basic_scilpy_3_10/lib/python3.10/site-packages/h5py/_hl/group.py", line 357, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5o.pyx", line 189, in h5py.h5o.open
KeyError: 'Unable to synchronously open object (invalid identifier type to function)'

I am one Python 3.10.12 (and I got the same error in Python 3.11.6)

scripts/scil_connectivity_compute_matrices.py Show resolved Hide resolved
@EmmaRenauld
Copy link
Contributor Author

I used the new script on older data to compare before vs after.

Could you please send me your data? Thanks!

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.

2 participants