@@ -94,7 +94,7 @@ def __init__(self, dirname="", prune_channels=True):
9494 self .logger .error (f"{ self .dirname } is not a folder" )
9595 self ._prune_channels = prune_channels
9696 self ._opened_files = {}
97- self ._ignore_unknown_blocks = True # internal debug property
97+ self ._ignore_unknown_datablocks = True # internal debug property
9898
9999 def _explore_folder (self ):
100100 """
@@ -144,8 +144,8 @@ def _explore_folder(self):
144144 def _source_name (self ):
145145 return str (self .dirname )
146146
147- def _read_file_blocks (self , filename , prune_channels = True ):
148- """Read blocks from AlphaOmega MPX file version 4.
147+ def _read_file_datablocks (self , filename , prune_channels = True ):
148+ """Read datablocks from AlphaOmega MPX file version 4.
149149
150150 :param filename: the MPX filename to read blocks from
151151 :type filename: Path-like object or str
@@ -163,7 +163,7 @@ def _read_file_blocks(self, filename, prune_channels=True):
163163 stream_data_channels = {}
164164 ports = {}
165165 events = []
166- unknown_blocks = []
166+ unknown_datablocks = []
167167 with open (filename , "rb" ) as f :
168168 length , block_type = HeaderType .unpack (f .read (HeaderType .size ))
169169 # First block is always type h and size 60
@@ -237,7 +237,7 @@ def _read_file_blocks(self, filename, prune_channels=True):
237237
238238 length , block_type = HeaderType .unpack (header_bytes )
239239 if length == 65535 :
240- # The stop condition for reading MPX blocks is base on the
240+ # The stop condition for reading MPX datablocks is base on the
241241 # length of the block: if the block has length 65535 (or -1
242242 # in signed integer value) we know we have reached the end
243243 # of the file
@@ -260,7 +260,7 @@ def _read_file_blocks(self, filename, prune_channels=True):
260260 is_input ,
261261 channel_number ,
262262 * spike_color ,
263- ) = Type2Block .unpack (f .read (Type2Block .size ))
263+ ) = Type2DataBlock .unpack (f .read (Type2DataBlock .size ))
264264 if is_analog and is_input :
265265 (
266266 mode ,
@@ -505,7 +505,7 @@ def _read_file_blocks(self, filename, prune_channels=True):
505505 }
506506 )
507507 else :
508- if not self ._ignore_unknown_blocks :
508+ if not self ._ignore_unknown_datablocks :
509509 try :
510510 bt = block_type .decode ()
511511 self .logger .debug (
@@ -519,7 +519,7 @@ def _read_file_blocks(self, filename, prune_channels=True):
519519 "(int format)"
520520 )
521521 )
522- unknown_blocks .append (
522+ unknown_datablocks .append (
523523 {
524524 "length" : length ,
525525 "block_type" : block_type ,
@@ -561,7 +561,7 @@ def _read_file_blocks(self, filename, prune_channels=True):
561561 stream_data_channels ,
562562 ports ,
563563 events ,
564- unknown_blocks ,
564+ unknown_datablocks ,
565565 )
566566
567567 def _merge_segments (self , factor_period = 1.5 ):
@@ -663,7 +663,7 @@ def _parse_header(self):
663663 segments = []
664664 continuous_analog_channels = {}
665665 for i , filename in enumerate (filenames ):
666- metadata , cac , sac , dc , ct , sd , p , e , ub = self ._read_file_blocks (
666+ metadata , cac , sac , dc , ct , sd , p , e , ub = self ._read_file_datablocks (
667667 filename , self ._prune_channels
668668 )
669669 metadata ["filenames" ] = [filename ]
@@ -1069,27 +1069,27 @@ def get_name(f, name_length):
10691069
10701070
10711071HeaderType = struct .Struct ("<Hc" )
1072- """All blocks start with the same common structure:
1073- - length (ushort): the size (in bytes) of the block
1074- - block_type (char): the type of block (described after)
1072+ """All datablocks start with the same common structure:
1073+ - length (ushort): the size (in bytes) of the datablock
1074+ - datablock_type (char): the type of datablock (described after)
10751075
1076- There are two main block types:
1077- 1. definition blocks (types H, 2, S, B): these block describe metadata of
1076+ There are two main datablock types:
1077+ 1. definition datablocks (types H, 2, S, B): these datablock describe metadata of
10781078 channels and ports
1079- 2. data blocks (types 5, E): these blocks contains records data of the
1079+ 2. data datablocks (types 5, E): these datablocks contains records data of the
10801080 previously defined channels and ports
10811081
1082- Other blocks exist in the data but are ignored in this implementation as per the
1082+ Other datablocks exist in the data but are ignored in this implementation as per the
10831083specification: "Any block type other than the ones described below should be
10841084ignored."
10851085
10861086All data is little-endian (hence the '<' in Struct calls).
10871087"""
10881088
10891089SDataHeader = struct .Struct ("<xlhBBBBBBHBxddlB10s4sxl" )
1090- """Type H block is unique and the first block . It specifies file metadatas:
1090+ """Type H datablock is unique and the first datablock . It specifies file metadatas:
10911091 - alignment byte: ignore
1092- - next_block (long): offset of the next block from beginning of file
1092+ - next_datablock (long): offset of the next datablock from beginning of file
10931093 - version (short): program version number
10941094 - hour (unsigned char): start hour of data saving
10951095 - minute (unsigned char): start minute of the data saving
@@ -1113,17 +1113,17 @@ def get_name(f, name_length):
11131113 - reserved (long): not used
11141114"""
11151115
1116- Type2Block = struct .Struct ("<xlhhhxBBB" )
1116+ Type2DataBlock = struct .Struct ("<xlhhhxBBB" )
11171117"""There are two (or three, depending on your interpretation) types of Type 2
1118- blocks :
1118+ datablocks :
11191119 1. Analog channels definition
11201120 1.a. Continuous (RAW, LFP, SPK)
11211121 1.b. Segmented (SEG)
11221122 2. Digital channels definition (mainly TTL)
11231123
1124- all type 2 blocks starts with the same structure:
1124+ all type 2 datablocks starts with the same structure:
11251125 - alignment byte: ignore
1126- - next_block (long)
1126+ - next_datablock (long)
11271127 - is_analog (short): 0=Digital, 1=Analog
11281128 - is_input (short): 0=Output, 1=Input
11291129 - channel_number: the (unique) channel number identifier from the recording software
@@ -1140,7 +1140,7 @@ def get_name(f, name_length):
11401140 - amplitude (float): bit resolution. For MAP file version 4 if amplitude < 5
11411141 amplitude = 1_250_000/2**15
11421142 - sample_rate (float): in kHz (or more precisely in kilosample per seconds)
1143- - spike_count (short): size of each data block (short) + timestamp (unsigned long)
1143+ - spike_count (short): size of each data datablock (short) + timestamp (unsigned long)
11441144 - mode_spike (2 bytes): read as hex data 0xMCCC:
11451145 - M: 1=Master, 2=Slave
11461146 - CCC: linked channel
@@ -1180,17 +1180,17 @@ def get_name(f, name_length):
11801180in the specification and therefore not supported by this implementation)"""
11811181
11821182SDefStream = struct .Struct ("<xlhf" )
1183- """Type S block : Stream data definition:
1183+ """Type S datablock : Stream data definition:
11841184 - alignment byte: ignore
1185- - next_block (long): see above
1185+ - next_datablock (long): see above
11861186 - channel_number (short): see above
11871187 - sample_rate (float): see above
11881188 - name (n-char string): channel name; n=length-18
11891189
11901190"""
11911191
11921192SDefPortX = struct .Struct ("<xiifH" )
1193- """Type b block : Digital Input/Output port definition:
1193+ """Type b datablock : Digital Input/Output port definition:
11941194 - board_number (int): not sure… maybe in case of multiple connected
11951195 AlphaOmega setups?
11961196 - port (int): unique port number identifier
@@ -1200,19 +1200,19 @@ def get_name(f, name_length):
12001200"""
12011201
12021202SDataChannel = struct .Struct ("<ch" )
1203- """Type 5 block : channel data:
1203+ """Type 5 datablock : channel data:
12041204 - unit_number (char): for analog segmented channels: unit number; 0=Level,
12051205 1=Unit1, 2=Unit2, 3=Unit3, 4=Unit4
12061206 - channel_number: the previously defined channel_number (in one of the
1207- definition blocks )
1207+ definition datablocks )
12081208"""
12091209SDataChannel_sample_id = struct .Struct ("<L" )
12101210"""
12111211Then for analog channels:
12121212 - sample_value (n-short): array of data values
12131213 - first_sample_number (ulong): for continuous channels: first sample number
12141214 in the channel records. This is the timestamp (see :attr:`SAOEvent`) of
1215- the first sample in the data blocks
1215+ the first sample in the data datablocks
12161216"""
12171217SDataChannelDigital = struct .Struct ("<Lh" )
12181218"""
@@ -1235,7 +1235,7 @@ def get_name(f, name_length):
12351235"""
12361236
12371237SAOEvent = struct .Struct ("<cL" )
1238- """Type E: stream data block :
1238+ """Type E: stream data datablock :
12391239 - type_event (char): event type only b"S" for now
12401240 - timestamp (ulong): a counter initialized at 0 at hardware boot and that
12411241 advances at the sampling rate of the system
0 commit comments