 //This script simulates an "EFTEM series" from a STEM datacube
 
//Energy limits for EFTEM series
number E_Start_eV = 1230
number E_End_eV = 1380
number E_Step_eV = 50
number E_Window_eV = 40

//get DataCube 
image  DataCube := getFrontImage()

//ead its dimensions
number width,height,depth
DataCube.get3Dsize(width,height,depth)

//read energy calibration
number dispersion = DataCube.ImageGetDimensionScale(2)
number origin = DataCube.ImageGetDimensionOrigin(2)
result("\ndispersion "+dispersion +" origin "+Origin)


//itterate through energy and integrate within an energy window
for (number E_eV = E_Start_eV; E_eV <= E_End_eV;E_eV += E_Step_eV)
	{
	//convert from eV to channels
	number Start = MSA112_eVtoCh(E_eV-E_Window_eV/2,origin,dispersion)
	number End = MSA112_eVtoCh(E_eV+E_Window_eV/2,origin,dispersion)
result("\n"+E_eV)	

	//select a section from the DataCube
	image CubeSection = DataCube[0,0,Start,width,height,End]
	
	//render along energy axia
	image Eftem = MSA112_Render3DtoFront(CubeSection)
	
	//set name ans display
	Eftem.setName("EFTEM "+E_eV+"eV")
	Eftem.showimage()
	}
