11"""
2- Neuronexus has their own file format based on their Allego Recording System
2+ NeuroNexus has their own file format based on their Allego Recording System
33https://www.neuronexus.com/webinar/allego-software-updates/
44
55The format involves 3 files:
66 * The *.xdat.json metadata file
77 * The *_data.xdat binary file of all raw data
8- * The *_timestamps.xdat binary file of the timeestamp data
8+ * The *_timestamps.xdat binary file of the timestamp data
99
1010Based on sample data is appears that the binary file is always a float32 format
1111Other information can be found within the metadata json file
2323like channel_names, channel_ids, channel_types.
2424
2525An additional note on channels. It appears that analog channels are called `pri` or
26- `ai0` within the metadata where as digital channels are called `din0` or `dout0`.
26+ `ai0` within the metadata whereas digital channels are called `din0` or `dout0`.
2727In this first implementation it is up to the user to do the appropriate channel slice
28- to only get the data they want.
28+ to only get the data they want. This is a buffer-based approach that Sam likes.
29+ Eventually we will try to divide these channels into streams (analog vs digital) or
30+ we can come up with a work around if users open an issue requesting this.
2931
3032Zach McKenzie
3133
4749from neo .core import NeoReadWriteError
4850
4951
50- class NeuronexusRawIO (BaseRawIO ):
52+ class NeuroNexusRawIO (BaseRawIO ):
5153
5254 extensions = ["xdat" , "json" ]
5355 rawmode = "one-file"
5456
5557 def __init__ (self , filename : str | Path = "" ):
5658 """
57- The Allego Neuronexus reader for the `xdat` file format
59+ The Allego NeuroNexus reader for the `xdat` file format
5860
5961 Parameters
6062 ----------
@@ -66,12 +68,12 @@ def __init__(self, filename: str | Path = ""):
6668 * The format involves 3 files:
6769 * The *.xdat.json metadata file
6870 * The *_data.xdat binary file of all raw data
69- * The *_timestamps.xdat binary file of the timeestamp data
71+ * The *_timestamps.xdat binary file of the timestamp data
7072 From the metadata the other two files are located within the same directory
7173 and loaded.
7274
7375 * The metadata is stored as the metadata attribute for individuals hoping
74- to extract probe information, but neo itself does not load any of the probe
76+ to extract probe information, but Neo itself does not load any of the probe
7577 information
7678
7779 Examples
@@ -146,7 +148,11 @@ def _parse_header(self):
146148 # We can do a quick timestamp check to make sure it is the correct timestamp data for the
147149 # given metadata
148150 if self ._timestamps [0 ] != self .metadata ["status" ]["timestamp_range" ][0 ]:
149- raise NeoReadWriteError (f"The metadata indicates a different starting timestamp" )
151+ metadata_start = self .metadata ["status" ]["timestamp_range" ][0 ]
152+ data_start = self ._teimstamps [0 ]
153+ raise NeoReadWriteError (
154+ f"The metadata indicates a different starting timestamp { metadata_start } than the data starting timestamp { data_start } "
155+ )
150156
151157 # organize the channels
152158 signal_channels = []
@@ -156,7 +162,7 @@ def _parse_header(self):
156162 # and because all data is stored in the same buffer stream for the moment all channels
157163 # will be in stream_id = 0. In the future this will be split into sub_streams based on
158164 # type but for now it will be the end-users responsability for this.
159- stream_id = 0 # hard-coded see note above
165+ stream_id = '0' # hard-coded see note above
160166 for channel_index , channel_name in enumerate (channel_info ["chan_name" ]):
161167 channel_id = channel_info ["ntv_chan_name" ][channel_index ]
162168 # 'ai0' indicates analog data which is stored as microvolts
@@ -272,4 +278,4 @@ def read_metadata(self, fname_metadata):
272278# this is pretty useless right now, but I think after a
273279# refactor with sub streams we could adapt this for the sub-streams
274280# so let's leave this here for now :)
275- stream_id_to_stream_name = {0 : "Neuronexus Allego Data" }
281+ stream_id_to_stream_name = {'0' : "Neuronexus Allego Data" }
0 commit comments