function v = read_Intan_analogin_file(filename,num_channels)

    fileinfo = dir(filename);
    num_samples = fileinfo.bytes/(num_channels * 2); % uint16 = 2 bytes
    fid = fopen(filename, 'r'); 
    v = fread(fid, [num_channels, num_samples], 'uint16'); 
    fclose(fid);
    
    v = v * 3.3/2^16; % convert to volts
end