Skip to content

Commit

Permalink
more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
36000 committed Dec 20, 2024
1 parent 485e171 commit 187decf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
17 changes: 10 additions & 7 deletions AFQ/api/bundle_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,22 +1052,25 @@ def transform_rois(self, bundle_name, mapping, new_affine,
for roi_type, rois in transformed_rois.items():
if roi_type == "prob_map":
suffix = "probseg"
roi_type_name = ""
else:
suffix = "mask"
roi_type_name = roi_type.lower().replace(
" ", "").replace(
"_", "").replace(
"-", "")
roi_type_name = roi_type.lower().replace(
" ", "").replace(
"_", "").replace(
"-", "")
roi_type_name = roi_type_name[0].upper() \
+ roi_type_name[1:]
if not isinstance(rois, list):
rois = [rois]
for ii, roi in enumerate(rois):
suffix = f"{str_to_desc(bundle_name)}{roi_type_name}"
desc = f"{str_to_desc(bundle_name)}{roi_type_name}"
if roi_type in ["include", "exclude"]:
suffix = f"{suffix}{ii}"
desc = f"{suffix}{ii}"
fname = get_fname(
base_fname,
"_space-subject_desc-"
f"{suffix}"
f"{desc}"
f"_{suffix}.nii.gz",
"ROIs")
nib.save(
Expand Down
4 changes: 2 additions & 2 deletions AFQ/tasks/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def viz_indivBundle(base_fname,
if len(indiv_profile) > 1:
fname = get_fname(
base_fname,
f'_desc-{str_to_desc(bundle_name)}'
f'_desc-{str_to_desc(bundle_name)}Core'
f'_tractography.html',
"viz_core_bundles")
core_fig = make_subplots(
Expand Down Expand Up @@ -336,7 +336,7 @@ def plot_tract_profiles(base_fname, output_dir, scalars, segmentation_imap):
this_scalar = scalar if isinstance(scalar, str) else scalar.get_name()
fname = get_fname(
base_fname,
f'_param-{str_to_desc(this_scalar)}_desc-vizprofile_tractography.png',
f'_param-{str_to_desc(this_scalar)}_desc-vizprofile_tractography',
'tract_profile_plots')

visualize_tract_profiles(
Expand Down
13 changes: 12 additions & 1 deletion AFQ/viz/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from AFQ.viz.utils import display_string
from AFQ.utils.stats import contrast_index as calc_contrast_index
from AFQ.data.utils import BUNDLE_RECO_2_AFQ, BUNDLE_MAT_2_PYTHON
from AFQ.utils.path import drop_extension

try:
from pingouin import intraclass_corr, corr
Expand Down Expand Up @@ -659,8 +660,18 @@ def tract_profiles(self, names=None, scalar="FA",
if ba.is_using_temp_axis():
ba.temp_fig.legend(
labels_temp, names, fontsize=vut.medium_font)
if "_desc" in o_file: # Use BIDS naming convention
o_file_pre = o_file.split("_desc-")[0]
o_file_post = o_file.split("_desc-")[1]
bids_bname = bundle.lower().replace(
" ", "").replace(
"-", "").replace(
"_", "")
bf_name = o_file_pre + "_desc-" + bids_bname + o_file_post
else:
bf_name = f"{o_file}_{bundle}"
ba.save_temp_fig(
o_folder, f"{o_file}_{bundle}", self._save_fig)
o_folder, bf_name, self._save_fig)
if len(names) > 1:
ba.fig.legend(
labels, names, loc='center',
Expand Down

0 comments on commit 187decf

Please sign in to comment.