-
Notifications
You must be signed in to change notification settings - Fork 261
Spikeglx np2 #1045
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
Spikeglx np2 #1045
Conversation
Hello @samuelgarcia! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-01-19 17:30:03 UTC |
@JuliaSprenger : could you merge this https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/pulls/61 so I can run test for this ? |
@JuliaSprenger : ready for review. |
Done, the test files are merged and io tests are restarted. |
cool thanks |
shape=(info['sample_length'], info['num_chan']), offset=0, order='C') | ||
data = np.memmap(info['bin_file'], dtype='int16', mode='r', offset=0, order='C') | ||
# this should be (info['sample_length'], info['num_chan']) | ||
# be some file are shorten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this then maybe raise a warning if the info metadata and the data length don't match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samuelgarcia What is your opinion about this?
Hi @samuelgarcia! I don't agree with removing the |
The failing tests seem to be not related to your changes, but to nix / h5py. |
Channel location was wrong in neo. |
Hi Julia. I don't think So 3 solutions:
|
Hi @samuelgarcia, |
No I don't think we should add probeinterface as a dependency for neo. To add the location is super easy # read signals
glx_folder = '/bla/bla'
reader = neo.SpikeGLXIO(dirname=glx_folder)
anasig = reader.read_segment().analogsignals[0]
# read probe
probe = probeinterface.read_spikeglx(glx_folder / 'blabla.meta')
# set location in annotations
anasig.array_annotations['channel_location'] = probe.contact_positions This is why I wanted to remove location handling from neo to avoid maintenance because it is already maintain in PI. |
hey @samuelgarcia , I'm trying to use this PR code, getting this error when reading: ---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-2-5bd6546cdd03> in <module>
2 meta = str(dir_path / "m676p3l11#1_ori16_g0_t0.imec.ap.meta")
3
----> 4 rec = se.SpikeGLXRecordingExtractor(folder_path=dir_path, stream_id='imec.ap')
5 # probe = read_spikeglx(file=meta)
6 # rp = rec.set_probe(probe=probe)
/media/luiz/storage/Github/spikeinterface/spikeinterface/extractors/neoextractors/spikeglx.py in __init__(self, folder_path, stream_id)
35 if HAS_NEO_11:
36 neo_kwargs['load_sync_channel'] = False
---> 37 NeoBaseRecordingExtractor.__init__(self, stream_id=stream_id, **neo_kwargs)
38
39 #~ # open the corresponding stream probe
/media/luiz/storage/Github/spikeinterface/spikeinterface/extractors/neoextractors/neobaseextractor.py in __init__(self, stream_id, **neo_kwargs)
24 def __init__(self, stream_id=None, **neo_kwargs):
25
---> 26 _NeoBaseExtractor.__init__(self, **neo_kwargs)
27
28 # check channel
/media/luiz/storage/Github/spikeinterface/spikeinterface/extractors/neoextractors/neobaseextractor.py in __init__(self, **neo_kwargs)
14 neoIOclass = eval('neo.rawio.' + self.NeoRawIOClass)
15 self.neo_reader = neoIOclass(**neo_kwargs)
---> 16 self.neo_reader.parse_header()
17
18 assert self.neo_reader.block_count() == 1, \
/media/luiz/storage/Github/python-neo/neo/rawio/baserawio.py in parse_header(self)
183
184 """
--> 185 self._parse_header()
186 self._check_stream_signal_channel_characteristics()
187
/media/luiz/storage/Github/python-neo/neo/rawio/spikeglxrawio.py in _parse_header(self)
76
77 def _parse_header(self):
---> 78 self.signals_info_list = scan_files(self.dirname)
79
80 # sort stream_name by higher sampling rate first
/media/luiz/storage/Github/python-neo/neo/rawio/spikeglxrawio.py in scan_files(dirname)
257 # except for the last fake channel
258 per_channel_gain = np.ones(num_chan, dtype='float64')
--> 259 if meta['imDatPrb_type'] == '0':
260 if signal_kind == 'ap':
261 index_imroTbl = 3
KeyError: 'imDatPrb_type' indeed, |
which version of NP do you have ? |
It is caused by an older version of SpieGLX metadata, which does not have This can be solved by this small change:
ref: https://github.com/billkarsh/SpikeGLX/blob/gh-pages/Support/Metadata_3A.md
|
neo/rawio/spikeglxrawio.py
Outdated
# the last channel doesn't have a gain value | ||
for c in range(num_chan - 1): | ||
per_channel_gain[c] = 1. / float(meta['imroTbl'][c].split(' ')[index_imroTbl]) | ||
if meta['imDatPrb_type'] == '0': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if meta['imDatPrb_type'] == '0': | |
if 'imDatPrb_type' not in meta or meta['imDatPrb_type'] == '0': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am having the same problem
@luiztauffer @bendichter : I made a new commit that should fix you problem. @AntonioST can you test this on your neuropixel data and check the gain with the latest commit, please I think there was a bug ? @JuliaSprenger : read to review and and merge I think now. We stringly need this in spikeinterface. |
Do you add this to the test datasets? |
@JuliaSprenger : we already have in spikeglx NP1 and NP2 in the gin. |
Do you want to comment / resolve this one? https://github.com/NeuralEnsemble/python-neo/pull/1045/files#r746731986 |
I don't think users should need to interact with probeinterface if they don't have to. Can you either add this here (with weak ref) or document it somehow so it's visible to users. We could also make the channel location handling optional. |
@JuliaSprenger : I added back channel_location in neo directly using a dep on probeinterface for this IO as you suggested. |
@samuelgarcia Do you want to wait some more for the feedback by @AntonioST and @luiztauffer or can I merge this now? |
You can merge now. |
load_sync_channel
option to not load the last channelSee #1028