Skip to content

Conversation

JuliaSprenger
Copy link
Member

@JuliaSprenger JuliaSprenger commented Oct 20, 2021

To load multiple ncs files with different sampling rates multiple signals streams are required on the RawIO level. Here, for each set of channels sharing (sampling rate, n_samples, t_start) encountered in the files a dedicated signal stream is created to permit loading the data. Stream are ordered by descending sampling rate.

This PR also changes the event, epoch and spikes loaded for a segment. Previously all time point data were loaded for all segments, extending beyond the continuous signal of that segment. Now only time point data in the corresponding time frame of a segment are considered. If ncs data are available these define the segment structure. To load all time point data in a single segment all ncs files can be excluded resulting in a single segment containing all event, epoch and spiking data.

This PR is building on top of #990..
For the original discussion, see #1038

@pep8speaks
Copy link

pep8speaks commented Oct 20, 2021

Hello @JuliaSprenger! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-05-13 11:17:03 UTC

@TheChymera
Copy link
Contributor

I tried this out and I get:

chymera@neurohost ~/src/neuralynx_nwb/neuralynx_nwb $ python -c 'import convert; convert.reposit_data()'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/chymera/src/neuralynx_nwb/neuralynx_nwb/convert.py", line 44, in reposit_data
    reader = neo.io.NeuralynxIO(dirname=session_data, keep_original_times=True) # TODO: newer version should support: , keep_original_times=True)
  File "/home/chymera/src/python-neo/neo/io/neuralynxio.py", line 51, in __init__
    BaseFromRaw.__init__(self, dirname)
  File "/home/chymera/src/python-neo/neo/io/basefromrawio.py", line 74, in __init__
    self.parse_header()
  File "/home/chymera/src/python-neo/neo/rawio/baserawio.py", line 185, in parse_header
    self._parse_header()
  File "/home/chymera/src/python-neo/neo/rawio/neuralynxrawio/neuralynxrawio.py", line 291, in _parse_header
    self._sigs_memmaps, ncsSegTimestampLimits = self.scan_ncs_files(self.ncs_filenames)
  File "/home/chymera/src/python-neo/neo/rawio/neuralynxrawio/neuralynxrawio.py", line 635, in scan_ncs_files
    if v[0].is_equivalent(latest_sections, abs_tol=tolerance):
AttributeError: 'NcsSections' object has no attribute 'is_equivalent'

@JuliaSprenger
Copy link
Member Author

Hi @TheChymera, sorry for not making this clear in the first place: I opened this PR as a Draft as it is not complete yet. I am still working on the issue and will finalize the PR this week.

@TheChymera
Copy link
Contributor

@JuliaSprenger no worries, I just wanted to share feedback in case it might useful :) Also, what example data do you work with, did you get the full vStr_phase_stim dataset, or just one of the M* subsets?

@JuliaSprenger JuliaSprenger marked this pull request as ready for review October 28, 2021 13:03
@JuliaSprenger JuliaSprenger added this to the 0.11.0 milestone Oct 28, 2021
@JuliaSprenger JuliaSprenger force-pushed the enh/neuralynx_multi_rate branch from c8ced49 to 9412c97 Compare October 28, 2021 15:52
@JuliaSprenger
Copy link
Member Author

@samuelgarcia I resolved conflicts with the current master and tests should pass now. Can you review if you have time?

@samuelgarcia
Copy link
Contributor

Hi Julia,
this looks good.
I made some comments in parse header. Maybe we can enforce check to be sure that channel in the same stream have same sampling rate(done already) but also same lenght and same t_start.

Do we have somewhere something that check that the same stream have the same gaps ?
How do we handle if diffrents stream have differents gaps ? (this would be a noghtmare no ?)

@JuliaSprenger
Copy link
Member Author

JuliaSprenger commented Nov 18, 2021

Hi @samuelgarcia thanks for the feedback. You are right, the gap handling should happen first on a per-stream basis and then across streams as the requirements are a bit different. I will update the PR soon.

@yarikoptic
Copy link
Contributor

Hi @JuliaSprenger , we are hacking in DANDI/NWB hackathon and @TheChymera apparently still uses his own, more hacky version. It would be great to see this PR to finalize/gets merged so we could use it instead. Please let us know if there is anything specific we could be of help with if anything.

@JuliaSprenger JuliaSprenger marked this pull request as draft March 25, 2022 14:59
@JuliaSprenger
Copy link
Member Author

Failing IO tests are due to a certificate update on the gin side and outdated cached versions. Hopefully this issue will resolve itself in the next hours, see https://gin.g-node.org/G-Node/Info/issues/59

@JuliaSprenger
Copy link
Member Author

JuliaSprenger commented Mar 29, 2022

@samuelgarcia Thanks for having a first look. I addressed your comments. Can you have a look again? I am only waiting for confirmation to put some corresponding test files on gin to add a minimal stream test.

@JuliaSprenger
Copy link
Member Author

JuliaSprenger commented Mar 31, 2022

TODO: Ensure consistent ordering of streams - done

@JuliaSprenger JuliaSprenger force-pushed the enh/neuralynx_multi_rate branch from ba91fa2 to eae66a3 Compare March 31, 2022 16:22
@JuliaSprenger
Copy link
Member Author

@samuelgarcia I rebased on master and ordered stream by descending sampling rate.

@samuelgarcia
Copy link
Contributor

Perfect. Can I merge now ?

@JuliaSprenger
Copy link
Member Author

If the tests still pass: Yes please merge it :)

@samuelgarcia
Copy link
Contributor

Salut Julia,
test are not passing. Could you have a look ?

@JuliaSprenger JuliaSprenger force-pushed the enh/neuralynx_multi_rate branch from 20373e1 to bd33c15 Compare May 13, 2022 11:17
@JuliaSprenger
Copy link
Member Author

@samuelgarcia I rebased on master and tests are passing now. Ready to merge.

@JuliaSprenger
Copy link
Member Author

@samuelgarcia ping?

@samuelgarcia samuelgarcia merged commit a3a4a37 into NeuralEnsemble:master May 19, 2022
@JuliaSprenger JuliaSprenger deleted the enh/neuralynx_multi_rate branch May 19, 2022 14:06
@apdavison apdavison modified the milestones: 0.10.3, 0.11.0 Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants