Skip to content

Commit

Permalink
do not separate df for empty refs and preds
Browse files Browse the repository at this point in the history
  • Loading branch information
naga-karthik committed Oct 25, 2024
1 parent e5f8ae1 commit 28f684a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions compute_metrics_reloaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ def compute_metrics_single_subject(prediction, reference, metrics):
# append entry into the output_list to store the metrics for the current subject
metrics_dict = {'reference': reference, 'prediction': prediction}

# NOTE: this is hacky fix to try to speed up metrics computation, tread very carefully
if len(unique_labels) == 2:
# compute metrics only for lesions
unique_labels = unique_labels[1:]
# # NOTE: this is hacky fix to try to speed up metrics computation, tread very carefully
# if len(unique_labels) == 2:
# # compute metrics only for lesions
# unique_labels = unique_labels[1:]

# loop over all unique labels, e.g., voxels with values 1, 2, ...
# by doing this, we can compute metrics for each label separately, e.g., separately for spinal cord and lesions
Expand Down Expand Up @@ -260,11 +260,11 @@ def main():
# Convert JSON data to pandas DataFrame
df = build_output_dataframe(output_list)

# create a separate dataframe for columns where EmptyRef and EmptyPred is True
df_empty_masks = df[(df['EmptyRef'] == True) & (df['EmptyPred'] == True)]
# # create a separate dataframe for columns where EmptyRef and EmptyPred is True
# df_empty_masks = df[(df['EmptyRef'] == True) & (df['EmptyPred'] == True)]

# keep only the rows where either pred or ref is non-empty or both are non-empty
df = df[(df['EmptyRef'] == False) | (df['EmptyPred'] == False)]
# # keep only the rows where either pred or ref is non-empty or both are non-empty
# df = df[(df['EmptyRef'] == False) | (df['EmptyPred'] == False)]

# Compute mean and standard deviation of metrics across all subjects
df_mean = (df.drop(columns=['reference', 'prediction', 'EmptyRef', 'EmptyPred']).groupby('label').
Expand Down

0 comments on commit 28f684a

Please sign in to comment.