Skip to content

Commit

Permalink
[FIX] Address list read error when escape characters (e.g. comma) in …
Browse files Browse the repository at this point in the history
…file paths
  • Loading branch information
Dan Levitas committed May 22, 2024
1 parent 0d351c3 commit 134e454
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion handler/ezBIDS_core/ezBIDS_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3061,7 +3061,11 @@ def check_dwi_b0maps(dataset_list_unique_series):
print("")

# Load dataframe containing all uploaded files
uploaded_img_list = natsorted(pd.read_csv("list", header=None, lineterminator='\n').to_numpy().flatten().tolist())
try:
uploaded_img_list = natsorted(pd.read_csv("list", header=None, lineterminator='\n').to_numpy().flatten().tolist())
except:
# Need for [rare] instances where a comma (or other escape character) is in the file path
uploaded_img_list = natsorted(pd.read_csv("list", sep=' ', header=None, lineterminator='\n').to_numpy().flatten().tolist())

# Remove dots in file names (that aren't extensions). This screws up the bids-validator otherwise
uploaded_img_list = fix_multiple_dots(uploaded_img_list)
Expand Down
7 changes: 6 additions & 1 deletion handler/ezBIDS_core/update_ezBIDS_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
DATA_DIR = sys.argv[1]
os.chdir(DATA_DIR)

img_list = natsorted(pd.read_csv("list", header=None, lineterminator="\n").to_numpy().flatten().tolist())
try:
img_list = natsorted(pd.read_csv("list", header=None, lineterminator="\n").to_numpy().flatten().tolist())
except:
# Need for [rare] instances where a comma (or other escape character) is in the file path
img_list = natsorted(pd.read_csv("list", sep=' ', header=None, lineterminator='\n').to_numpy().flatten().tolist())

MEG_extensions = [".ds", ".fif", ".sqd", ".con", ".raw", ".ave", ".mrk", ".kdf", ".mhd", ".trg", ".chn", ".dat"]

# place paths to image thumbnails in ezBIDS_core.json
Expand Down

0 comments on commit 134e454

Please sign in to comment.