Skip to content

Commit

Permalink
Update utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Feb 24, 2025
1 parent 38c3ac2 commit 34a8634
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cubids/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import json
import re
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -901,8 +902,9 @@ def assign_variants(summary, rename_cols):
Notes
-----
Variant names are constructed using the following rules:
1. Basic parameters use their actual values (e.g., VARIANTFlipAngle75)
2. Clustered parameters use their cluster numbers (e.g., VARIANTEchoTime2)
1. Basic parameters use their actual values (e.g., VARIANTFlipAngle75),
with non-alphanumeric characters removed.
2. Clustered parameters use their cluster numbers prefixed with "C" (e.g., VARIANTEchoTimeC2)
3. Special parameters like HasFieldmap use predefined strings (e.g., VARIANTNoFmap)
4. Multiple parameters are concatenated (e.g., VARIANTEchoTime2FlipAngle75)
"""
Expand Down Expand Up @@ -972,6 +974,13 @@ def assign_variants(summary, rename_cols):
# If the value is an actual float
elif isinstance(val, float):
val = str(val).replace(".", "p")
if val.endswith("p0"):
# Remove the trailing "p0"
val = val[:-2]

# Filter out non-alphanumeric characters
val = re.sub(r"[^a-zA-Z0-9]", "", val)

acq_str += f"{col}{val}"

if acq_str == "VARIANT":
Expand Down

0 comments on commit 34a8634

Please sign in to comment.