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

Make the altair code a little more flexible #1101

Merged
merged 1 commit into from
Feb 4, 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
23 changes: 14 additions & 9 deletions AFQ/viz/altair.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def formal_tp(tp_name):
def altair_df_to_chart(profiles, position_domain=(20, 80),
column_count=1, font_size=20,
line_size=10, row_label_angle=90,
bundle_list=None,
legend_line_size=5,
alt_x_kwargs={}, alt_y_kwargs={},
**kwargs):
"""
Given a dataframe formatted for Altair, probably from
Expand Down Expand Up @@ -118,11 +120,14 @@ def altair_df_to_chart(profiles, position_domain=(20, 80),
"DKI MD": " (µm²/ms)",
"DKI MK": ""}

if bundle_list is None:
bundle_list = profiles["Bundle Name"].unique()

row_charts = []
for jj, b_name in enumerate(profiles["Bundle Name"].unique()):
for jj, b_name in enumerate(bundle_list):
row_dataframe = profiles[profiles["Bundle Name"] == b_name]
charts = []
for ii, tp in enumerate(profiles.TP.unique()):
for ii, tp in enumerate(sorted(profiles.TP.unique())):
this_dataframe = row_dataframe[row_dataframe.TP == tp]
if jj == 0:
title_name = tp + tp_units[tp]
Expand All @@ -138,13 +143,13 @@ def altair_df_to_chart(profiles, position_domain=(20, 80),
else:
x_axis_title = ""
useXlab = False
y_kwargs = dict(
scale=alt.Scale(zero=False),
# axis=alt.Axis(title=""),
title=y_axis_title
)
x_kwargs = dict(
axis=alt.Axis(title=x_axis_title, labels=useXlab))
y_kwargs = {
"scale": alt.Scale(zero=False),
"title": y_axis_title,
**alt_y_kwargs}
x_kwargs = {
"axis": alt.Axis(title=x_axis_title, labels=useXlab),
**alt_x_kwargs}
prof_chart = alt.Chart(
this_dataframe, title=title_name).mark_line(
size=line_size).encode(
Expand Down
4 changes: 0 additions & 4 deletions examples/tutorial_examples/plot_001_afq_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@
for ind in bundle_counts.index:
if ind == "Total Recognized":
threshold = 1000
elif ind == "Forceps Major":
Copy link
Collaborator

Choose a reason for hiding this comment

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

No longer an issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We use the other callosal bundles now!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes of course!

# This bundle is hard to track with this many streamlines
# Due to noise in this part of the brain
threshold = 1
else:
threshold = 10
if bundle_counts["n_streamlines"][ind] < threshold:
Expand Down
Loading