Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions hallmonitor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
datadict_has_changes,
file_last_modified_date,
get_args,
get_deviation_files,
get_deviation_string,
get_eeg_errors,
get_expected_combination_rows,
Expand Down Expand Up @@ -112,6 +113,7 @@ def validate_data(
joint_rows = get_joint_root_vars(dataset)
logger.debug("Joint rows: %s", joint_rows)
combo_rows = get_expected_combination_rows(dataset)
logger.debug("Combination rows: %s", combo_rows)
combo_variables = set()
for combo in combo_rows:
combo_variables.update(combo.variables)
Expand All @@ -124,8 +126,6 @@ def validate_data(
len(missing_ids),
)



# raise errors for missing identifiers without a no-data.txt
for id in missing_ids:
# if appropriate option is set, skip "missing" errors when identifier is in pending-qa
Expand Down Expand Up @@ -326,6 +326,7 @@ def validate_data(
no_data_file = get_no_data_file(dir_filenames, id, joint_rows,logger)
has_no_data = True if no_data_file else False

joint_deviation_files = get_deviation_files(dir_filenames, id, joint_rows,logger)

logger.debug("has_deviation=%s, has_no_data=%s", has_deviation, has_no_data)
if has_deviation and has_no_data:
Expand Down Expand Up @@ -367,10 +368,13 @@ def validate_data(

misnamed_files = []
dir_filepaths = [os.path.join(id_dir, f) for f in dir_filenames]
# Solution: Create all possible known deviation.txt that could be located within as long as it iis in joint/ combination and enable it
for file_path in dir_filepaths:
file_name = os.path.basename(file_path)
if file_name == deviation_file:
continue
elif file_name in joint_deviation_files:
continue
elif file_name == "issue.txt":
pending.append(
new_error_record(
Expand Down
21 changes: 21 additions & 0 deletions hallmonitor/hmutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,27 @@ def get_deviation_file(dir_filenames, identifier, joint_rows, logger):
logger.debug("Found joint deviation file %s for identifier %s", joint_deviation_file, identifier)
return joint_deviation_file
return None

def get_deviation_files(dir_filenames, identifier, joint_rows, logger):
"""
Return a list of deviation files for the given identifier and joint rows.
"""
joint_deviation_files = []
if not any(f.endswith("deviation.txt") for f in dir_filenames):
return []
for joint_row in joint_rows:
if identifier.variable in joint_row.variables:
logger.debug("Identifier %s is part of joint row %s", identifier, joint_row.name)
# check for deviation/no-data files for joint root variable
#joint_deviation_file = f"{joint_row.name}_deviation.txt"
#joint_no_data_file = f"{joint_row.name}_no-data.txt"
for var in joint_row.variables:
joint_id = Identifier(
identifier.subject, var, identifier.session, identifier.run, identifier.event
)
joint_deviation_file = f"{joint_id}_deviation.txt"
joint_deviation_files.append(joint_deviation_file)
return joint_deviation_files

def get_no_data_file(dir_filenames, identifier, joint_rows, logger):
"""
Expand Down