Skip to content

Commit

Permalink
Merge pull request ME-ICA#14 from handwerkerd/harmonizing_kunduDTM_wi…
Browse files Browse the repository at this point in the history
…th_main

removed unnecessary function tedana.selection.selection_utils.get_new_meanmetricrank
  • Loading branch information
jbteves authored Aug 18, 2022
2 parents 0af24d2 + 2802e38 commit 7018b04
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 107 deletions.
2 changes: 1 addition & 1 deletion tedana/selection/selection_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from scipy.stats import scoreatpercentile

from tedana.metrics.dependence import generate_decision_table_score
from tedana.selection.selection_utils import ( # get_new_meanmetricrank,
from tedana.selection.selection_utils import (
change_comptable_classifications,
confirm_metrics_exist,
get_extend_factor,
Expand Down
106 changes: 0 additions & 106 deletions tedana/selection/selection_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import numpy as np

from tedana.metrics.dependence import generate_decision_table_score
from tedana.stats import getfbounds

LGR = logging.getLogger("GENERAL")
Expand Down Expand Up @@ -653,108 +652,3 @@ def get_extend_factor(n_vols=None, extend_factor=None):
LGR.error(error_msg)
raise ValueError(error_msg)
return extend_factor


def get_new_meanmetricrank(component_table, comps2use, decision_node_idx, calc_new_rank=False):
"""
If a revised d_table_score was already calculated, use that.
If not, calculate a new d_table_score based on the components
identified in comps2use
Parameters
----------
component_table
comps2use
decision_node_idx: :obj:`int`
The index for the current decision node
calc_new_rank: :obj:`bool`
calculate a new d_table_score even if revised scores with the same
labels were already calculated
Return
------
meanmetricrank
comptable
"""
rank_label = f"d_table_score_node{decision_node_idx}"
if not calc_new_rank and (rank_label in component_table.columns):
# return existing
LGR.info(
f"{rank_label} already calculated so not recalculating in node {decision_node_idx}"
)
return component_table[rank_label], component_table

# get the array of ranks
ranks = generate_decision_table_score(
component_table.loc[comps2use, "kappa"],
component_table.loc[comps2use, "dice_FT2"],
component_table.loc[comps2use, "signal-noise_t"],
component_table.loc[comps2use, "countnoise"],
component_table.loc[comps2use, "countsigFT2"],
)
# see if we need to make a new column
if rank_label not in component_table.columns:
component_table[rank_label] = np.zeros(component_table.shape[0]) * np.nan

# fill in the column with the components of interest
for c, rank in zip(comps2use, ranks):
component_table.loc[c, rank_label] = rank

return component_table[rank_label].copy(), component_table.copy()


# Not currently being used and hopefully will never again be used
# def prev_classified_comps(comptable, decision_node_idx, classification_label, prev_X_steps=0):
# """
# Output a list of components with a specific label during the current or
# previous X steps of the decision tree. For example, if
# classification_label = ['provisionalaccept'] and prev_X_steps = 0
# then this outputs the indices of components that are currenlty
# classsified as provisionalaccept. If prev_X_steps=2, then this will
# output components that are classified as provisionalaccept or were
# classified as such any time before the previous two decision tree steps

# Parameters
# ----------
# comptable
# n_echos: :obj:`int`
# The number of echos in the multi-echo data set
# decision_node_idx: :obj:`int`
# The index of the node in the decision tree that called this function
# classification_label: :obj:`list[str]`
# A list of strings containing classification labels to identify in components
# For example: ['provisionalaccept']
# prev_X_steps: :obj:`int`
# If 0, then just count the number of provisionally accepted or rejected
# or unclassified components in the current node. If this is a positive
# integer, then also check if a component was a in one of those three
# categories in ignore_prev_X_steps previous nodes. default=0

# Returns
# -------
# full_comps2use: :obj:`list[int]`
# A list of indices of components that have or add classification_lable
# """

# full_comps2use = selectcomps2use(comptable, classification_label)
# rationales = comptable["rationale"]

# if prev_X_steps > 0: # if checking classifications in prevision nodes
# for compidx in range(len(comptable)):
# tmp_rationale = rationales.values[compidx]
# tmp_list = re.split(":|;| ", tmp_rationale)
# while "" in tmp_list: # remove blank strings after splitting rationale
# tmp_list.remove("")
# # Check the previous nodes
# # This is inefficient, but it should work
# for didx in range(max(0, decision_node_idx - prev_X_steps), decision_node_idx):
# if str(didx) in tmp_list:
# didx_loc = tmp_list.index(str(didx))
# if didx_loc > 1:
# tmp_classifier = tmp_list[didx_loc - 1]
# if tmp_classifier in classification_label:
# full_comps2use.append(compidx)

# full_comps2use = list(set(full_comps2use))

# return full_comps2use

0 comments on commit 7018b04

Please sign in to comment.