tomwalters@614: function [data, nFrames, period, nChannels, nSamples, sample_rate] = ... tomwalters@614: AIMCread(filename, strobes_filename) tomwalters@320: %[data, nFrames, period, nChannels, nSamples ] = AIMCread( filename) tomwalters@320: % tomwalters@320: % data ... matrix (or array) of size [nFrames,nChannels,nSamples] tomwalters@320: % in case vertical/horizontal profiles are read, you should use squeeze tomwalters@320: % nFrames ... number of frames tomwalters@320: % period ... Frame interval in ms tomwalters@614: % nChannels ... points on vertical axis of an auditory image tomwalters@614: % nSamples ... points on horizontal axis of an auditory image tomwalters@320: tomwalters@320: fid = fopen(filename); tomwalters@320: tomwalters@614: strobes_fid = -1; tomwalters@614: if nargin > 1 tomwalters@614: strobes_fid = fopen(strobes_filename); tomwalters@614: strobes_raw = fread(strobes_fid, [], 'int32'); tomwalters@614: end tomwalters@614: tomwalters@320: debug = 0; tomwalters@320: tom@440: nFrames = fread( fid, 1, 'uint32'); tomwalters@320: period = fread( fid, 1, 'float32'); % Frame period in ms tom@440: nChannels = fread( fid, 1, 'uint32'); % vertical axis of an AI tom@440: nSamples = fread( fid, 1, 'uint32'); % horizontal axis of an AI tomwalters@320: sample_rate = fread(fid, 1, 'float32'); % sample rate of each channel in Hz tomwalters@320: tomwalters@320: if nChannels == 1 % temporal profiles tomwalters@320: data = fread( fid, [nSamples,nFrames], 'float32'); % transposed! tomwalters@320: data = data.'; tomwalters@320: data = reshape( data, [nFrames,1,nSamples]); % to have the same dimensions tomwalters@320: % if a 'squeeze' is used, this line has no effect at all tomwalters@320: if debug tomwalters@320: disp('seems to be temporal profiles') tomwalters@320: end tomwalters@320: elseif nSamples == 1 % spectral profiles tomwalters@320: data = fread( fid, [nChannels,nFrames], 'float32'); % transposed! tomwalters@320: data = data.'; tomwalters@320: %data = reshape( data, [nFrames,nChannels,1]); % has no effect tomwalters@320: if debug tomwalters@320: disp('seems to be spectral profiles') tomwalters@320: end tomwalters@320: else % auditory 2d images tomwalters@320: data = zeros(nFrames,nChannels,nSamples); tomwalters@320: for k=1:nFrames % loop since fread cannot return 3d array tomwalters@320: Image = fread(fid, [nSamples,nChannels], 'float32'); % transposed! tomwalters@320: data(k,:,:) = Image.'; tomwalters@320: end tomwalters@320: if debug tomwalters@320: disp('seems to be 2d images') tomwalters@320: end tomwalters@320: end tomwalters@320: tomwalters@320: fclose(fid);