#NEWLINE# @ verbose #NEWLINE# def _read_segment_file( self , data , idx , fi , start , stop , cals , mult ) : #NEWLINE# #INDENT# 'Take a chunk of raw data, multiply by mult or cals, and store' #NEWLINE# n_channels = ( self . info [ 'nchan' ] - 1 ) #NEWLINE# channel_offset = self . _raw_extras [ 0 ] [ 'channel_offset' ] #NEWLINE# baselines = self . _raw_extras [ 0 ] [ 'baselines' ] #NEWLINE# stim_ch = self . _raw_extras [ 0 ] [ 'stim_channel' ] #NEWLINE# n_bytes = 2 #NEWLINE# sel = np . arange ( ( n_channels + 1 ) ) [ idx ] #NEWLINE# chunk_size = ( channel_offset * n_channels ) #NEWLINE# data_left = ( ( stop - start ) * n_channels ) #NEWLINE# block_size = ( ( ( int ( 100000000.0 ) // n_bytes ) // chunk_size ) * chunk_size ) #NEWLINE# block_size = min ( data_left , block_size ) #NEWLINE# s_offset = ( start % channel_offset ) #NEWLINE# with open ( self . _filenames [ fi ] , 'rb' , buffering = 0 ) as fid : #NEWLINE# #INDENT# fid . seek ( ( 900 + ( n_channels * ( 75 + ( ( start - s_offset ) * n_bytes ) ) ) ) ) #NEWLINE# for sample_start in ( np . arange ( 0 , data_left , block_size ) // n_channels ) : #NEWLINE# #INDENT# sample_stop = ( sample_start + min ( ( ( block_size // n_channels ) , ( ( data_left // n_channels ) - sample_start ) ) ) ) #NEWLINE# n_samps = ( sample_stop - sample_start ) #NEWLINE# data_ = np . empty ( ( ( n_channels + 1 ) , n_samps ) ) #NEWLINE# extra_samps = ( chunk_size if ( ( s_offset != 0 ) or ( ( n_samps % channel_offset ) != 0 ) ) else 0 ) #NEWLINE# if ( s_offset >= ( channel_offset / 2 ) ) : #NEWLINE# #INDENT# extra_samps += chunk_size #NEWLINE# #UNINDENT# count = ( ( ( n_samps // channel_offset ) * chunk_size ) + extra_samps ) #NEWLINE# n_chunks = ( count // chunk_size ) #NEWLINE# samps = np . fromfile ( fid , dtype = '<i2' , count = count ) #NEWLINE# samps = samps . reshape ( ( n_chunks , n_channels , channel_offset ) , order = 'C' ) #NEWLINE# block = np . zeros ( ( ( n_channels + 1 ) , ( channel_offset * n_chunks ) ) ) #NEWLINE# for ( set_idx , row ) in enumerate ( samps ) : #NEWLINE# #INDENT# block_slice = slice ( ( set_idx * channel_offset ) , ( ( set_idx + 1 ) * channel_offset ) ) #NEWLINE# block [ : ( - 1 ) , block_slice ] = row #NEWLINE# #UNINDENT# block = block [ sel , s_offset : ( n_samps + s_offset ) ] #NEWLINE# data_ [ sel ] = block #NEWLINE# data_ [ ( - 1 ) ] = stim_ch [ ( start + sample_start ) : ( start + sample_stop ) ] #NEWLINE# data_ [ sel ] -= baselines [ sel ] [ : , None ] #NEWLINE# _mult_cal_one ( data [ : , sample_start : sample_stop ] , data_ , idx , cals , mult = None )