diff --git a/BioGTK.csproj b/BioGTK.csproj
index 27c776a..7c9c9d3 100644
--- a/BioGTK.csproj
+++ b/BioGTK.csproj
@@ -21,6 +21,7 @@
2.3.0
AnyCPU;x64;ARM64
True
+ x64
@@ -72,11 +73,13 @@
+
+
PreserveNewest
True
diff --git a/Glade/Console.glade b/Glade/Console.glade
index 74e7b84..deb07df 100644
--- a/Glade/Console.glade
+++ b/Glade/Console.glade
@@ -96,6 +96,7 @@
True
True
False
+ True
True
diff --git a/Glade/Console.glade~ b/Glade/Console.glade~
index 414118a..74e7b84 100644
--- a/Glade/Console.glade~
+++ b/Glade/Console.glade~
@@ -46,6 +46,7 @@
400
- 7
+ 15
@@ -71,7 +72,7 @@
293
- 8
+ 15
diff --git a/Source/App.cs b/Source/App.cs
index 2d54a5f..e755f0f 100644
--- a/Source/App.cs
+++ b/Source/App.cs
@@ -58,17 +58,22 @@ public static void Initialize()
/// @return A boolean value.
public static bool SetImageJPath()
{
- Gtk.FileChooserDialog filechooser =
- new Gtk.FileChooserDialog("Select ImageJ Executable Location",Scripting.window,
- FileChooserAction.Save,
- "Cancel", ResponseType.Cancel,
- "Save", ResponseType.Accept);
+ string title = "Select ImageJ Executable Location";
+ if (OperatingSystem.IsMacOS())
+ title = "Select ImageJ Executable Location (Fiji.app/Contents/MacOS/ImageJ-macosx)";
+ Gtk.FileChooserDialog filechooser =
+ new Gtk.FileChooserDialog(title, Scripting.window,
+ FileChooserAction.Open,
+ "Cancel", ResponseType.Cancel,
+ "Save", ResponseType.Accept);
filechooser.SetCurrentFolder(System.IO.Path.GetDirectoryName(Environment.ProcessPath));
if (filechooser.Run() != (int)ResponseType.Accept)
return false;
ImageJ.ImageJPath = filechooser.Filename;
+ filechooser.Destroy();
Settings.AddSettings("ImageJPath", filechooser.Filename);
Settings.Save();
+
return true;
}
diff --git a/Source/Bio.cs b/Source/Bio.cs
index 154e90e..99226e8 100644
--- a/Source/Bio.cs
+++ b/Source/Bio.cs
@@ -36,7 +36,7 @@ public static BioImage GetImage(string ids)
{
for (int i = 0; i < images.Count; i++)
{
- if (images[i].ID.Contains(ids) || images[i].file == ids)
+ if (images[i].ID == ids || images[i].file == ids)
return images[i];
}
return null;
@@ -80,7 +80,7 @@ public static int GetImageCountByName(string s)
string name = Path.GetFileNameWithoutExtension(s);
for (int im = 0; im < images.Count; im++)
{
- if (images[im].ID.Contains(name))
+ if (images[im].ID == s)
i++;
}
return i;
@@ -148,11 +148,11 @@ public static void RemoveImage(string id)
/// @param id The id of the image to update.
/// @param im The BioImage to update with.
/// @return The image is being returned.
- public static void UpdateImage(string id, BioImage im)
+ public static void UpdateImage(BioImage im)
{
for (int i = 0; i < images.Count; i++)
{
- if (images[i].Filename == id)
+ if (images[i].ID == im.ID)
{
images[i] = im;
return;
@@ -4076,28 +4076,27 @@ private static void InitOME()
public static void SaveFile(string file, string ID)
{
string[] sts = new string[1];
- sts[0] = file;
- SaveSeries(sts, ID);
+ sts[0] = ID;
+ SaveSeries(sts, file);
}
- /// It takes a list of image files, and saves them as a single multi-page TIFF file
+ /// It takes a list of image IDs, and saves them as a single multi-page TIFF file.
///
- /// @param files an array of file paths to the images to be saved
- /// @param ID The path to the file to save to.
- public static void SaveSeries(string[] files, string ID)
+ /// @param An array of IDs of the images to save
+ /// @param The path to the file to save to.
+ public static void SaveSeries(string[] IDs, string file)
{
string desc = "";
int stride = 0;
ImageJDesc j = new ImageJDesc();
- BioImage bi = Images.GetImage(files[0]);
+ BioImage bi = Images.GetImage(IDs[0]);
j.FromImage(bi);
desc = j.GetString();
- for (int fi = 0; fi < files.Length; fi++)
+ for (int fi = 0; fi < IDs.Length; fi++)
{
- string file = files[fi];
-
- BioImage b = Images.GetImage(file);
- string fn = Path.GetFileNameWithoutExtension(ID);
- string dir = Path.GetDirectoryName(ID);
+ string id = IDs[fi];
+ BioImage b = Images.GetImage(id);
+ string fn = Path.GetFileNameWithoutExtension(id);
+ string dir = Path.GetDirectoryName(file);
stride = b.Buffers[0].Stride;
//Save ROIs to CSV file.
@@ -4121,15 +4120,15 @@ public static void SaveSeries(string[] files, string ID)
desc += "-ImageInfo:" + fi + ":" + json + NewLine;
}
- Tiff image = Tiff.Open(ID, "w");
- for (int fi = 0; fi < files.Length; fi++)
+ Tiff image = Tiff.Open(file, "w");
+ for (int fi = 0; fi < IDs.Length; fi++)
{
int im = 0;
- string file = files[fi];
+ string id = IDs[fi];
//Progress pr = new //Progress(file, "Saving");
//pr.Show();
//Application.DoEvents();
- BioImage b = Images.GetImage(file);
+ BioImage b = Images.GetImage(id);
int sizec = 1;
if (!b.isRGB)
{
@@ -4169,7 +4168,7 @@ public static void SaveSeries(string[] files, string ID)
image.SetField(TiffTag.SUBFILETYPE, FileType.PAGE);
// specify the page number
buffer = b.Buffers[im].GetSaveBytes(true);
- image.SetField(TiffTag.PAGENUMBER, im + (b.Buffers.Count * fi), b.Buffers.Count * files.Length);
+ image.SetField(TiffTag.PAGENUMBER, im + (b.Buffers.Count * fi), b.Buffers.Count * IDs.Length);
for (int i = 0, offset = 0; i < b.SizeY; i++)
{
image.WriteScanline(buffer, offset, i, 0);
@@ -4552,6 +4551,7 @@ public static BioImage OpenFile(string file, int series, bool tab, bool addToIma
else
b.StackThreshold(false);
Recorder.AddLine("Bio.BioImage.Open(" + '"' + file + '"' + ");");
+ if(addToImages)
Images.AddImage(b,tab);
//pr.Close();
//pr.Dispose();
@@ -6610,15 +6610,6 @@ public static void OpenAsync(string file)
App.progress.Title = "Opening File";
App.progress.Text = file;
App.progress.Show();
- // start a background task to update progress bar
- System.Threading.Tasks.Task.Run(() =>
- {
- // update progress bar on main UI thread
- Application.Invoke(delegate
- {
- App.progress.ProgressValue = progressValue;
- });
- });
}
/// It opens a file asynchronously
///
diff --git a/Source/BioConsole.cs b/Source/BioConsole.cs
index 2cdccb1..b40861a 100644
--- a/Source/BioConsole.cs
+++ b/Source/BioConsole.cs
@@ -11,7 +11,7 @@ public class BioConsole : Window
/// Used to load in the glade file resource as a window.
private Builder _builder;
public static bool onTab = false;
- public static bool useBioformats = false;
+ public static bool useBioformats = true;
public static bool headless = false;
public static bool resultInNewTab = false;
int line = 0;
@@ -73,6 +73,8 @@ protected void SetupHandlers()
tabRadioBut.Clicked += TabRadioBox_Clicked;
this.KeyPressEvent += Console_KeyPressEvent;
this.DeleteEvent += BioConsole_DeleteEvent;
+ if (OperatingSystem.IsMacOS())
+ bioformatsBox.Active = false;
}
private void ResultsBox_Clicked(object sender, EventArgs e)
@@ -88,13 +90,13 @@ private void BioConsole_DeleteEvent(object o, DeleteEventArgs args)
private void Console_KeyPressEvent(object o, KeyPressEventArgs args)
{
- if (args.Event.Key == Gdk.Key.Up)
+ if (args.Event.Key == Gdk.Key.w)
{
line++;
string[] s = consoleBox.Buffer.Text.Split(Environment.NewLine);
textBox.Buffer.Text = s[s.Length - 1 - line];
}
- if (args.Event.Key == Gdk.Key.Down)
+ if (args.Event.Key == Gdk.Key.s)
{
line--;
string[] s = consoleBox.Buffer.Text.Split(Environment.NewLine);
@@ -119,6 +121,7 @@ private void BioformatsBox_Clicked(object sender, EventArgs e)
else
{
BioImage.OMESupport();
+ bioformatsBox.Active = false;
}
}
diff --git a/Source/ImageJ.cs b/Source/ImageJ.cs
index 730a56b..6f34d88 100644
--- a/Source/ImageJ.cs
+++ b/Source/ImageJ.cs
@@ -56,31 +56,37 @@ public static void RunString(string con, string param, bool headless)
Process pr = new Process();
pr.StartInfo.FileName = ImageJPath;
string te = rng.Next(0, 9999999).ToString();
- string p = Environment.CurrentDirectory + "\\" + te + ".txt";
- p.Replace("/", "\\");
+ string p = Path.GetDirectoryName(Environment.ProcessPath) + "/" + te;
+ if (OperatingSystem.IsMacOS())
+ {
+ Console.WriteLine(p);
+ pr.StartInfo.UseShellExecute = true;
+ }
File.WriteAllText(p, con);
if (headless)
pr.StartInfo.Arguments = "--headless -macro " + p + " " + param;
else
pr.StartInfo.Arguments = "-macro " + p + " " + param;
pr.Start();
- File.Delete(Path.GetDirectoryName(ImageJPath) + "/done.txt");
+ string donedir = Path.GetDirectoryName(Environment.ProcessPath);
+ donedir = donedir.Replace("\\", "/");
+ File.Delete(Path.GetDirectoryName(Environment.ProcessPath) + "/done.txt");
processes.Add(pr);
do
{
- if (File.Exists(Path.GetDirectoryName(ImageJPath) + "/done.txt"))
+ if (File.Exists(donedir + "/done.txt"))
{
do
{
try
{
- File.Delete(Path.GetDirectoryName(ImageJPath) + "/done.txt");
+ File.Delete(donedir + "/done.txt");
}
catch (Exception)
{
}
- } while (File.Exists(Path.GetDirectoryName(ImageJPath) + "/done.txt"));
+ } while (File.Exists(donedir + "/done.txt"));
pr.Kill();
break;
}
@@ -97,8 +103,10 @@ public static void RunString(string con, string param, bool headless)
/// image is opened using the default imagej open command.
///
/// @return The image is being returned as a new tab.
- public static void RunOnImage(string con, bool headless, bool onTab, bool bioformats, bool resultInNewTab)
+ public static void RunOnImage(string con, int index, bool headless, bool onTab, bool bioformats, bool resultInNewTab)
{
+ if (OperatingSystem.IsMacOS())
+ bioformats = false;
if (ImageJPath == "")
{
if (!App.SetImageJPath())
@@ -106,7 +114,7 @@ public static void RunOnImage(string con, bool headless, bool onTab, bool biofor
}
string filename = "";
string dir = Path.GetDirectoryName(ImageView.SelectedImage.file);
-
+ dir = dir.Replace("\\", "/");
if (ImageView.SelectedImage.ID.EndsWith(".ome.tif"))
{
filename = Path.GetFileNameWithoutExtension(ImageView.SelectedImage.ID);
@@ -114,44 +122,72 @@ public static void RunOnImage(string con, bool headless, bool onTab, bool biofor
}
else
filename = Path.GetFileNameWithoutExtension(ImageView.SelectedImage.ID);
- string file = dir + "\\" + filename + "-temp" + ".ome.tif";
- file = file.Replace("\\", "/");
+ string file = dir + "/" + filename + "-temp.ome.tif";
+ if(!bioformats)
+ file = dir + "/" + filename + ".tif";
+ string donepath = Path.GetDirectoryName(Environment.ProcessPath);
+ donepath = donepath.Replace("\\", "/");
string st =
- "run(\"Bio-Formats Importer\", \"open=\" + getArgument + \" autoscale color_mode=Default open_all_series display_rois rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT\"); " + con +
+ "run(\"Bio-Formats Importer\", \"open=" + dir + "/" + ImageView.SelectedImage.ID + " autoscale color_mode=Default open_all_series display_rois rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT\"); " + con +
"run(\"Bio-Formats Exporter\", \"save=" + file + " export compression=Uncompressed\"); " +
- "dir = getDir(\"startup\"); " +
+ "dir = \"" + donepath + "\"" +
"File.saveString(\"done\", dir + \"/done.txt\");";
if (!bioformats)
st =
"open(getArgument); " + con +
"saveAs(\"Tiff\",\"" + file + "\"); " +
- "dir = getDir(\"startup\"); " +
+ "dir = \"" + donepath + "\"" +
"File.saveString(\"done\", dir + \"/done.txt\");";
- //We save the image as a temp image as otherwise imagej won't export due to file access error.
- RunString(st, ImageView.SelectedImage.file, headless);
-
+ if (File.Exists(file) && bioformats)
+ File.Delete(file);
+ RunString(st, dir + "/" + ImageView.SelectedImage.ID, headless);
if (!File.Exists(file))
return;
-
- string ffile = dir + "\\" + filename + ".ome.tif";
- File.Delete(ffile);
- File.Copy(file, ffile);
- File.Delete(file);
//If not in images we add it to a new tab.
- if (Images.GetImage(ffile) == null)
+ string s = filename;
+ if (bioformats)
+ s += "-temp.ome.tif";
+ else
+ s += ".tif";
+ string f = dir + "/" + s;
+ f = f.Replace("\\", "/");
+ string fn = filename + ".tif";
+ if (bioformats)
+ fn = filename + ".ome.tif";
+
+ if (Images.GetImage(fn) == null)
{
- BioImage.OpenFile(ffile, resultInNewTab);
+ BioImage bm = BioImage.OpenFile(f, index, false, false);
+ bm.Filename = fn;
+ bm.ID = fn;
+ bm.file = dir + "/" + fn;
+ Images.AddImage(bm,true);
}
else
{
- //BioImage b = BioImage.OpenFile(ffile, false);
- Images.UpdateImage(ffile,BioImage.OpenFile(ffile));
- Images.GetImage(ffile).Update();
+ BioImage b = BioImage.OpenFile(f, index, onTab, false);
+ b.ID = ImageView.SelectedImage.ID;
+ b.Filename = ImageView.SelectedImage.ID;
+ b.file = dir + "/" + fn;
+ Images.UpdateImage(b);
+ App.viewer.Images[App.viewer.selectedIndex] = b;
}
- App.viewer.UpdateImage();
- App.viewer.UpdateView();
+ //If using bioformats we delete the temp file.
+ if(bioformats)
+ File.Delete(f);
+ // update progress bar on main UI thread
+ Application.Invoke(delegate
+ {
+ App.viewer.UpdateImage();
+ App.viewer.UpdateView();
+ });
+ Recorder.AddLine("ImageJ.RunOnImage(\"" + con + "\"," + headless + "," + onTab + "," + bioformats + "," + resultInNewTab + ");");
+ }
- Recorder.AddLine("ImageJ.RunOnImage(\"" + con + "\"," + headless + "," + onTab + "," + bioformats + ");");
+ public static void RunOnImage(string con, bool headless, bool onTab, bool bioformats, bool resultInNewTab)
+ {
+ RunOnImage(con,0,headless,onTab,bioformats,resultInNewTab);
+ Recorder.AddLine("ImageJ.RunOnImage(\"" + con + "\"," + 0 + "," + headless + "," + onTab + "," + bioformats + "," + resultInNewTab + ");");
}
/// This function is used to initialize the path of the ImageJ.exe file
///
diff --git a/Source/Progress.cs b/Source/Progress.cs
index 955ca0c..065622e 100644
--- a/Source/Progress.cs
+++ b/Source/Progress.cs
@@ -26,7 +26,11 @@ public double ProgressValue
}
set
{
- progressBar.Fraction = value;
+ // update progress bar on main UI thread
+ Application.Invoke(delegate
+ {
+ progressBar.Fraction = value;
+ });
}
}
public string Text
diff --git a/bio.icns b/bio.icns
new file mode 100644
index 0000000..97ee588
Binary files /dev/null and b/bio.icns differ