Skip to content
4 changes: 2 additions & 2 deletions TPTBox/core/bids_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"MP2RAG",
"MPM",
"MT",
"MT",
"MTS",
"T1map",
"T2map",
"T2starmap",
Expand Down Expand Up @@ -298,6 +298,7 @@
# Run is used when the file collides with an other. Run gets a increasing number
## Official
"Acquisition": "acq",
"Split": "split",
# sag, ax, iso usw. and In case different sequences are used to record the same modality (for example, RARE and FLASH for T1w)
# Examples: sag, sag-RARE, RARE
"Task": "task",
Expand Down Expand Up @@ -334,7 +335,6 @@
# Single class segmentation
Comment thread
Hendrik-code marked this conversation as resolved.
"Label": "label",
# Others (never used)
"Split": "split",
"Density": "den",
"version": "version",
"Description": "desc",
Expand Down
35 changes: 26 additions & 9 deletions TPTBox/core/bids_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,22 @@ def get_frame_of_reference_uid(self, default=None):
base36 = chars[i] + base36
return base36[:length]

def get_identifier(self, sequence_splitting_keys: list[str]) -> str:
"""Generates an identifier for the BIDS_FILE based on subject and splitting keys

Args:
sequence_splitting_keys (list[str]): list of keys to use for splitting
"""
if "sub" not in self.info:
print(f"family_id, no sub-key, got {self.info}")
identifier = "sub-404"
else:
identifier = "sub-" + self.info["sub"]
for s in self.info.keys():
if s in sequence_splitting_keys:
identifier += "_" + s + "-" + self.info[s]
return identifier


class Searchquery:
def __init__(self, subj: Subject_Container, flatten=False) -> None:
Expand Down Expand Up @@ -1456,15 +1472,16 @@ def __lt__(self, other):

def get_identifier(self):
first_e = self.data_dict[next(iter(self.data_dict.keys()))][0]
if "sub" not in first_e.info:
print(f"family_id, no sub-key, got {first_e.info} and data_dict {list(self.data_dict.keys())}")
identifier = "sub-404"
else:
identifier = "sub-" + first_e.info["sub"]
for s in first_e.info.keys():
if s in self.sequence_splitting_keys:
identifier += "_" + s + "-" + first_e.info[s]
return identifier
return first_e.get_identifier(self.sequence_splitting_keys)
# if "sub" not in first_e.info:
# print(f"family_id, no sub-key, got {first_e.info} and data_dict {list(self.data_dict.keys())}")
# identifier = "sub-404"
# else:
# identifier = "sub-" + first_e.info["sub"]
# for s in first_e.info.keys():
# if s in self.sequence_splitting_keys:
# identifier += "_" + s + "-" + first_e.info[s]
# return identifier
Comment on lines +1484 to +1492

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a large block of commented-out legacy implementation left after the new early return. Since it is now unreachable and duplicates the extracted logic, it should be removed to avoid confusion and reduce maintenance overhead.

Suggested change
# if "sub" not in first_e.info:
# print(f"family_id, no sub-key, got {first_e.info} and data_dict {list(self.data_dict.keys())}")
# identifier = "sub-404"
# else:
# identifier = "sub-" + first_e.info["sub"]
# for s in first_e.info.keys():
# if s in self.sequence_splitting_keys:
# identifier += "_" + s + "-" + first_e.info[s]
# return identifier

Copilot uses AI. Check for mistakes.

def items(self):
return self.data_dict.items()
Expand Down
2 changes: 1 addition & 1 deletion TPTBox/core/nii_poi_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def assert_affine(

# Print errors
for err in found_errors:
log.print(err, ltype=Log_Type.FAIL, verbose=verbose)
log.print(f"{text}; {err}", ltype=Log_Type.FAIL, verbose=verbose)
Comment thread
robert-graf marked this conversation as resolved.
Outdated
# Final conclusion and possible raising of AssertionError
has_errors = len(found_errors) > 0
if raise_error and has_errors:
Expand Down