Esempio n. 1
0
    def __init__(self, fid, channeldata):

        align.check(fid);

        #self.name = ''.join(list(fread(fid, 16, 'c', 'c', 1)));
        fid.seek(16, os.SEEK_CUR);

        fwrite(fid, 1, channeldata.chan_no, 'H', 1);
        fwrite(fid, 1, channeldata.type, 'H', 1);
        fwrite(fid, 1, channeldata.sensor_no, 'h', 1);
        fid.seek(2, os.SEEK_CUR);
        fwrite(fid, 1, channeldata.gain, 'f', 1);
        fwrite(fid, 1, channeldata.units_per_bit, 'f', 1);
        #self.yaxis_label = ''.join(list(fread(fid, 16, 'c', 'c', 1)));
        fid.seek(16, os.SEEK_CUR);
        fwrite(fid, 1, channeldata.aar_val, 'd', 1);
        fwrite(fid, 1, channeldata.checksum, 'i', 1);
        #self.reserved = ''.join(list(fread(fid, 32, 'c', 'c', 1)));
        fid.seek(32, os.SEEK_CUR);
        fid.seek( 4, os.SEEK_CUR);
        fid.seek(77, os.SEEK_CUR);

        if channeldata.type in [1,3]: device_data.writemeg(fid,channeldata.device_data); #meg/ref
        elif channeldata.type in [2]: device_data.writeeeg(fid,channeldata.device_data); #eeg
        elif channeldata.type in [4]: device_data.writeexternal(fid,channeldata.device_data); #external
        elif channeldata.type in [5]: device_data.writetrigger(fid,channeldata.device_data); #TRIGGER
        elif channeldata.type in [6]: device_data.writeutility(fid,channeldata.device_data); #utility
        elif channeldata.type in [7]: device_data.writederived(fid,channeldata.device_data); #derived
        elif channeldata.type in [8]: device_data.writeshorted(fid,channeldata.device_data); #shorted
        else: print 'device type unknown'
Esempio n. 2
0
    def __init__(self, fid, channeldata, log=None):
        #logging.basicConfig(filename='/tmp/MSWconfigwrite.log',filemode='w',level=logging.DEBUG)

        align.check(fid);
        #logging.basicConfig(filename='/tmp/MSWconfigwrite.log',filemode='w',level=logging.DEBUG)
        #self.name = ''.join(list(fread(fid, 16, 'c', 'c', 1)));
        #fid.seek(16, os.SEEK_CUR);
        fwrite(fid, 1, array([channeldata.name]), 'c', 1); #16b
        #fwrite(fid, 1, array([channeldata.name_array]), 'c', 1); #16b
        #print channeldata.name,fid,fid.tell()
        fwrite(fid, 1, channeldata.chan_no, 'H', 1); #4b
        fwrite(fid, 1, channeldata.type, 'H', 1); #4b
        fwrite(fid, 1, channeldata.sensor_no, 'h', 1); #4b
        fid.seek(2, os.SEEK_CUR); #2b
        fwrite(fid, 1, channeldata.gain, 'f', 1); #4b
        fwrite(fid, 1, channeldata.units_per_bit, 'f', 1); #4b
        #self.yaxis_label = ''.join(list(fread(fid, 16, 'c', 'c', 1)));
        #fid.seek(16, os.SEEK_CUR);
        fwrite(fid, 1, array([channeldata.yaxis_label]), 'c', 1); #16
        fwrite(fid, 1, channeldata.aar_val, 'd', 1); #4
        fwrite(fid, 1, channeldata.checksum, 'i', 1); #4
        #self.reserved = ''.join(list(fread(fid, 32, 'c', 'c', 1)));
        #fid.seek(32, os.SEEK_CUR);
        fwrite(fid, 1, array([channeldata.reserved]), 'c', 1); #32
        fid.seek( 4, os.SEEK_CUR); #4b
        logger2.error((channeldata.name_short,str(fid.tell())))
        #fid.seek(77, os.SEEK_CUR);
        if channeldata.type in [1,3]: device_data.writemeg(fid,channeldata.device_data); #meg/ref
        elif channeldata.type in [2]: device_data.writeeeg(fid,channeldata.device_data); #eeg
        elif channeldata.type in [4]: device_data.writeexternal(fid,channeldata.device_data); #external
        elif channeldata.type in [5]: device_data.writetrigger(fid,channeldata.device_data); #TRIGGER
        elif channeldata.type in [6]: device_data.writeutility(fid,channeldata.device_data); #utility
        elif channeldata.type in [7]: device_data.writederived(fid,channeldata.device_data); #derived
        elif channeldata.type in [8]: device_data.writeshorted(fid,channeldata.device_data); #shorted
        else: print 'device type unknown'