function digital_input_ch = read_Intan_digitalin_file(filename,num_channels)

    fileinfo = dir(filename);
    num_samples = fileinfo.bytes/2; % uint16 = 2 bytes
    fid = fopen(filename, 'r');
    digital_word = fread(fid, num_samples, 'uint16');
    fclose(fid);

    digital_input_ch = (bitand(digital_word, 2.^(0:num_channels-1)) > 0); % ch has a value of 0-15 here
end