% Convert 'traces' matrix into input file for QuB % Upon running this program, select the desired *_traces.dat file(s) generated % by Generate_time_traces_TIF_SiMREPS.m % Output will be named *_traces.txt; these files can be loaded into QuB for HMM % analysis close all; clear all; [traces_file, traces_path, fi] = uigetfile('*traces.dat','MultiSelect','on'); cd(traces_path); if iscell(traces_file) == 0 traces_file_mat = traces_file; clear traces_file; traces_file{1} = traces_file_mat; clear traces_file_mat; end for tracesnum = 1:size(traces_file,2) traces_filename = strcat(traces_path,traces_file{tracesnum}); save_file = strcat(traces_filename(1:length(traces_filename)-4),'.txt'); fid = fopen(save_file, 'At'); traces = load(traces_filename,'-mat'); traces = traces.traces; ntraces = size(traces,1); nframes = size(traces,2); qubmat = zeros(0,2); traces = round(traces); for m = 1:ntraces if mod(m,10)==0 disp(num2str(m)); end trace = traces(m,:); % trace = trace - min(trace); % trace = trace./max(trace); for n = 1:nframes fprintf(fid,'%d\t %6.4f\n', n, trace(n)); end fprintf(fid,'\n'); end fclose(fid); end disp('Done writing traces to file.');