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

Minor viz fix #4

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AFQ/utils/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"CST_R": "Right Corticospinal",
"CGC_L": "Left Cingulum Cingulate",
"CGC_R": "Right Cingulum Cingulate",
"IFO_L": "Left Inferior Fronto-Occipital",
"IFO_R": "Right Inferior Fronto-Occipital",
"IFO_L": "Left Inferior Fronto-occipital",
"IFO_R": "Right Inferior Fronto-occipital",
"ILF_L": "Left Inferior Longitudinal",
"ILF_R": "Right Inferior Longitudinal",
"SLF_L": "Left Superior Longitudinal",
Expand Down
39 changes: 10 additions & 29 deletions AFQ/viz/fury_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _inline_interact(scene, inline, interact):
return scene


def visualize_bundles(sft, n_points=None, bundle_dict=None,
def visualize_bundles(seg_sft, n_points=None,
bundle=None, colors=None,
color_by_direction=False,
opacity=1.0,
Expand All @@ -50,22 +50,14 @@ def visualize_bundles(sft, n_points=None, bundle_dict=None,

Parameters
----------
sft : Stateful Tractogram, str
A Stateful Tractogram containing streamline information
or a path to a trk file
In order to visualize individual bundles, the Stateful Tractogram
must contain a bundle key in it's data_per_streamline which is a list
of bundle `'uid'`.
seg_sft : SegmentedSFT, str
A SegmentedSFT containing streamline information
or a path to a segmented trk file.

n_points : int or None
n_points to resample streamlines to before plotting. If None, no
resampling is done.

bundle_dict : dict, optional
Keys are names of bundles and values are dicts that specify them.
Default: bundles are either not identified, or identified
only as unique integers in the metadata.

bundle : str or int, optional
The name of a bundle to select from among the keys in `bundle_dict`
or an integer for selection from the sft metadata.
Expand Down Expand Up @@ -110,7 +102,7 @@ def visualize_bundles(sft, n_points=None, bundle_dict=None,
figure.SetBackground(background[0], background[1], background[2])

for (sls, color, name, dimensions) in vut.tract_generator(
sft, bundle, bundle_dict, colors, n_points):
seg_sft, bundle, colors, n_points):
sls = list(sls)
if name == "all_bundles":
color = line_colors(sls)
Expand Down Expand Up @@ -501,9 +493,8 @@ def _draw_core(sls, n_points, figure, bundle_name, indiv_profile,
return line_color_untouched


def single_bundle_viz(indiv_profile, sft,
def single_bundle_viz(indiv_profile, seg_sft,
bundle, scalar_name,
bundle_dict=None,
flip_axes=[False, False, False],
labelled_nodes=[0, -1],
figure=None,
Expand All @@ -516,13 +507,9 @@ def single_bundle_viz(indiv_profile, sft,
indiv_profile : ndarray
A numpy array containing a tract profile for this bundle for a scalar.

sft : Stateful Tractogram, str
A Stateful Tractogram containing streamline information.
If bundle is an int, the Stateful Tractogram
must contain a bundle key in it's data_per_streamline which is a list
of bundle `'uid'.
Otherwise, the entire Stateful Tractogram will be used as the bundle
for the visualization.
seg_sft : SegmentedSFT, str
A SegmentedSFT containing streamline information
or a path to a segmented trk file.

bundle : str or int
The name of the bundle to be used as the label for the plot,
Expand All @@ -531,12 +518,6 @@ def single_bundle_viz(indiv_profile, sft,
scalar_name : str
The name of the scalar being used.

bundle_dict : dict, optional
This parameter is used if bundle is an int.
Keys are names of bundles and values are dicts that specify them.
Default: Either the entire sft is treated as a bundle,
or identified only as unique integers in the metadata.

flip_axes : ndarray
Which axes to flip, to orient the image as RAS, which is how we
visualize.
Expand Down Expand Up @@ -564,7 +545,7 @@ def single_bundle_viz(indiv_profile, sft,

n_points = len(indiv_profile)
sls, _, bundle_name, dimensions = next(vut.tract_generator(
sft, bundle, bundle_dict, None, n_points))
seg_sft, bundle, None, n_points))

_draw_core(
sls, n_points, figure, bundle_name, indiv_profile,
Expand Down
27 changes: 10 additions & 17 deletions AFQ/viz/plotly_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _plot_profiles(profiles, bundle_name, color, fig, scalar):
yaxis_title=dict(text=vut.display_string(scalar), font=font)))


def visualize_bundles(sft, n_points=None,
def visualize_bundles(seg_sft, n_points=None,
bundle=None, colors=None, shade_by_volume=None,
color_by_streamline=None, n_sls_viz=3600,
sbv_lims=[None, None], include_profiles=(None, None),
Expand All @@ -241,12 +241,9 @@ def visualize_bundles(sft, n_points=None,

Parameters
----------
sft : Stateful Tractogram, str
A Stateful Tractogram containing streamline information
or a path to a trk file.
In order to visualize individual bundles, the Stateful Tractogram
must contain a bundle key in it's data_per_streamline which is a list
of bundle `'uid'`.
seg_sft : SegmentedSFT, str
A SegmentedSFT containing streamline information
or a path to a segmented trk file.

n_points : int or None
n_points to resample streamlines to before plotting. If None, no
Expand Down Expand Up @@ -347,7 +344,7 @@ def visualize_bundles(sft, n_points=None,
set_layout(figure, color=_color_arr2str(background))

for (sls, color, name, dimensions) in vut.tract_generator(
sft, bundle, colors, n_points,
seg_sft, bundle, colors, n_points,
n_sls_viz=n_sls_viz):
if isinstance(color_by_streamline, dict):
if name in color_by_streamline:
Expand Down Expand Up @@ -731,7 +728,7 @@ def _draw_core(sls, n_points, figure, bundle_name, indiv_profile,
return line_color_untouched


def single_bundle_viz(indiv_profile, sft,
def single_bundle_viz(indiv_profile, seg_sft,
bundle, scalar_name,
flip_axes=[False, False, False],
labelled_nodes=[0, -1],
Expand All @@ -745,13 +742,9 @@ def single_bundle_viz(indiv_profile, sft,
indiv_profile : ndarray
A numpy array containing a tract profile for this bundle for a scalar.

sft : Stateful Tractogram, str
A Stateful Tractogram containing streamline information.
If bundle is an int, the Stateful Tractogram
must contain a bundle key in it's data_per_streamline which is a list
of bundle `'uid'.
Otherwise, the entire Stateful Tractogram will be used as the bundle
for the visualization.
seg_sft : SegmentedSFT, str
A SegmentedSFT containing streamline information
or a path to a segmented trk file.

bundle : str or int
The name of the bundle to be used as the label for the plot,
Expand Down Expand Up @@ -795,7 +788,7 @@ def single_bundle_viz(indiv_profile, sft,

n_points = len(indiv_profile)
sls, _, bundle_name, dimensions = next(vut.tract_generator(
sft, bundle, None, n_points))
seg_sft, bundle, None, n_points))

line_color = _draw_core(
sls, n_points, figure, bundle_name, indiv_profile,
Expand Down
Loading