// Imports import ij.IJ; import ij.ImagePlus; import ij.ImageStack; import ij.Prefs; import ij.process.FloatProcessor; import ij.gui.GenericDialog; import ij.gui.NonBlockingGenericDialog; import ij.gui.MessageDialog; import org.fairsim.sim_algorithm.SimAlgorithm; import org.fairsim.sim_algorithm.SimParam; import org.fairsim.sim_algorithm.SimParam.FilterStyle; import org.fairsim.sim_algorithm.SimUtils; import org.fairsim.sim_algorithm.OtfProvider; import org.fairsim.fiji.DisplayWrapper; import org.fairsim.utils.ImageDisplay; import org.fairsim.linalg.Vec2d; import org.fairsim.utils.Tool; import loci.plugins.BF; // Check open image only has 9 frames: we want this to be quick! ImagePlus iPl = ij.WindowManager.getCurrentImage(); if (iPl.getStackSize() != 9){ MessageDialog errorDlg = new MessageDialog(null, "Raw data stack size error!", "Please use a single-slice, single-channel image for parameter finding."); return; } // Log fairSIM output in the FIJI log Tool.setLogger( new Tool.Logger() { public void writeTrace(String w) { IJ.log("-fs- "+w); } public void writeError(String e) { IJ.log("fs ERR: "+e); } public void writeShortMessage(String s) { IJ.showStatus(s); } }); // Ask for channel, lens. Timelapse, optosplit. GenericDialog msDlg = new GenericDialog("Enter microscope parameters"); msDlg.addChoice("Channel", new String[]{"488", "561", "640"}, "488"); msDlg.addChoice("Lens", new String[]{"60X Water", "100X Oil"}, "60X Water"); msDlg.addCheckbox("Timelapse mode?", false); msDlg.addCheckbox("Optosplit used?", false); msDlg.addCheckbox("Debug?", false); msDlg.showDialog(); if(msDlg.wasCanceled()) return; String wavelength = msDlg.getNextChoice(); String lens = msDlg.getNextChoice(); boolean timelapse = msDlg.getNextBoolean(); boolean optosplit = msDlg.getNextBoolean(); boolean debug = msDlg.getNextBoolean(); // Find illumination parameters. // fairSIM pattern-finding parameters // SIM reconstruction parameters int nrBands = 2; // #SIM bands int nrAng = 3; // #angles int nrPha = 3; // #phases int fitBand = 1; boolean coarsePeakFit = false; double fitExclude = 0.4; // freq. region (DC) to ignore when search for k0, in fraction of OTF cutoff // Microscope parameters - default for 60X water double otfNA = 1.2; // NA double otfCorr = 0.1; // compensation int imgSize = 512; // width & height of image double pxlSize = 0.0833; // pixel size in micron switch(lens){ case "60X Water": otfNA = 1.2; pxlSize = 0.0833; break; case "100X Oil": oftNA = 1.49; pxlSize = 0.05; break; } double emWavelen; double px1, py1, px2, py2, px3, py3; // Coarse parameters switch(wavelength){ case "488": // 488nm emWavelen = 525; if (timelapse){ px1 = -0.056; py1 = -114.567; px2 = 99.744; py2 = 57.189; px3 = -99.811; py3 = 57.389; } else { px1 = 114.522; py1 = -0.078; px2 = -57.056; py2 = 99.833; px3 = -57.056; py3 = -99.744; } break; case "561": // 561nm emWavelen = 600; if (timelapse){ px1 = -0.056; py1 = -114.567; px2 = 99.744; py2 = 57.189; px3 = -99.811; py3 = 57.389; } else { px1 = 114.522; py1 = -0.078; px2 = -57.056; py2 = 99.833; px3 = -57.056; py3 = -99.744; } break; case "640": // 640nm emWavelen = 700; if (optosplit){ px1 = 114.522; py1 = -0.078; px2 = -57.056; py2 = 99.833; px3 = -57.056; py3 = -99.744; } else if (timelapse){ px1 = 0.033; py1 = -91.589; px2 = 79.811; py2 = 45.722; px3 = -79.789; py3 = 45.922; } else { px1 = 91.5; py1 = -0.100; px2 = -45.7; py2 = 79.856; px3 = -45.878; py3 = -79.678; } break; } OtfProvider otf = OtfProvider.fromEstimate( otfNA, emWavelen, otfCorr ); SimParam simParam = SimParam.create( nrBands, nrAng, nrPha, imgSize, pxlSize, otf ); // copy raw data, window, fft Vec2d.Cplx [][] rawImages = new Vec2d.Cplx[nrAng][nrPha]; for (int a = 0; a