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

Added OpenEphys to KWD conversion #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added OpenEphys to KWD conversion #44

wants to merge 1 commit into from

Conversation

theilmbh
Copy link
Member

@theilmbh theilmbh commented Oct 2, 2018

What metadata needs to get added to the KWD file along with the raw waveforms?

Copy link
Contributor

@MarvinT MarvinT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're interested in getting klusta-pipeline python3 compatible I could probably get a PR for that going. Want to take a look at my python3 PRs for ephys and behav analysis?

We probably want to take some of the good parts of make_kwd and mix them in. Also, the way the repo is currently organized is a lot of the functions are in dataio and utils which might be useful for you. Both for putting your functions in there and for re using those functions.

return list(set(recordings))

def check_n_samples_consistency(continuous_files):
n_samples_list = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not make this a set to begin with?

def get_openephys_channel_number(continuous_file):
cf_filename = os.path.split(continuous_file)[1]
cf_filename = cf_filename.replace('.continuous', '')
if 'CH' in cf_filename:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're going to have these kinds of magic numbers can you do some asserts to make sure you're getting the data you expected.

also maybe elifs and a else case that raises an error?

kwd_file.create_dataset("/recordings/{}/application_data/channel_sample_rates".format(recording_number), data=channel_sample_rates)
kwd_file.create_dataset("/recordings/{}/application_data/channel_bit_volts".format(recording_number), data=channel_bit_volts)
kwd_file.create_dataset("/recordings/{}/application_data/timestamps".format(recording_number), data=np.array(channel_timestamps))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set it up to have a an if name == main so we can run it as a script

channel_sample_rates[channel] = int(cf_header['sampleRate'])
channel_bit_volts[channel] = float(cf_header['bitVolts'])

(n_records, n_oe_file_samples) = calculate_openephys_continuous_sizes(oe_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need the parenthesis around (n_records, n_oe_file_samples)

oe_file.seek(recording_offset)
record_recording_number = np.fromfile(oe_file, np.dtype('>u2'), 1)[0]
recordings.append(record_recording_number)
return (recordings, timestamps)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need parenthesis here either

recordings = []
timestamps = []
(n_records, n_samples) = calculate_openephys_continuous_sizes(oe_file)
for record in range(n_records):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this record/record offset code is a bit of a repeated motif throughout several functions, it might be clearer to say

for record_offset in gen_record_offsets(n_records):
    timestamps.append(seek_and_read(oe_file, record_offset + RECORD_TIMESTAMP_OFFSET, '<i8'))
    recordings.append(seek_and_read(oe_file, record_offset + RECORD_RECORDING_OFFSET, '>u2')[0])

but that's just my style

def get_n_channels(continuous_files):
return len(continuous_files)

def initialize_kwd_file(data_dir, experiment_name):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you looked at from klusta_pipeline.dataio import save_info, save_recording, save_chanlist, save_probe, save_parameters
there might be a bunch of code you can reuse in there
Also, are we going to have averaging options here? as in klusta_pipeline.utils? options to ignore dead channels?


# For each record, save the samples in the kwd recording dataset
for record_ind, record in enumerate(recording_records):
record_data_list = load_openephys_continuous_record(oe_file, record)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change this to
_, _, _. record_data = load_openephys_continuous_record(oe_file, record) or
record_data = load_openephys_continuous_record(oe_file, record)[3]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants