#pragma rtGlobals=3 // Use modern global access method and strict wave access. //It contains to functions, one that allows the user to manually select the traces and the //other automatically discard traces that are to noise at the begigging(written for the detergent project/ //the second function needs implementations to be of general purpose) //traces are manually selected from a 2D matrix Function Select_traces_manually(trace_matrix0) Wave trace_matrix0 Duplicate/O trace_matrix0, trace_matrix Make/o/n=(dimsize(trace_matrix, 0), dimsize(trace_matrix, 1)) trace_sel Variable ii,kk kk = 0 for(ii=0; ii < 4; ii+=1) //dimsize(trace_matrix, 1); ii +=1) display/N=name0 trace_matrix[][ii] ModifyGraph axThick=2 Label bottom "time, s" Label left "intensity a.u." ModifyGraph lsize=0.1 ModifyGraph/W=name0 expand=3 DoUpdate/W=name0 Variable x Prompt x, "do not enter anything" Doprompt "Press continue if you want to keep the trace",x killwindow name0 if(V_flag == 0) trace_sel[][kk] = trace_matrix[p][ii] kk +=1 endif endfor DeletePoints/M=1 (kk),(dimsize(trace_matrix,1)-(kk)), trace_sel killwaves trace_matrix, trace_matrix0 return trace_sel end //traces are selected automatically with an algorithm: //The user define the maximum value of noise and all the traces above that are excluded. The noise is defined as // the fraction between the standard deviation of the pixel average divided by the pixel average of the points enclosed //in an interval defined by the user. Function Select_traces_algorithm1(trace_matrix0) Wave trace_matrix0 Duplicate/O trace_matrix0, trace_matrix Make/o/n=(dimsize(trace_matrix, 0), dimsize(trace_matrix, 1)) trace_sel//, trace_selTest //it is used to test the algorithm Variable ii,kk, aa kk = 0 aa = 0 //the user selecet the interval in which the average is defined and also the required precision/noise Variable x1, x2, y1, Prec Prompt x1, "Insert the initial frame" Prompt x2, "Insert the final frame" Prompt Prec, "Insert the precision of trace selection,i.e. the meximum noise" Doprompt/HELP="Noise or precision is defined as the invers of the Pixel average of the selected interval diveded by its Standart deviation" "Insert the initial and final frame so that their difference contains 20 frames and it is rappresentative of the bleaching intensities before leakage", x1, x2, Prec //Controll statment to verify that the inserted values respect the conditions. if(V_flag==1) abort "You pressed cancel instead of continue, the programme was interrupted" elseif(abs(x2-x1) != 20) Prompt y1, "do not enter anything" Doprompt "The difference between the initial and final frame is not 20 if you want to abort press cancel", y1 if(V_flag==1) abort "You pressed cancel instead of continue, the programme was interrupted" endif endif //selection loop for(ii=0; ii < dimsize(trace_matrix, 1); ii +=1) imagestats/Q /G = { x1, x2, ii, ii } trace_matrix; if(abs(V_adev/V_avg) <= Prec) trace_sel[][kk] = trace_matrix[p][ii] kk +=1 else // it is used to test the algorithm // trace_selTest[][kk] = trace_matrix[p][ii] aa +=1 endif endfor DeletePoints/M=1 (kk),(dimsize(trace_matrix,1)-(kk)), trace_sel killwaves trace_matrix, trace_matrix0 print aa, kk end