From 187decfd2cd9fd3f128aeb5870067a8a8d0bfa78 Mon Sep 17 00:00:00 2001 From: 36000 Date: Thu, 19 Dec 2024 18:03:05 -0800 Subject: [PATCH] more tweaks --- AFQ/api/bundle_dict.py | 17 ++++++++++------- AFQ/tasks/viz.py | 4 ++-- AFQ/viz/plot.py | 13 ++++++++++++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/AFQ/api/bundle_dict.py b/AFQ/api/bundle_dict.py index 25064476..e2c11478 100644 --- a/AFQ/api/bundle_dict.py +++ b/AFQ/api/bundle_dict.py @@ -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( diff --git a/AFQ/tasks/viz.py b/AFQ/tasks/viz.py index 1c8f2623..a4c0550a 100644 --- a/AFQ/tasks/viz.py +++ b/AFQ/tasks/viz.py @@ -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( @@ -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( diff --git a/AFQ/viz/plot.py b/AFQ/viz/plot.py index bb8ca815..f4dd359f 100644 --- a/AFQ/viz/plot.py +++ b/AFQ/viz/plot.py @@ -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 @@ -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',