// Register_Coverslip_Nikon macro by Christophe Leterrier // Calculates new positions based on the original and new positions of two reference points // Used for repetitive imaging of neurons // Works with Nikon csv stage positions files: generates a new file from an "original positions" file and a "new positions" file containing only the two new positions of the reference points // Computed transformation is XY rotation + translation, plus a mean Z offset // 18/11/2011 Zeiss version // 20/02/2024 Nikon version macro Register_Coverslip_Nikon { is3D = false; //Gets two Nikon position export files : one with the original positions, another with the new position of reference points (2 points) OriPath=File.openDialog("Original Positions file?"); RefPath=File.openDialog("New Reference Positions file?"); OriDirPath=File.getParent(OriPath); OriFileName=File.getName(OriPath); NewDirPath=File.getParent(RefPath); NewFileName=File.getNameWithoutExtension(OriPath)+"_transfo"; // Gets the file name, and positions set name OriFile=File.openAsString(OriPath); OriLine=split(OriFile, "\n"); print("\n"); print("*** Register Coverslip Nikon Log ***"); print("Original Positions Path: "+OriPath); // Gets the number of positions to initialize the original positions arrays OriLength=OriLine.length; OriPosNumber=OriLength; // Defines the name, X and Y original positions arrays OriPosName=newArray(OriPosNumber); OriX=newArray(OriPosNumber); OriY=newArray(OriPosNumber); if (is3D == true) OriZ=newArray(OriPosNumber); // Loops on all positions to feed the original positions array for (i=0; i