#pragma rtGlobals=1 // Use modern global access method. // adding Stitch Panel to Macros Menu Menu "Macros" "Do Stitch", DoStitch() end Proc DoStitch() //creating all variables & strings String/G list_edf,list_txt,listHi_edf,listLo_edf,listHi_txt,listLo_txt,BaseName Variable/G SampleLoI1,SampleHiI1 Variable/G gapin=1 Variable/G DetShift=30 Variable/G Gap=17 Variable/G ModuleSize=195 //creating Panel NewPanel /K=1 /W=(3,20,400,200) as "Stitch" Button SelectDataPath, pos={11,6}, size={350,31}, fSize=16, fstyle=1, fColor=(0,0,52224), title="Select Data Path", proc=SelectDataPath SetVariable gapin,pos={11,81}, size={340,18}, title="gap increase in pixels (± n pixels above and below each gap)",noedit=0,value=gapin SetVariable DetShift, pos={11,101}, size={230,18}, title="shift distance in pixels of the images", noedit=0, value=DetShift Button SelectOutputPath, pos={11,41}, size={350,31}, fSize=16, fstyle=1, fColor=(0,0,52224), title="Select Output Path", proc=SelectOutputPath Button Stitch, pos={11,131}, size={350,31}, fSize=16, fstyle=1, fColor=(0,0,52224), title="Stitch", proc=Stitch end Function SelectDataPath(ba) : ButtonControl STRUCT WMButtonAction &ba SVAR list_edf,list_txt,listHi_edf,listLo_edf,listHi_txt,listLo_txt,BaseName, InputPath list_edf = "" list_txt = "" Variable index=0 Make/T/O BaseNameWave switch( ba.eventCode ) case 2: NewPath/O/M="Select data folder where files are contained" folder if (V_Flag!=0) abort endif do String file_edf, file_txt file_edf=indexedfile(folder,index,".edf") // generating a list of .txt files and a list of .edf files in the folder (this I can discard if I use the open operation instead of new path) if (strlen (file_edf) == 0) break endif file_txt=indexedfile(folder,index,".txt") if (strlen (file_txt) == 0) break endif list_edf+=file_edf+";" // add ";" to separate every file name list_txt+=file_txt+";" index+=1 while(1) //separating list by appended Hi_(.file extension) and Lo_(.file extension) for both .edf and .txt files listHi_edf=ListMatch(list_edf,"*hi_1m.edf") listLo_edf=ListMatch(list_edf,"*lo_1m.edf") listHi_txt=ListMatch(list_txt,"*hi_1m.txt") listLo_txt=ListMatch(list_txt,"*lo_1m.txt") BaseName=replacestring("_hi_1m.edf",listHi_edf,"") //list of basename of the files; here I use the list of files with "hi" appended to obtain the base name of the file redimension/N=(ItemsInList(BaseName, ";")) BaseNameWave // convert basename string into a txtwave BaseNameWave = StringFromList(p, BaseName, ";") break endswitch return 0 End Function SelectOutputPath(ba) : ButtonControl STRUCT WMButtonAction &ba SVAR OutputPath switch( ba.eventCode ) case 2: NewPath/O/M="Select data folder to save output files" output if (V_Flag!=0) abort endif break endswitch return 0 End Function Stitch(ba) : ButtonControl STRUCT WMButtonAction &ba NVAR Gap, gapin, Detshift, ModuleSize,SampleLoI1,SampleHiI1 SVAR list_edf,list_txt,listHi_edf,listLo_edf,listHi_txt,listLo_txt,BaseName, InputPath, OutputPath Wave/T BaseNameWave redimension/N=(ItemsInList(BaseName, ";")) BaseNameWave switch( ba.eventCode ) case 2: Variable GapSize= Gap-1+2*gapin String FileHi_edf,FileLo_edf,FileHi_txt,FileLo_txt Variable i,NOF NOF=numpnts(BaseNameWave) For (i=0; i