-
Notifications
You must be signed in to change notification settings - Fork 9
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
Unable to save Table data to csv #335
Comments
Hi Idit, If you'd like to propose a change to neurotic, the preferred method is the following:
I understand this may seem very complicated if you have never done it before. The advantage is that GitHub will automatically run neurotic's test suite, and I can more easily check that the proposed changes work. This off-loads work from me. Presently, I do really have time that I can devote to this. Without actually testing your code, but just reading it, it looks to me like this is not a good change in its present form. The Have you seen the script I provided to Miryam for exporting the contents of the annotations table? I will copy its contents below. I know a script is not as convenient as a button click in the application, but it should be able to export the table's contents. import os
from pathlib import Path
import pandas as pd
import neurotic
################################################################################
# Change these values for your needs
metadata_file = 'metadata.yml'
dataset_list = [
'IN VIVO / JG12 / 2019-05-10 / 002',
]
################################################################################
for dataset in dataset_list:
print('Dataset:', dataset)
metadata = neurotic.MetadataSelector(file=metadata_file)
metadata.select(dataset)
output_file = Path(metadata['data_file']).stem + ' TABLE.csv'
output_file = Path(metadata['data_dir']) / output_file
if output_file.exists():
print('ATTENTION: The output file already exists:')
print(' ', output_file)
overwrite = input('Do you want to overwrite it? [y/n] ')
if overwrite != 'y':
print('OK, aborting')
exit()
exclude_epoch_encoder = input('Do you want to exclude epoch encoder entries from the output? [y/n] ')
print('Loading data and generating table...')
blk = neurotic.load_dataset(metadata, lazy=False)
seg = blk.segments[0]
epochs = seg.epochs
print('Saving table...')
df_list = []
for ep in epochs:
if exclude_epoch_encoder == 'y':
ep = ep[ep.labels != '(from epoch encoder file)'];
df_list.append(pd.DataFrame({
'Start (s)': ep.times.rescale('s').round(4),
'End (s)': (ep.times + ep.durations).rescale('s').round(4),
'Duration (s)': ep.durations.rescale('s').round(4),
'Type': ep.name,
'Label': ep.labels,
}))
df_all = pd.concat(df_list).sort_values(['Start (s)', 'End (s)', 'Type', 'Label'])
df_all.to_csv(output_file, index=False)
print('Table successfully written to:')
print(' ', output_file)
print() |
Thank you, Jeff! |
Hello Jeff,
My name is Idit and I'm Miryam Levy's daughter (from BIU).
In the BIU lab, they are using neurotic version 1.5.0 and unable to save the data displayed to a CSV file. It generated only the headers.
I debugged it a bit and it seems that the NeuroticWritableEpochSource is missing a source.
I'd like to propose a fix but have no permission to push a Pull Request.
Please find the patch diff. Thanks, Idit
The text was updated successfully, but these errors were encountered: