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

Fix fast loading for Intan files with Neo >= 0.10.0 #324

Merged
merged 2 commits into from Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions neurotic/gui/config.py
Expand Up @@ -347,13 +347,20 @@ def create_ephyviewer_window(self, theme='light', ui_scale='medium', support_inc
# Intan-specific tricks
if isinstance(io, neo.io.IntanIO):
# dirty trick for getting ungrouped channels into a single source
io.header['signal_channels']['group_id'] = 0
# TODO handle other signal streams (stim, analog out), not just the first
try:
# Neo >= 0.10.0
io.header['signal_channels']['stream_id'] = io.header['signal_streams'][0]['id']
io.header['signal_streams'] = io.header['signal_streams'][:1]
except KeyError:
# Neo < 0.10.0
io.header['signal_channels']['group_id'] = 0

# prepare to append custom channel names stored in data file to ylabels
custom_channel_names = {c['native_channel_name']: c['custom_channel_name'] for c in io._ordered_channels}

channel_indexes = [p['index'] for p in self.metadata['plots']]
sources['signal'].append(ephyviewer.AnalogSignalFromNeoRawIOSource(io, channel_indexes))
sources['signal'].append(ephyviewer.AnalogSignalFromNeoRawIOSource(io, channel_indexes=channel_indexes))

# modify loaded channel names to use ylabels
for i, p in enumerate(self.metadata['plots']):
Expand Down
14 changes: 13 additions & 1 deletion neurotic/tests/metadata-for-tests.yml
Expand Up @@ -78,7 +78,19 @@ plain-text-axograph:
units: V
ylim: [-0.1, 5.1]

matlab example:
matlab-example:
data_dir: matlab-example
remote_data_dir: matlab-example
data_file: neo-matlab.mat

intan-example:
data_dir: intan-example
remote_data_dir: intan-example
data_file: intan-rhx-demo.rhd

plots: # TODO: make this example work without specifying "plots"
- channel: A-000
- channel: A-001
- channel: A-002
- channel: A-003
- channel: A-004
21 changes: 21 additions & 0 deletions neurotic/tests/test_gui.py
Expand Up @@ -86,5 +86,26 @@ def test_empty_plots(self):
# close thread properly
win.close()

def test_intan_lazy_loading(self):
"""Test creating an ephyviewer window for Intan with lazy loading"""
file = self.test_file
dataset = 'intan-example'
metadata = neurotic.MetadataSelector(file=file,
initial_selection=dataset)
metadata.download_all_data_files()

lazy = True
blk = neurotic.load_dataset(metadata=metadata, lazy=lazy)
ephyviewer_config = neurotic.EphyviewerConfigurator(metadata, blk,
lazy=lazy)
ephyviewer_config.show_all()

app = mkQApp()
win = ephyviewer_config.create_ephyviewer_window()
self.assertIsInstance(win, MainViewer)

# close thread properly
win.close()

if __name__ == '__main__':
unittest.main()
12 changes: 11 additions & 1 deletion neurotic/tests/test_neo_io.py
Expand Up @@ -74,7 +74,17 @@ def test_plain_text_axograph(self):

def test_matlab(self):
"""Test reading a MATLAB file"""
dataset = 'matlab example'
dataset = 'matlab-example'
metadata = neurotic.MetadataSelector(file=self.temp_file,
initial_selection=dataset)
metadata.download('data_file')

blk = neurotic.load_dataset(metadata=metadata, lazy=False)
assert(blk)

def test_intan(self):
"""Test reading an Intan file"""
dataset = 'intan-example'
metadata = neurotic.MetadataSelector(file=self.temp_file,
initial_selection=dataset)
metadata.download('data_file')
Expand Down