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

Generate HDF5 from TRKs #985

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

Conversation

frheault
Copy link
Member

@frheault frheault commented Apr 23, 2024

Quick description

New script to generate a HDF5 in the same style as for connectomics from a list of TRKs.

(Tests for the script will come this week)

...

Type of change

Check the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Provide data, screenshots, command line to test (if relevant)

...

Checklist

  • My code follows the style guidelines of this project (run autopep8)
  • I added relevant citations to scripts, modules and functions docstrings and descriptions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I moved all functions from the script file (except the argparser and main) to scilpy modules
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@pep8speaks
Copy link

pep8speaks commented Apr 23, 2024

Hello @frheault, Thank you for updating !

Line 40:1: W293 blank line contains whitespace

Comment last updated at 2024-05-22 20:24:47 UTC

Copy link

codecov bot commented Apr 23, 2024

Codecov Report

Attention: Patch coverage is 83.63636% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 68.05%. Comparing base (9b79ea4) to head (cdca28d).
Report is 39 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #985      +/-   ##
==========================================
+ Coverage   68.01%   68.05%   +0.04%     
==========================================
  Files         419      420       +1     
  Lines       21567    21667     +100     
  Branches     3241     3257      +16     
==========================================
+ Hits        14668    14745      +77     
- Misses       5608     5632      +24     
+ Partials     1291     1290       -1     
Components Coverage Δ
Scripts 69.01% <83.63%> (+0.04%) ⬆️
Library 66.59% <ø> (+0.03%) ⬆️

@EmmaRenauld
Copy link
Contributor

(Tests for the script will come this week)

This week, hein ;)

help='Save empty connections. Then, the list of possible '
p.add_argument('--save_empty', nargs='?', metavar='labels_list',
dest='labels_list', const=True,
help='Save empty connections. The list of possible '
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add in the description that the labels_list is now facultative.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not change the dest to labels_file instead. It sounds like args.labels_list should be a list.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could change that later in all the scripts and functions.

scripts/scil_tractogram_convert_trk_to_hdf5.py Outdated Show resolved Hide resolved
|-- LABEL1_LABEL2.trk
|-- [...]
|-- LABEL90_LABEL90.trk

Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't read the code yet. But from a user point of view reading this doc, here's a question: what happens if one is missing? Ex, if there is not file LABEL1_LABEL2.trk. Do you infer from other files all existing labels? Do you raise a warning? Will it work nonetheless?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no problem with missing labels, this is why all the other scripts need a labels_list (to know what is and what is not missing).

I added: "The value of first labels should be smaller or equal to the second labels.
Connectivity scripts in scilpy only consider the upper triangular part of the
connectivity matrix."

scripts/scil_tractogram_convert_trk_to_hdf5.py Outdated Show resolved Hide resolved
scripts/scil_tractogram_convert_trk_to_hdf5.py Outdated Show resolved Hide resolved
p.add_argument('in_bundles', nargs='+',
help='Path of the input connections or bundles.')
p.add_argument('out_hdf5',
help='Output HDF5 filename (.h5).')
Copy link
Contributor

Choose a reason for hiding this comment

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

I had a question concerning this. In dwi_ml, I save my hdf5 files as .hdf5, not .h5. Any difference? Do we always accept them? Should we change the doc in all hdf5 scripts?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no difference, when I looked at stuff done in Vanderbilt and Dipy, they used .h5 so I used the same
https://figshare.com/articles/dataset/DIPY_Synb0_weights/20277522/2

This script is useful to convert a set of connections or bundles to a single
HDF5 file. The HDF5 file will contain a group for each input file, with the
streamlines stored in the specified space and origin.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe, something like: Most of our scripts using hdf5 files deal with any space and origin, so just choose your favorite option?

Copy link
Member Author

Choose a reason for hiding this comment

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

All of my scripts for connectivity assume vox/corner (to avoid as much computation on 100k connections).

So I added: (keep the default if you are going to use the connectivity scripts in scilpy).

scripts/scil_tractogram_convert_trk_to_hdf5.py Outdated Show resolved Hide resolved
scripts/scil_tractogram_convert_trk_to_hdf5.py Outdated Show resolved Hide resolved
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.

None yet

3 participants