#NEWLINE# def read_block( self , lazy = False , cascade = True ) : #NEWLINE# #INDENT# '\n        ' #NEWLINE# tree = ElementTree . parse ( self . filename ) #NEWLINE# root = tree . getroot ( ) #NEWLINE# acq = root . find ( 'acquisitionSystem' ) #NEWLINE# nbits = int ( acq . find ( 'nBits' ) . text ) #NEWLINE# nbchannel = int ( acq . find ( 'nChannels' ) . text ) #NEWLINE# sampling_rate = ( float ( acq . find ( 'samplingRate' ) . text ) * pq . Hz ) #NEWLINE# voltage_range = float ( acq . find ( 'voltageRange' ) . text ) #NEWLINE# amplification = float ( acq . find ( 'amplification' ) . text ) #NEWLINE# bl = Block ( file_origin = os . path . basename ( self . filename ) . replace ( '.xml' , '' ) ) #NEWLINE# if cascade : #NEWLINE# #INDENT# seg = Segment ( ) #NEWLINE# bl . segments . append ( seg ) #NEWLINE# rc_list = [ ] #NEWLINE# for ( i , xml_rcg ) in enumerate ( root . find ( 'anatomicalDescription' ) . find ( 'channelGroups' ) . findall ( 'group' ) ) : #NEWLINE# #INDENT# rcg = RecordingChannelGroup ( name = 'Group {}' . format ( i ) ) #NEWLINE# bl . recordingchannelgroups . append ( rcg ) #NEWLINE# for xml_rc in xml_rcg : #NEWLINE# #INDENT# rc = RecordingChannel ( index = int ( xml_rc . text ) ) #NEWLINE# rc_list . append ( rc ) #NEWLINE# rcg . recordingchannels . append ( rc ) #NEWLINE# rc . recordingchannelgroups . append ( rcg ) #NEWLINE# #UNINDENT# rcg . channel_indexes = np . array ( [ rc . index for rc in rcg . recordingchannels ] , dtype = int ) #NEWLINE# rcg . channel_names = np . array ( [ 'Channel{}' . format ( rc . index ) for rc in rcg . recordingchannels ] , dtype = 'S' ) #NEWLINE# #UNINDENT# reader = RawBinarySignalIO ( filename = self . filename . replace ( '.xml' , '.dat' ) ) #NEWLINE# seg2 = reader . read_segment ( cascade = True , lazy = lazy , sampling_rate = sampling_rate , t_start = ( 0.0 * pq . s ) , unit = pq . V , nbchannel = nbchannel , bytesoffset = 0 , dtype = ( np . int16 if ( nbits <= 16 ) else np . int32 ) , rangemin = ( ( - voltage_range ) / 2.0 ) , rangemax = ( voltage_range / 2.0 ) ) #NEWLINE# for ( s , sig ) in enumerate ( seg2 . analogsignals ) : #NEWLINE# #INDENT# if ( not lazy ) : #NEWLINE# #INDENT# sig /= amplification #NEWLINE# #UNINDENT# sig . segment = seg #NEWLINE# seg . analogsignals . append ( sig ) #NEWLINE# rc_list [ s ] . analogsignals . append ( sig ) #NEWLINE# #UNINDENT# #UNINDENT# bl . create_many_to_one_relationship ( ) #NEWLINE# return bl