function [eventout]= EEGSynch_FFT_trialfun_BioSemiMarkerRedefine(eventin)

eventout=eventin;

for r=1:length(eventin)
    if strcmp(eventin(1,r).type,'STATUS')==1
        
        numin=eventin(1,r).value;
        
        numoutbits=de2bi(numin);
        
        numout1bits=numoutbits(1:8);
        numout2bits=numoutbits(9:16);
        
        numout1=bi2de(numout1bits);
        numout2=bi2de(numout2bits);
        
        %double check that numout2 is indeed 255 (this should always be the case)
        
        if numout2~=255
            error('Something went wrong with redefining the Biosemi markers (1 16 bit into 2 8 bit numbers). Second marker is not equal to 255. Please check')
            break
        end
        eventout(1,r).value=numout1;
    end
end