function images = read_mrimages(dir_name, subject, date, time, series, no, slice); % % Binary images are created using the following command: % $ medcon -c "bin" -b16 -n -noprefix -alias -f *. % % Usage example: % > cd /MRI/Experiments % > images = read_mrimage('SUB0001/raw_030622', '*', '*', '*', '00004' , % '*', '*'); % % All fields are strings. Wildcards are allowed in subject, date, time, % series, no, and slice % % (C) Copyright 2003 % Farshad Moradi % California Institute of Technology % images = []; fname = {}; dir_cont = dir([dir_name '/' subject '+1_+' date '+' time '+' series '+' no '+' slice '.bin']); for i=1:length(dir_cont), fname{i} = dir_cont(i).name; end; fname = sort(fname); for i=1:length(fname), fid = fopen( [dir_name '/' fname{i}] ); temp = fread(fid, 'short=>double'); fclose(fid); sz = round(sqrt(length(temp))); images(i).name = fname{i}; if length(temp)==sz*sz, images(i).data = reshape(temp,sz,sz); images(i).w = sz; images(i).h = sz; else, images(i).data = temp; images(i).w = length(temp); images(i).h = 1; end; end;