BioImager  5.0.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
BioImager.Microscope Class Reference

Public Types

enum  Actions {
  StageUp , StageRight , StageDown , StageLeft ,
  StageFieldUp , StageFieldRight , StageFieldDown , StageFieldLeft ,
  FocusUp , FocusDown , TL , RL ,
  TakeImage , TakeImageStack , Acquisition , Locate
}
 

Static Public Member Functions

static void Initialize ()
 
static void CalibrateXYZ (int calibMode)
 
static Point3D GetPosition ()
 
static void SetPosition (Point3D p)
 
static void SetPosition (PointD p)
 
static void OpenRL ()
 If the shutter is closed, open it.
 
static void OpenTL ()
 If the shutter is closed, open it.
 
static void CloseRL ()
 If the shutter is open, then close it.
 
static void CloseTL ()
 If the shutter is open, then we close it.
 
static void SetTL (uint tl)
 
static void SetRL (uint tr)
 
static int GetTL ()
 
static int GetRL ()
 
static int GetShutterPosition (string shutter)
 Gets the current position of a named shutter.
 
static void SetShutterPosition (string shutter, int state)
 Sets the current position of a named shutter.
 
static void MoveUp (double d)
 
static void MoveRight (double d)
 
static void MoveDown (double d)
 
static void MoveLeft (double d)
 
static void MoveFieldUp ()
 Move the field up by the height of the view.
 
static void MoveFieldRight ()
 Move the field right by the width of the view.
 
static void MoveFieldDown ()
 Move the field down by one unit.
 
static void MoveFieldLeft ()
 Move the field left by the width of the viewport.
 
static void SetFocus (double d)
 
static double GetFocus ()
 
static string GetFolder ()
 
static void SetFolder (string fol)
 
static BioImage TakeImage ()
 
static BioImage TakeImage (bool save, bool addToImages, bool newTab)
 
static BioImage TakeImageStack ()
 
static void Watcher ()
 the textbox, sets the watcher's path to that folder, and enables the watcher.
 
static BioImage TakeImageStack (double UpperLimit, double LowerLimit, double interval)
 
static BioImage[] TakeTiles (int width, int height, bool save=true, bool addToImages=true, bool newTab=false)
 
static RectangleD GetObjectiveViewRectangle ()
 
static RectangleD GetViewRectangle (bool update)
 
static void Close ()
 

Static Public Attributes

static bool redraw = false
 
static Focus Focus = null
 
static Stage Stage = null
 
static Objectives Objectives = null
 
static TLShutter TLShutter = null
 
static RLShutter RLShutter = null
 
static HXPShutter HXPShutter = null
 
static LightSource TLHalogen = null
 
static LightSource RLHalogen = null
 
static LightSource HXP = null
 
static FilterWheel TLFilterWheel = null
 
static FilterWheel RLFilterWheel = null
 
static FilterWheel FilterWheel = new FilterWheel()
 
static double UpperLimit
 
static double LowerLimit
 
static double fInterVal
 
static object CmdSetMode = null
 
static bool initialized = false
 
static bool ArrowKeysEnabled = true
 
static Point3D defaultPos = new Point3D(30000, 30000, 23900)
 
static object root = null
 
static StringBuilder dllVersion = new StringBuilder()
 
static SDK sdk
 
static int sessionID = -1
 
static string userRx = ""
 
static PointD viewSize
 
static PMicroscope pMicroscope = null
 
static int ImageCount = 0
 

Properties

static Objectives.Objective Objective [get]
 

Detailed Description

Definition at line 786 of file Microscope.cs.

Member Enumeration Documentation

◆ Actions

Enumerator
StageUp 
StageRight 
StageDown 
StageLeft 
StageFieldUp 
StageFieldRight 
StageFieldDown 
StageFieldLeft 
FocusUp 
FocusDown 
TL 
RL 
TakeImage 
TakeImageStack 
Acquisition 
Locate 

Definition at line 789 of file Microscope.cs.

Member Function Documentation

◆ CalibrateXYZ()

static void BioImager.Microscope.CalibrateXYZ ( int calibMode)
static

It checks to see if the stage and focus are calibrated on the lower limit and if not, it calibrates them

Parameters
calibMode"OnLowerLimit"

Definition at line 994 of file Microscope.cs.

995 {
996 if (Properties.Settings.Default.LibPath.Contains("MTB"))
997 {
999 new BioImager.MicroscopeConsole.Command(BioImager.MicroscopeConsole.Command.Type.SetCalibration, new double[] { calibMode }));
1000 //We check to see if focus & stage are correctly calibrated on lower limit and perform calibration if necessary
1001 PointD cur = Stage.GetPosition(true);
1002 double z = Focus.GetFocus();
1003 //After calibration we return to the position before calibration.
1004 SetPosition(cur);
1005 Focus.SetFocus(z);
1006 }
1007 }
AForge.PointD PointD
double GetFocus()
void SetFocus(double f)
static Command RunCommand(Command c)
static void SetPosition(Point3D p)
static Focus Focus
static Stage Stage
PointD GetPosition(bool update)

◆ Close()

static void BioImager.Microscope.Close ( )
static

Definition at line 1596 of file Microscope.cs.

1597 {
1598 PMicroscope.Stop();
1599 }

◆ CloseRL()

static void BioImager.Microscope.CloseRL ( )
static

If the shutter is open, then close it.

Definition at line 1058 of file Microscope.cs.

1059 {
1060 //If shutter is open then we close it.
1061 if (RLShutter.GetPosition() == 0)
1063 }
static RLShutter RLShutter
void SetPosition(int p)

◆ CloseTL()

static void BioImager.Microscope.CloseTL ( )
static

If the shutter is open, then we close it.

Definition at line 1066 of file Microscope.cs.

1067 {
1068 //If shutter is open then we close it.
1069 if (TLShutter.GetPosition() == 0)
1071 }
static TLShutter TLShutter
void SetPosition(int p)

◆ GetFocus()

static double BioImager.Microscope.GetFocus ( )
static

It returns the current focus of the z-axis.

Returns
The focus of the z-axis.

Definition at line 1184 of file Microscope.cs.

1185 {
1186 return Focus.GetFocus();
1187 }

◆ GetFolder()

static string BioImager.Microscope.GetFolder ( )
static

If the folder is not set, prompt the user to select a folder. If the user selects a folder, set the folder to the selected folder. If the user does not select a folder, return null. If the folder is set, return the folder.

Returns
The folder path.

Definition at line 1195 of file Microscope.cs.

1196 {
1197 object o = Recordings.GetProperty(Automation.Action.ValueType.ValuePattern, "GetFolder");
1198 string s = null;
1199 if (o != null)
1200 s = o.ToString();
1201 if (s == null && folder == "")
1202 {
1203 FolderBrowserDialog fs = new FolderBrowserDialog();
1204 fs.Description = "Select Imaging Folder";
1205 if (fs.ShowDialog() != DialogResult.OK)
1206 {
1207 fs.Dispose();
1208 return null;
1209 }
1210 else
1211 {
1212 fs.Dispose();
1213 Properties.Settings.Default.ImagingPath = fs.SelectedPath;
1214 return fs.SelectedPath;
1215 }
1216 }
1217 else
1218 {
1219 folder = Properties.Settings.Default.ImagingPath;
1220 return folder;
1221 }
1222 }

◆ GetObjectiveViewRectangle()

static RectangleD BioImager.Microscope.GetObjectiveViewRectangle ( )
static

It returns a rectangle that represents the viewable area of the current objective

Returns
A rectangle with the dimensions of the viewport.

Definition at line 1563 of file Microscope.cs.

1564 {
1565 Objectives.Objective o = Objectives.GetObjective();
1566 PointD d = Stage.GetPosition(false);
1567 return new RectangleD(d.X, d.Y, o.ViewWidth, o.ViewHeight);
1568 }
AForge.RectangleD RectangleD
static Objectives Objectives
Objective GetObjective()

◆ GetPosition()

static Point3D BioImager.Microscope.GetPosition ( )
static

Get the current stage position and focus position, and return a Point3D object containing the stage position and focus position

Returns
A Point3D object.

Definition at line 1014 of file Microscope.cs.

1015 {
1016 PointD p = Stage.GetPosition(false);
1017 double f = Focus.GetFocus();
1018 return new Point3D(p.X, p.Y, f);
1019 }

◆ GetRL()

static int BioImager.Microscope.GetRL ( )
static

GetRL() returns the position of the RLShutter object.

Returns
The position of the RLShutter.

Definition at line 1100 of file Microscope.cs.

1101 {
1102 return RLShutter.GetPosition();
1103 }

◆ GetShutterPosition()

static int BioImager.Microscope.GetShutterPosition ( string shutter)
static

Gets the current position of a named shutter.

Parameters
shutterName of the shutter.
Returns
Position of the named shutter

Definition at line 1109 of file Microscope.cs.

1110 {
1111 return MicroManager.Shutters.GetPosition(shutter);
1112 }

◆ GetTL()

static int BioImager.Microscope.GetTL ( )
static

It returns the position of the TLShutter object

Returns
The position of the shutter.

Definition at line 1092 of file Microscope.cs.

1093 {
1094 return TLShutter.GetPosition();
1095 }

◆ GetViewRectangle()

static RectangleD BioImager.Microscope.GetViewRectangle ( bool update)
static

If the microscope is in PMicroscope mode, return the PMicroscope rectangle, otherwise return the stage rectangle

Parameters
updateBoolean value that determines whether the view rectangle should be updated or not.
Returns
A rectangle with the dimensions of the viewport.

Definition at line 1576 of file Microscope.cs.

1577 {
1578 if (update)
1579 {
1580 PointD d = Stage.GetPosition(false);
1581 return new RectangleD(d.X, d.Y, viewSize.X, viewSize.Y);
1582 }
1583 else
1584 {
1585 if(Properties.Settings.Default.PMicroscope)
1586 {
1587 return new RectangleD(PMicroscope.location.X, PMicroscope.location.Y, viewSize.X, viewSize.Y);
1588 }
1589 else
1590 {
1591 PointD d = Stage.GetPosition(false);
1592 return new RectangleD(d.X, d.Y, viewSize.X, viewSize.Y);
1593 }
1594 }
1595 }
static PointD viewSize

◆ Initialize()

static void BioImager.Microscope.Initialize ( )
static

The function initializes the microscope and the imaging library

Returns
The return value is an object.

Definition at line 847 of file Microscope.cs.

848 {
849 if (initialized)
850 return;
851 int err;
852 folder = Properties.Settings.Default.ImagingPath;
853 if (Properties.Settings.Default.PMicroscope)
854 {
855 pMicroscope = new PMicroscope();
857 bool b = pMicroscope.SetPosition(new Point3D(100, 100, 100));
858 Point3D p;
859 bool res = pMicroscope.GetPosition3D(out p, false);
860 bool bb = pMicroscope.TakeImage(Application.StartupPath + "\\Image");
861 Objectives = new Objectives(6);
862 Stage = new Stage();
863 Focus = new Focus();
864 }
865 else
866 if (Properties.Settings.Default.PycroManager)
867 {
868 //First we determine which MMConfig file we are using. There is currently no way of doing this programmatically. So we will ask the user.
869 if (Properties.Settings.Default.MMConfig == "")
870 {
871 OpenFileDialog fl = new OpenFileDialog();
872 fl.Filter = "Config Files (*.cfg)|*.cfg";
873 fl.InitialDirectory = Properties.Settings.Default.AppPath;
874 MessageBox.Show("Micro-Manager current configuration file not set please select the current configuration.");
875 fl.Title = "Set Current Config File (Shown in MicroManager GUI)";
876 if (fl.ShowDialog() != DialogResult.OK)
877 Application.Exit();
878 Properties.Settings.Default.MMConfig = fl.FileName;
879 }
880 MicroManager.Initialize(Properties.Settings.Default.MMConfig);
881 Objectives = new Objectives(7);
882 for (int i = 0; i < MicroManager.Objectives.List.Count; i++)
883 {
884 Objectives.List[MicroManager.Objectives.List[i].Index].Name = MicroManager.Objectives.List[i].Name;
885 }
886 Stage = new Stage();
887 Focus = new Focus();
888 }
889 else
890 if (Properties.Settings.Default.AppPath == "")
891 {
892 OpenFileDialog fl = new OpenFileDialog();
893 MessageBox.Show("Imaging application path is not set. Please set executable location.");
894 fl.Title = "Set imaging application location.";
895 if (fl.ShowDialog() != DialogResult.OK)
896 Application.Exit();
897 Properties.Settings.Default.AppPath = fl.FileName;
898 fl.Dispose();
899 }
900 else
901 if (Properties.Settings.Default.LibPath == "")
902 {
903 OpenFileDialog fl = new OpenFileDialog();
904 MessageBox.Show("Imaging library path is not set. Please set imaging library.");
905 fl.Title = "Set imaging library location.";
906 if (fl.ShowDialog() != DialogResult.OK)
907 Application.Exit();
908 Properties.Settings.Default.LibPath = fl.FileName;
909 fl.Dispose();
910 }
911 if (Properties.Settings.Default.LibPath.Contains("MTB"))
912 {
915 Stage = new Stage();
916 Focus = new Focus();
917 Objectives = new Objectives(7);
918 TLShutter = new TLShutter();
919 RLShutter = new RLShutter();
920 HXPShutter = new HXPShutter();
921 TLHalogen = new LightSource();
922 RLHalogen = new LightSource();
923 HXP = new LightSource();
925 PointD.SetLimits(Stage.minX, Stage.maxX, Stage.minY, Stage.maxY);
926 //We calibrate the stage and focus, so that images are taken always with same calibration
927 CalibrateXYZ(0);
928 }
929 else if (Properties.Settings.Default.LibPath.Contains("Prio"))
930 {
931 sdk = new SDK();
932 /* get the version number of the dll */
933 if ((err = sdk.GetVersion(dllVersion)) != Prior.PRIOR_OK)
934 {
935 MessageBox.Show("Error getting Prior SDK version (" + err.ToString() + ")");
936 return;
937 }
938
939 /* SDK must be initialised before any real use
940 */
941 if ((err = sdk.Initialise()) != Prior.PRIOR_OK)
942 {
943 MessageBox.Show("Error initialising Prior SDK (" + err.ToString() + ")");
944 return;
945 }
946
947 /* create a session in the DLL, this gives us one controller and currently an ODS and SL160 robot loader.
948 * Multiple connections allow control of multiple stage/loaders but is outside the brief for this demo
949 */
950 if ((sessionID = sdk.OpenSession()) < 0)
951 {
952 MessageBox.Show("Error (" + sessionID.ToString() + ") Creating session in SDK " + dllVersion);
953 return;
954 }
955 int open = 0;
956 try
957 {
958 for (int port = 0; port < 10; port++)
959 {
960 //specify path name or PriorSDK.log is written to working directory
961 //priorSDK.Cmd(sessionID, "dll.log.on", ref userRx);
962 /* my controller identifies on COM1, yours will probably be different.
963 */
964 /* try to connect to the ps3 */
965 open = sdk.Cmd(sessionID, "controller.connect " + port.ToString(), ref userRx, false);
966 }
967 }
968 catch (Exception)
969 {
970
971 }
972
973 if (open != Prior.PRIOR_OK)
974 {
975 MessageBox.Show("Error (" + open.ToString() + ") connecting to stage controller ", "",
976 MessageBoxButtons.OK, MessageBoxIcon.Error);
977 return;
978 }
979 err = sdk.Cmd(sessionID, "controller.stage.hostdirection.set 1 1", ref userRx);
981 Stage = new Stage();
982 Focus = new Focus();
983 }
984
986 viewSize = new PointD(rec.W, rec.H);
987 Watcher();
988 initialized = true;
989 }
System.Windows.Forms.Application Application
Definition ImageView.cs:14
static double lowerLimit
static double upperLimit
static StringBuilder dllVersion
static LightSource HXP
static PMicroscope pMicroscope
static RectangleD GetObjectiveViewRectangle()
static void CalibrateXYZ(int calibMode)
static string userRx
static FilterWheel RLFilterWheel
static FilterWheel TLFilterWheel
static LightSource TLHalogen
static LightSource RLHalogen
static HXPShutter HXPShutter
static void Watcher()
the textbox, sets the watcher's path to that folder, and enables the watcher.
static bool initialized
static FilterWheel FilterWheel
List< Objective > List
bool TakeImage(string path)
bool GetPosition3D(out Point3D p, bool update)
bool SetPosition(Point3D p)
int Initialise()
Definition SDK.cs:339
int Cmd(int session, string usertx, ref string userrx, bool displayError=true)
Definition SDK.cs:354
int OpenSession()
Definition SDK.cs:344
int GetNosePiecePositions()
Definition SDK.cs:243
int GetVersion(StringBuilder version)
Definition SDK.cs:334
static double maxX
Definition Microscope.cs:24
static double minX
Definition Microscope.cs:23
static double maxY
Definition Microscope.cs:26
static double minY
Definition Microscope.cs:25

◆ MoveDown()

static void BioImager.Microscope.MoveDown ( double d)
static

Move the stage down by the specified amount

Parameters
dThe distance to move the stage down.

Definition at line 1141 of file Microscope.cs.

1142 {
1143 Stage.MoveDown(d);
1144 }
void MoveDown(double m)

◆ MoveFieldDown()

static void BioImager.Microscope.MoveFieldDown ( )
static

Move the field down by one unit.

Definition at line 1164 of file Microscope.cs.

1165 {
1167 }

◆ MoveFieldLeft()

static void BioImager.Microscope.MoveFieldLeft ( )
static

Move the field left by the width of the viewport.

Definition at line 1169 of file Microscope.cs.

1170 {
1172 }
void MoveLeft(double m)

◆ MoveFieldRight()

static void BioImager.Microscope.MoveFieldRight ( )
static

Move the field right by the width of the view.

Definition at line 1159 of file Microscope.cs.

1160 {
1162 }
void MoveRight(double m)

◆ MoveFieldUp()

static void BioImager.Microscope.MoveFieldUp ( )
static

Move the field up by the height of the view.

Definition at line 1154 of file Microscope.cs.

1155 {
1157 }
void MoveUp(double m)

◆ MoveLeft()

static void BioImager.Microscope.MoveLeft ( double d)
static

Move the stage left by the specified distance

Parameters
dThe distance to move the stage in mm.

Definition at line 1149 of file Microscope.cs.

1150 {
1151 Stage.MoveLeft(d);
1152 }

◆ MoveRight()

static void BioImager.Microscope.MoveRight ( double d)
static

MoveRight(double d) moves the stage right by d

Parameters
dThe distance to move the stage in millimeters.

Definition at line 1133 of file Microscope.cs.

1134 {
1135 Stage.MoveRight(d);
1136 }

◆ MoveUp()

static void BioImager.Microscope.MoveUp ( double d)
static

Move the stage up by a distance of d

Parameters
dThe distance to move the stage up.

Definition at line 1125 of file Microscope.cs.

1126 {
1127 Stage.MoveUp(d);
1128 }

◆ OpenRL()

static void BioImager.Microscope.OpenRL ( )
static

If the shutter is closed, open it.

Definition at line 1041 of file Microscope.cs.

1042 {
1043 //If shutter is closed we open it.
1044 if (RLShutter.GetPosition() == 0)
1046 }

◆ OpenTL()

static void BioImager.Microscope.OpenTL ( )
static

If the shutter is closed, open it.

Definition at line 1050 of file Microscope.cs.

1051 {
1052 //If shutter is closed we open it.
1053 if (TLShutter.GetPosition() == 0)
1055 }

◆ SetFocus()

static void BioImager.Microscope.SetFocus ( double d)
static

‍The function SetFocus is a static function that takes a double as a parameter and calls the static function SetFocus on the class Focus with the parameter d

Parameters
dThe double value to set the focus to.

Definition at line 1177 of file Microscope.cs.

1178 {
1179 Focus.SetFocus(d);
1180 }

◆ SetFolder()

static void BioImager.Microscope.SetFolder ( string fol)
static

If the folder doesn't exist, create it. If the property exists, set it. Set the folder variable to the folder. Set the ImagingPath property to the folder. Save the settings

Parameters
folthe folder to save the images to

Definition at line 1227 of file Microscope.cs.

1228 {
1229 if (!Directory.Exists(fol))
1230 Directory.CreateDirectory(fol);
1231 if(Automation.Properties.ContainsKey("SetFolder"))
1232 Automation.SetProperty("SetFolder",fol);
1233 folder = fol;
1234 Properties.Settings.Default.ImagingPath = folder;
1235 Properties.Settings.Default.Save();
1236 }

◆ SetPosition() [1/2]

static void BioImager.Microscope.SetPosition ( Point3D p)
static

It sets the position of the stage and focus to the values in the Point3D object

Parameters
Point3Da class that contains 3 doubles, X, Y, and Z.

Definition at line 1025 of file Microscope.cs.

1026 {
1027 Stage.SetPosition(p.X,p.Y);
1028 Focus.SetFocus(p.Z);
1029 Microscope.redraw = true;
1030 }
void SetPosition(double px, double py)
Definition Microscope.cs:69

◆ SetPosition() [2/2]

static void BioImager.Microscope.SetPosition ( PointD p)
static

SetPosition(PointD p) sets the position of the stage to the PointD p

Parameters
PointDa class that contains an X and Y coordinate

Definition at line 1035 of file Microscope.cs.

1036 {
1037 Stage.SetPosition(p.X, p.Y);
1038 Microscope.redraw = true;
1039 }

◆ SetRL()

static void BioImager.Microscope.SetRL ( uint tr)
static

Set the position of the RLShutter to the value of tr

Parameters
trThe position of the shutter.

Definition at line 1084 of file Microscope.cs.

1085 {
1086 RLShutter.SetPosition((short)tr);
1087 }

◆ SetShutterPosition()

static void BioImager.Microscope.SetShutterPosition ( string shutter,
int state )
static

Sets the current position of a named shutter.

Parameters
shutterName of the shutter.
Returns
Position of the named shutter

Definition at line 1118 of file Microscope.cs.

1119 {
1120 MicroManager.Shutters.SetPosition(shutter, state);
1121 }

◆ SetTL()

static void BioImager.Microscope.SetTL ( uint tl)
static

This function sets the position of the TL shutter to the value of the variable tl

Parameters
tlthe position of the shutter

Definition at line 1076 of file Microscope.cs.

1077 {
1078 TLShutter.SetPosition((short)tl);
1079 }

◆ TakeImage() [1/2]

static BioImage BioImager.Microscope.TakeImage ( )
static

It takes an image from the camera and saves it to a file

Returns
The image is being returned.

Definition at line 1241 of file Microscope.cs.

1242 {
1243 return TakeImage(true,true,false);
1244 }

◆ TakeImage() [2/2]

static BioImage BioImager.Microscope.TakeImage ( bool save,
bool addToImages,
bool newTab )
static

Definition at line 1246 of file Microscope.cs.

1247 {
1248 if (Properties.Settings.Default.SimulateCamera && !Properties.Settings.Default.PMicroscope)
1249 {
1250 folder = GetFolder();
1251 BioImage b = MicroscopeSetup.simImage.Copy();
1252 Point3D p = GetPosition();
1253 b.Volume.Location = new Point3D(p.X,p.Y,p.Z);
1254 RectangleD view = Microscope.GetViewRectangle(true);
1255 b.Resolutions[0] = new Resolution(b.SizeX, b.SizeY, b.Buffers[0].PixelFormat,view.W / b.SizeX, view.H / b.SizeY, b.PhysicalSizeZ,p.X,p.Y,p.Z);
1256 b.Volume.Location = p;
1257 b.Volume.Width = view.W;
1258 b.Volume.Height = view.H;
1259 string file;
1260 if (folder == "" || folder == null)
1261 file = Properties.Settings.Default.ImageName + (ImageCount++) + ".ome.tif";
1262 else
1263 file = folder + "/" + Properties.Settings.Default.ImageName + (ImageCount++) + ".ome.tif";
1264 b.ID = file;
1265 b.file = file;
1266 if (addToImages)
1267 {
1268 Images.AddImage(b);
1269 App.tabsView.AddTab(b);
1270 }
1271 if(save)
1272 BioImage.SaveOME(file, b.ID);
1273 return b;
1274 }
1275 else if (Properties.Settings.Default.PMicroscope)
1276 {
1277 folder = GetFolder();
1278 string file;
1279 if (folder == "" || folder == null)
1280 file = Properties.Settings.Default.ImageName + (ImageCount++).ToString();
1281 else
1282 file = folder + "/" + Properties.Settings.Default.ImageName + (ImageCount++);
1283 pMicroscope.TakeImage(file);
1284 byte[] bts = File.ReadAllBytes(file);
1285 int w, h;
1286 PixelFormat px;
1287 Enum.TryParse<PixelFormat>(Properties.Settings.Default.PCameraFormat, out px);
1288 pMicroscope.GetSize(out w, out h);
1289 Bitmap bf = new Bitmap(file, w, h, px, bts, new ZCT(0, 0, 0), 0);
1290 bf.Stats = Statistics.FromBytes(bf);
1291 BioImage bm = new BioImage(file + ".ome.tif");
1292 bm.Buffers.Add(bf);
1293 //Set the physical size based on objective view
1294 RectangleD rec = GetViewRectangle(false);
1295 Point3D p = Microscope.GetPosition();
1296 Resolution res = new Resolution(w,h,px,rec.W / bm.SizeX,rec.H / bm.SizeY,1, p.X,p.Y,p.Z);
1297 bm.Volume.Location = p;
1298 bm.Volume.Width = rec.W;
1299 bm.Volume.Height = rec.H;
1300 bm.UpdateCoords(1, 1, 1);
1301 bm.Resolutions.Add(res);
1302 for (int c = 0; c < bf.RGBChannelsCount; c++)
1303 {
1304 bm.Channels.Add(new Channel(c, bf.BitsPerPixel, bf.RGBChannelsCount));
1305 }
1306 BioImage.AutoThreshold(bm, false);
1307 if (!imagingStack)
1308 {
1309 if (addToImages)
1310 {
1311 Images.AddImage(bm);
1312 App.tabsView.AddTab(bm);
1313 }
1314 if (save)
1315 BioImage.SaveAsync(file + ".ome.tif", bm.ID,0,true);
1316 if (bm.bitsPerPixel > 8)
1317 bm.StackThreshold(true);
1318 else
1319 bm.StackThreshold(false);
1320 }
1321 else
1322 bi.Buffers.Add(bm.Buffers[0]);
1323 //We delete the temporary file created by camera.
1324 File.Delete(file);
1325 currentImage = bm;
1326 return bi;
1327 }
1328 else if (Properties.Settings.Default.PycroManager)
1329 {
1330 folder = GetFolder();
1331 string file;
1332 if (folder == "" || folder == null)
1333 file = Properties.Settings.Default.ImageName + (ImageCount++).ToString();
1334 else
1335 file = folder + "/" + Properties.Settings.Default.ImageName + (ImageCount++);
1336 BioImage bm = MicroManager.TakeImage(file);
1337
1338 if (!imagingStack)
1339 {
1340 if (addToImages)
1341 {
1342 Images.AddImage(bm);
1343 App.tabsView.AddTab(bm);
1344 }
1345 if (save)
1346 BioImage.SaveAsync(file + ".ome.tif", bm.ID,0,true);
1347 }
1348 else
1349 {
1350 bi.Buffers.AddRange(bm.Buffers);
1351 }
1352 currentImage = bm;
1353 if (bi == null)
1354 return bm;
1355 else
1356 return bi;
1357 }
1358 else
1359 {
1360 if (Function.Functions.ContainsKey("TakeImage"))
1361 {
1362 App.imager.PerformFunction(Function.Functions["TakeImage"]);
1363 return null;
1364 }
1365 else
1366 {
1367 MessageBox.Show("Go to Microscope Setup to set 'TakeImage' function eg. a Button shortcut or GUI recording. Or set camera simulation on & set Camera image.", "Function 'TakeImage' not defined.");
1368 return null;
1369 }
1370 }
1371 }
AForge.Bitmap Bitmap
AForge.PixelFormat PixelFormat
BioLib.BioImage BioImage
Definition TabsView.cs:15
AForge.ZCT ZCT
Definition TabsView.cs:17
static string GetFolder()
static RectangleD GetViewRectangle(bool update)
static Point3D GetPosition()
static int ImageCount
bool GetSize(out int width, out int height)

◆ TakeImageStack() [1/2]

static BioImage BioImager.Microscope.TakeImageStack ( )
static

This function takes a stack of images from the camera and returns a BioImage object

Returns
A BioImage object.

Definition at line 1375 of file Microscope.cs.

1376 {
1378 }
static double LowerLimit
static double UpperLimit
static double fInterVal

◆ TakeImageStack() [2/2]

static BioImage BioImager.Microscope.TakeImageStack ( double UpperLimit,
double LowerLimit,
double interval )
static

It takes an image stack from the microscope and adds it to the viewer.

The function is called from the main thread and it's purpose is to take an image stack from the microscope and add it to the viewer.

Parameters
UpperLimitThe upper limit of the stack
LowerLimitThe lowest focus position
intervalThe interval between each image.
Returns
A BioImage object.

Definition at line 1447 of file Microscope.cs.

1448 {
1449 imagingStack = true;
1450 //We start the locking wait loop
1451 WaitLocking();
1452 bi = new BioImage(Properties.Settings.Default.ImageName);
1453 watcher.Path = GetFolder();
1455 double d = UpperLimit - LowerLimit;
1456 double dd = d / interval;
1457 for (int i = 0; i < dd; i++)
1458 {
1459 TakeImage();
1460 //If this is the last image we don't need to move the focus.
1461 if (i < dd)
1463 Application.DoEvents();
1464 }
1465 //If we are using the imaging application to take images we need to add them to the viewer as the filesystemwatcher
1466 //can't add them due to thread access violation
1467 if (!Properties.Settings.Default.PMicroscope)
1468 {
1469 //First we wait till all the images are loaded
1470 do
1471 {
1472 Thread.Sleep(100);
1473 Application.DoEvents();
1474 } while (bi.Buffers.Count < (int)dd);
1475 }
1476
1477 bi.UpdateCoords(bi.Buffers.Count, 1, 1);
1478 for (int c = 0; c < bi.Buffers[0].RGBChannelsCount; c++)
1479 {
1480 bi.Channels.Add(new Channel(c, bi.bitsPerPixel, bi.Buffers[c].RGBChannelsCount));
1481 }
1482 //Set the physical size based on objective view
1484 /*
1485 bi.StageSizeX = rec.X;
1486 bi.StageSizeY = rec.Y;
1487 bi.StageSizeZ = UpperLimit;
1488 */
1489 bi.Resolutions.Add(new Resolution(bi.SizeX, bi.SizeY, bi.Buffers[0].PixelFormat,
1490 rec.W / bi.SizeX, rec.H / bi.SizeY, (UpperLimit - LowerLimit) / bi.SizeZ, rec.X,rec.Y,UpperLimit));
1491 bi.Volume = new VolumeD(new Point3D(bi.StageSizeX, bi.StageSizeY, bi.StageSizeZ),new Point3D(bi.SizeX * bi.PhysicalSizeX, bi.SizeY * bi.PhysicalSizeY, bi.StageSizeZ * bi.PhysicalSizeZ));
1492 BioImage.AutoThreshold(bi, false);
1493 if (bi.bitsPerPixel > 8)
1494 bi.StackThreshold(true);
1495 else
1496 bi.StackThreshold(false);
1497 Images.AddImage(bi);
1498 App.tabsView.AddTab(bi);
1499 imagingStack = false;
1500 currentImage = bi;
1501 images.Clear();
1502 locked.Clear();
1503 ImageCount = 0;
1504 return bi;
1505 }

◆ TakeTiles()

static BioImage[] BioImager.Microscope.TakeTiles ( int width,
int height,
bool save = true,
bool addToImages = true,
bool newTab = false )
static

It takes a number of images in a grid pattern

Parameters
widthThe number of tiles in the x direction
heightThe number of fields to take in the y direction

Definition at line 1510 of file Microscope.cs.

1511 {
1512 List<BioImage> ims = new List<BioImage>();
1513 imagingStack = false;
1514 bool leftright = false;
1515 if (Properties.Settings.Default.PMicroscope)
1516 {
1517 Point3D p = Microscope.GetPosition();
1518 //We ensure that the cached position is same as actual position
1519 Microscope.SetPosition(p);
1520 }
1521 for (int y = 0; y < height; y++)
1522 {
1523 if (y != 0)
1524 {
1525 Microscope.MoveFieldDown();
1526 }
1527 leftright = !leftright;
1528 ims.Add(Microscope.TakeImage(save, addToImages, newTab));
1529 for (int x = 0; x < width - 1; x++)
1530 {
1531 if (leftright)
1532 {
1533 Microscope.MoveFieldRight();
1534 }
1535 else
1536 {
1537 Microscope.MoveFieldLeft();
1538 }
1539 ims.Add(Microscope.TakeImage(save,addToImages,newTab));
1540 }
1541 }
1542 //If we are using the imaging application to take images we need to add them to the viewer as the filesystemwatcher
1543 //can't add them due to thread access violation
1544 if(!Properties.Settings.Default.PMicroscope)
1545 {
1546 //First we wait till all the images are loaded
1547 do
1548 {
1549 Application.DoEvents();
1550 } while (images.Count < width * height);
1551 for (int i = 0; i < images.Count; i++)
1552 {
1553 App.viewer.AddImage(images[i]);
1554 }
1555 images.Clear();
1556 }
1557 imagingStack = false;
1558 return ims.ToArray();
1559 }

◆ Watcher()

static void BioImager.Microscope.Watcher ( )
static

the textbox, sets the watcher's path to that folder, and enables the watcher.

This function is called when the user clicks the "Start" button. It gets the folder path from

Definition at line 1382 of file Microscope.cs.

1383 {
1384 string s = GetFolder();
1385 watcher.Created += fileSystemWatcher1_Created;
1386 watcher.Path = s;
1387 watcher.BeginInit();
1388 watcher.EnableRaisingEvents = true;
1389 watcher.EndInit();
1390 }

Member Data Documentation

◆ ArrowKeysEnabled

bool BioImager.Microscope.ArrowKeysEnabled = true
static

Definition at line 824 of file Microscope.cs.

◆ CmdSetMode

object BioImager.Microscope.CmdSetMode = null
static

Definition at line 822 of file Microscope.cs.

◆ defaultPos

Point3D BioImager.Microscope.defaultPos = new Point3D(30000, 30000, 23900)
static

Definition at line 825 of file Microscope.cs.

◆ dllVersion

StringBuilder BioImager.Microscope.dllVersion = new StringBuilder()
static

Definition at line 827 of file Microscope.cs.

◆ FilterWheel

FilterWheel BioImager.Microscope.FilterWheel = new FilterWheel()
static

Definition at line 820 of file Microscope.cs.

◆ fInterVal

double BioImager.Microscope.fInterVal
static

Definition at line 821 of file Microscope.cs.

◆ Focus

Focus BioImager.Microscope.Focus = null
static

Definition at line 809 of file Microscope.cs.

◆ HXP

LightSource BioImager.Microscope.HXP = null
static

Definition at line 817 of file Microscope.cs.

◆ HXPShutter

HXPShutter BioImager.Microscope.HXPShutter = null
static

Definition at line 814 of file Microscope.cs.

◆ ImageCount

int BioImager.Microscope.ImageCount = 0
static

Definition at line 834 of file Microscope.cs.

◆ initialized

bool BioImager.Microscope.initialized = false
static

Definition at line 823 of file Microscope.cs.

◆ LowerLimit

double BioImager.Microscope.LowerLimit
static

Definition at line 821 of file Microscope.cs.

◆ Objectives

Objectives BioImager.Microscope.Objectives = null
static

Definition at line 811 of file Microscope.cs.

◆ pMicroscope

PMicroscope BioImager.Microscope.pMicroscope = null
static

Definition at line 832 of file Microscope.cs.

◆ redraw

bool BioImager.Microscope.redraw = false
static

Definition at line 808 of file Microscope.cs.

◆ RLFilterWheel

FilterWheel BioImager.Microscope.RLFilterWheel = null
static

Definition at line 819 of file Microscope.cs.

◆ RLHalogen

LightSource BioImager.Microscope.RLHalogen = null
static

Definition at line 816 of file Microscope.cs.

◆ RLShutter

RLShutter BioImager.Microscope.RLShutter = null
static

Definition at line 813 of file Microscope.cs.

◆ root

object BioImager.Microscope.root = null
static

Definition at line 826 of file Microscope.cs.

◆ sdk

SDK BioImager.Microscope.sdk
static

Definition at line 828 of file Microscope.cs.

◆ sessionID

int BioImager.Microscope.sessionID = -1
static

Definition at line 829 of file Microscope.cs.

◆ Stage

Stage BioImager.Microscope.Stage = null
static

Definition at line 810 of file Microscope.cs.

◆ TLFilterWheel

FilterWheel BioImager.Microscope.TLFilterWheel = null
static

Definition at line 818 of file Microscope.cs.

◆ TLHalogen

LightSource BioImager.Microscope.TLHalogen = null
static

Definition at line 815 of file Microscope.cs.

◆ TLShutter

TLShutter BioImager.Microscope.TLShutter = null
static

Definition at line 812 of file Microscope.cs.

◆ UpperLimit

double BioImager.Microscope.UpperLimit
static

Definition at line 821 of file Microscope.cs.

◆ userRx

string BioImager.Microscope.userRx = ""
static

Definition at line 830 of file Microscope.cs.

◆ viewSize

PointD BioImager.Microscope.viewSize
static

Definition at line 831 of file Microscope.cs.

Property Documentation

◆ Objective

Objectives.Objective BioImager.Microscope.Objective
staticget

Definition at line 836 of file Microscope.cs.

837 {
838 get
839 {
840 return Objectives.GetObjective();
841 }
842 }

The documentation for this class was generated from the following file: