function outs = select_experiment(ins, key, op, value)
% select a subexperiment from ins where key==value

% can't figure out how to get find() to act vectorized over
% cell array. Grr.
selecti = [];
keymap = getfield(ins,key);
if (isequal(op,'equal')),
	for i=1:length(keymap),
		if (isequal(keymap(i),cellstr(value))),
			selecti(i) =1;
		end
	end
elseif (isequal(op,'lt')),
	selecti = keymap<value;
end
findi = find(selecti);

outs = struct('type','experiment');

fn = fieldnames(ins);
for i=1:length(fn),
	field = char(fn(i));
	array = getfield(ins,field);
	if (~isequal(field, 'propList') & size(array,1)>1),
		outs = setfield(outs, field, array(findi,:));
	end
end
