diff --git a/plugins/Multiscale_Coords.ijm b/plugins/Multiscale_Coords.ijm index 6d6bf88..00fffcd 100755 --- a/plugins/Multiscale_Coords.ijm +++ b/plugins/Multiscale_Coords.ijm @@ -30,16 +30,32 @@ the ROI interactively to the desired position, and the movements in um are given as the result. Start and end position values for stitched scans are also available. */ -//Retrieve dimensions of the loaded stack -getDimensions(mywidth, myheight, mychannels, myslices, myframes); +//Check if there is a file containing the multiscale settings +settings_path = getDirectory("home") + "/.multiscale_settings.txt"; -//Set default values -i=1; +if (File.exists(settings_path)){ -if (i==0){ + //Set default parameters specified in the file + parameters_file = File.openAsString(settings_path); + lines=split(parameters_file,"\n"); + + LowResimagePixelSize = lines[3]; + ZZcenterLowRes = lines[5]; + XXcenterLowRes = lines[7]; + YposLowRes = lines[9]; + cameraFOVX = lines[11]; + cameraFOVY = lines[13]; + HighResimagePixelSize = lines[15]; + CameraMoveX = lines[17]; + CameraMoveY = lines[19]; + stageRotation = parseFloat(lines[21]); // TO DO: angular correction // + + overlapXZ = lines[23]; + overlapY = lines[25]; } else { - //No settings file has been found. Set following default values + + //No settings file has been found. Set default values LowResimagePixelSize = 6.5; ZZcenterLowRes = 0; XXcenterLowRes = 0; @@ -53,11 +69,15 @@ if (i==0){ overlapXZ = cameraFOVX*0.3; overlapY = 50; - ScansInX = 1; - ScansInZ = 1; - //SlicesInY is defined later, depending on user inputs } +ScansInX = 1; +ScansInZ = 1; +//SlicesInY is defined later, depending on user inputs + +//Retrieve dimensions of the loaded stack +getDimensions(mywidth, myheight, mychannels, myslices, myframes); + //Flag to restart the plugin repeatFlag = 1; while(repeatFlag == 1) { @@ -253,7 +273,6 @@ while(repeatFlag == 1) { repeatFlag = Dialog.getCheckbox(); txtFlag = Dialog.getCheckbox(); - //Set stageRotation back to degrees after the RepeatFlag stageRotation = stageRotation*360/(2*PI); @@ -279,6 +298,24 @@ while(repeatFlag == 1) { Overlay.remove; } + //Save txt file with the parameters used, so that they are default for next use. + settings_file = File.open(settings_path); + settings_array = "File containing the last settings used in Multiscale_Coords.ijm\n" + + "\nLowResimagePixelSize\n" + LowResimagePixelSize + + "\nZZcenterLowRes\n" + ZZcenterLowRes + + "\nXXcenterLowRes\n" + XXcenterLowRes + + "\nYposLowRes\n" + YposLowRes + + "\ncameraFOVX\n" + cameraFOVX + + "\ncameraFOVY\n" + cameraFOVY + + "\nHighResimagePixelSize\n" + HighResimagePixelSize + + "\nCameraMoveX\n" + CameraMoveX + + "\nCameraMoveY\n" + CameraMoveY + + "\nstageRotation\n" + stageRotation + // TO DO: angular correction // + "\noverlapXZ\n" + overlapXZ + + "\noverlapY\n" + overlapY; + print(settings_file, settings_array); + File.close(settings_file); + } //END ////////////////////////////////////////////////////////////////////////////////