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

Scripts to project 3D and 4D maps to streamline points and perform math operations in space of streamline points #810

Merged

Conversation

grahamlittlephd
Copy link
Contributor

@grahamlittlephd grahamlittlephd commented Nov 16, 2023

Quick description

Scripts for projecting and analyzing 3D and 4D data on streamline points. Useful for analyzing different image modalities in the space of streamlines. For example, a correlation could be calculated from rsfMRI timeseries interpolated at streamline endpoints.

scil_tractogram_project_map_to_streamlines.py - takes a tractogram and map as input and interpolates the data from the map to every point for each streamline.

scil_tractogram_dpp_math.py - computes various mathematical operations for all points for each streamline or at each point independently.

Simple Example usage:
Projects fa data to each streamline point
scil_tractogram_project_map_to_streamlines.py in.trk fa.trk --in_maps fa.nii.gz --out_ddp_name fa

_Calculates mean fa for each streamline
scil_tractogram_dpp_math.py mean fa.trk fa_mean_per_streamline.trk --mode dps --in_dpp_name fa --out_name fa_mean

_Could then color streamlines using current functionality
scil_tractogram_assign_custom_color.py fa_mean_per_streamline.trk fa_mean_per_streamline_colored.trk --use_dps fa_mean --min_cmap 0

Example output of mean fa (jet color map) calculated for each streamline for tractography across the caudalenticular gray matter bridges:
image

Here is toy example and data for testing purposes:
toy_example_usage_project_map_to_two_streamlines.zip

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 Nov 16, 2023

Hello @grahamlittlephd, Thank you for updating !

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-02-19 17:58:10 UTC

@arnaudbore arnaudbore self-requested a review November 16, 2023 20:57
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@EmmaRenauld EmmaRenauld added the WIP Work In Progress label Nov 21, 2023
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

1 similar comment
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

1 similar comment
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

4 similar comments
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@EmmaRenauld
Copy link
Contributor

Thanks! I will cite your scripts in my upcoming PR.

Let's already give it a good name fitting with the whole renaming fashion.
scil_project_map_to_streamlines.py --> scil_tractogram_project_map_to_streamlines.
(Mine will be scil_project_streamlines_to_map --> scil_tractogram_project_streamlines_to_map)

(Question for you Graham. Would it be a better English to say project_streamlines_onto_map??)

Copy link
Contributor

@EmmaRenauld EmmaRenauld left a comment

Choose a reason for hiding this comment

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

Thanks!

I tested both scripts. Everything seems to work correctly! I still added quite a few comments, but it's just to improve clarity.

# -*- coding: utf-8 -*-

"""
Projects metrics extracted from a map onto the endpoints of streamlines.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it's fine, but ok. I will manage it in another PR after. Let's simplify this one.

scripts/scil_tractogram_project_map_to_streamlines.py Outdated Show resolved Hide resolved
scripts/scil_tractogram_project_map_to_streamlines.py Outdated Show resolved Hide resolved
scripts/scil_tractogram_project_map_to_streamlines.py Outdated Show resolved Hide resolved
scripts/scil_tractogram_project_map_to_streamlines.py Outdated Show resolved Hide resolved
scripts/scil_tractogram_dpp_math.py Outdated Show resolved Hide resolved
scripts/scil_tractogram_dpp_math.py Outdated Show resolved Hide resolved
scripts/scil_tractogram_dpp_math.py Show resolved Hide resolved
scripts/scil_tractogram_dpp_math.py Outdated Show resolved Hide resolved
scilpy/tractograms/streamline_operations.py Outdated Show resolved Hide resolved
@EmmaRenauld EmmaRenauld changed the title [WIP] Scripts to project 3D and 4D maps to streamline points and perform math operations in space of streamline points Scripts to project 3D and 4D maps to streamline points and perform math operations in space of streamline points Feb 19, 2024
Copy link
Contributor

@arnaudbore arnaudbore left a comment

Choose a reason for hiding this comment

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

GTG

@arnaudbore arnaudbore merged commit 1c4b850 into scilus:master Feb 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work In Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants