Skip to content

Commit

Permalink
[FIX] address file naming duplicates with SN begins with same number
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Levitas committed Jul 15, 2024
1 parent f7602f7 commit 0cb4b0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion handler/ezBIDS_core/ezBIDS_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def modify_uploaded_dataset_list(uploaded_img_list):
img_dir = os.path.dirname(img_file)
grouped_files = [
img_dir + '/' + x for x in os.listdir(img_dir)
if os.path.basename(img_file).split(ext)[0] in x
if os.path.basename(img_file).split(ext)[0] + "." in x
]

# deal with PET issue where ECAT-formatted or blood data could be accidentally grouped with imaging data
Expand Down
4 changes: 2 additions & 2 deletions handler/ezBIDS_core/update_ezBIDS_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
with open("ezBIDS_core.json", "r") as ezBIDS_json:
ezBIDS = json.load(ezBIDS_json)


for img_file in img_list:
if os.path.isfile(f"{DATA_DIR}/{img_file}") or os.path.isdir(f"{DATA_DIR}/{img_file}"):
for obj in ezBIDS["objects"]:
for item in obj["items"]:
path = item["path"]

if path == img_file:
files = [
os.path.join(os.path.dirname(img_file), x) for x in os.listdir(os.path.dirname(img_file))
Expand All @@ -47,7 +47,7 @@
else:
ext = Path(img_file).suffix

png_files = natsorted([x for x in files if img_file.split(ext)[0] in x and ".png" in x])
png_files = natsorted([x for x in files if img_file.split(ext)[0] + ".png" == x])
item["pngPaths"] = png_files

with open("ezBIDS_core.json", "w") as ezBIDS_json:
Expand Down

0 comments on commit 0cb4b0b

Please sign in to comment.