Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temporary fix for problem debugged with jesscall #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
24 changes: 20 additions & 4 deletions python/libs/Modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def clean_dataset_files(self):
def modify_dataset_description_json(self):
# EEG2BIDS Wizard version
appVersion = 'unknown'

try:
with open(os.path.join(os.path.dirname(__file__), '../../package.json'), "r") as fp:
file_data = json.load(fp)
Expand Down Expand Up @@ -238,16 +238,25 @@ def copy_event_files(self):
rows = list(reader)
tsv_file.close()

header_case = ''

for line in rows:
try:
header_case = 1
onset, duration, trial_type, value, sample = line
output.append([onset, duration, trial_type, value, sample])
except ValueError:
try:
header_case = 2
onset, duration, trial_type = line
output.append([onset, duration, trial_type, 'n/a', 'n/a'])
except ValueError:
print('error: ValueError')
try:
header_case = 3
onset, duration, trial_type, response_time, value, sample = line
output.append([onset, duration, trial_type, response_time, value, sample])
except ValueError:
print('error: ValueError')

path_event_files = ''
# We search for the events.tsv file.
Expand Down Expand Up @@ -275,7 +284,11 @@ def copy_event_files(self):
onset, duration, trial_type = line
output.append([onset, duration, trial_type, 'n/a', 'n/a'])
except ValueError:
print('error: ValueError')
try:
onset, duration, trial_type, response_time, value, sample = line
output.append([onset, duration, trial_type, response_time, value, sample])
except ValueError:
print('error: ValueError')
except:
print('No events.tsv found in the BIDS folder.')
else:
Expand All @@ -287,7 +300,10 @@ def copy_event_files(self):

# overwrite BIDS events.tsv with collected data.
with open(path_event_files, mode='a+', newline='') as tsv_file:
headers = ['onset', 'duration', 'trial_type', 'value', 'sample']
if header_case == 3:
headers = ['onset', 'duration', 'trial_type', 'response_time', 'value', 'sample']
else:
headers = ['onset', 'duration', 'trial_type', 'value', 'sample']
writer = csv.writer(tsv_file, delimiter='\t')
writer.writerow(headers)
writer.writerows(output)
Expand Down