Skip to content

Conversation

h-mayorquin
Copy link
Contributor

@h-mayorquin h-mayorquin commented Sep 18, 2025

This is an issue with the same data discussed in #1778

.
├── CSC145.ncs
├── CSC146.ncs
└── csc23_100.ncs

The problem is that the DspFilterDelay_µs is sometimes encoded in latin-1 and sometimes encoded in utf8. This means that we decoding with the current method (latin-1) sometimes this specific property is read without the micro symbol and creates a key error here:

for key in signal_annotations[0].keys():
values = []
# only collect values from channels belonging to current stream
for d in np.where(signal_channels["stream_id"] == f"{stream_id}")[0]:
value = signal_annotations[d][key]
values.append(value)

when aggregating annotations over the channels.

This patch fixes this by using a regex to match what Latin-1 will read if the data is encoded as UTF-8.

The deeper problem is that Neuralynx does not really maintain its promise of ASCII headers.

@weiglszonja

Screenshot from 2025-09-18 17-11-18

@PeterNSteinmetz
Copy link
Contributor

I think this patch is fine and should cover both cases.

There is no official documentation of how the Neuralynx software writes the ascii header and it has varied over versions in a somewhat unpredictable manner. Thus all the regex'es being used to parse the headers.

@h-mayorquin
Copy link
Contributor Author

I think this patch is fine and should cover both cases.

There is no official documentation of how the Neuralynx software writes the ascii header and it has varied over versions in a somewhat unpredictable manner. Thus all the regex'es being used to parse the headers.

Thanks for taking a look. I will add a test.

@h-mayorquin h-mayorquin marked this pull request as ready for review September 20, 2025 18:11
@h-mayorquin
Copy link
Contributor Author

This is ready.

Copy link
Contributor

@zm711 zm711 left a comment

Choose a reason for hiding this comment

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

Good by me too.

@zm711 zm711 merged commit 43c6415 into NeuralEnsemble:master Sep 22, 2025
5 checks passed
@h-mayorquin h-mayorquin deleted the add_key_to_neuralynx branch September 22, 2025 13:48
@zm711 zm711 added this to the 0.14.3 milestone Oct 4, 2025
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.

3 participants