BiologyTools / BioFormatsNET6

Bioformats java library converted to .NET6 with IKVM
2 stars 0 forks source link

linux target platform #1

Closed hkvaka closed 1 year ago

hkvaka commented 1 year ago

Hi

I am looking at integrating the nuget package in to my solution .NET 6 running on a Linux target platform

I am getting the following error while installing the package, will this package work for Linux platform

image

BiologyTools commented 1 year ago

I have just uploaded a revised version of the package updated with the latest Bioformats version as well as IKVM. When installing add the BioFormats.NET6 package and add IKVM 8.4.5. https://www.nuget.org/packages/BioFormats.NET6/6.12.0 Thank you for noticing this issue.

hkvaka commented 1 year ago

Thank you for quickly resolving this issue, I can now install both the packages as suggested. could you please point me to any documentation/ code snippet how I can use the library, basically I wanted to generate deep zoom images for z stack whole slide images for .ndpi/svs/mrxs files

BiologyTools commented 1 year ago

The whole slide images I have used with BioGTK are opened by the BioImage.OpenOMETiled function. 'OpenOMETiled (string file, int serie, int tilex, int tiley, int tileSizeX, int tileSizeY)' https://biologytools.github.io/class_bio_g_t_k_1_1_bio_image.html However the images I have do not have Z-depth only multiple pyramidal resolutions. If the images open up correctly in BioGTK you should be able to use the open tile function I mentioned. Let me know what format your images are in?

hkvaka commented 1 year ago

Many Thanks for a quick reply

The image formats I am looking to process are ndpi, svs and mrxs. to start with I am looking to process a large ndpi file

BiologyTools commented 1 year ago

The files I have tested with were czi. But if they open up correctly with BioGTKApp. You should be able to use the "Crop" filter to get stacks from the whole slide image. You can use the Recorder to get code that should work in a script.

hkvaka commented 1 year ago

I've tried to create a new BioImage by passing the file path and getting no Information from the image object, is this the expected way to load an image, could you suggest how to load an image and get metadata image

BiologyTools commented 1 year ago

The documentation needs to be updated I will be doing so today. Here is how to use the library to open part of an image. App.Initialize(); //BioImage.OpenOME(string file, int series, bool openInNewTab, bool addToImages, bool tile, int tilex, int tiley, int tileSizeX, int tileSizeY) //Note the series parameter is the pyramidal resolution for pyramidal images. BioImage bi = BioImage.OpenOME("file", 0, false, true, 0,0,800,800); BioImage.SaveOME("file to save to",bi.ID);

hkvaka commented 1 year ago

Thank you for the code snippet when I try to run the App.Initalize() also tried BioImage..Initalize() getting the below error

image

BiologyTools commented 1 year ago

It's throwing an error when trying to initialize the OME library using IKVM. Add a reference to the bioformats-package.dll which should be included in your project when you installed Bioformats.NET6.

BiologyTools commented 1 year ago

I noticed you are using Visual Studio Code for development I use Visual Studio 2022 Community for Windows. I'm not sure if you can get it to compile with Visual Studio Code.

hkvaka commented 1 year ago

I am using VS 2022 as well and noticed the bioformats-package.dll included in the proj files and marked it as always copy I can see the dll being copied to the output directory but still get the above error image

BiologyTools commented 1 year ago

image Is it showing up correctly in the Dependencies?

hkvaka commented 1 year ago

My dependencies look like this image

BiologyTools commented 1 year ago

Right click on dependencies and click "Add Project Reference..." then browse to the directory of your project and select the "bioformats_package.dll". Then you should have a assemblies reference like mine.

hkvaka commented 1 year ago

Thank you I've referenced it from the bin directory where its copied physically, not sure if thats what was suggested and now get a different error image

BiologyTools commented 1 year ago

Hmm this is a GTK error which platform are you running on? You need to install GTK. https://github.com/GtkSharp/GtkSharp/wiki/Installing-Gtk-on-Windows

hkvaka commented 1 year ago

my host OS is windows 10 target platform is Linux container running on Docker

BiologyTools commented 1 year ago

Did you get it to work? I use windows for building and have tested BioGTK on Windows, Linux & Mac it should work. Let me know if I can help in any way? I have seen a similar message when running on Mac while GTK3 was not installed.

hkvaka commented 1 year ago

Thank you, unfortunately am stuck on that issue as part of the dependencies gtksharp has been already installed image

BiologyTools commented 1 year ago

On Linux GTK3 comes with the operating system. While on Windows you need to install the GTK library as the link I provided instructs. https://github.com/GtkSharp/GtkSharp/wiki/Installing-Gtk-on-Windows I use Glade on windows to make the GUI and glade works with GTK3 which is why I already have GTK3 installed.

BiologyTools commented 1 year ago

Looks like to run BioGTK on windows the package manager MSYS2 must be installed to install the package GTK3 and the path environmental variable must be updated as instructed. Without updating the path environmental variable the app will fail to initialize. https://github.com/GtkSharp/GtkSharp/wiki/Installing-Gtk-on-Windows I will update the readme to include this information so it is more clear.

BiologyTools commented 1 year ago

Did you get BioGTK to work? You could also use "Bio" the WinForms version of the Library it also runs on Linux with Mono.

hkvaka commented 1 year ago

as my target platform is Linux did not install the windows Gtk. apologies, was side tracked with my other work, my main intention is to use the bio formats library in C# rather than using using java, can this library be used as a standalone package without any UI dependencies just as a back end processor,

BiologyTools commented 1 year ago

Yes it can be though it isn't the primary goal of the project, I have used it currently worked on viewing & ROI creation import & export as well as ImageJ integration. BioImage.Initialize() will initialize the Library alone. I am planning on making a headless mode like ImageJ has.

BiologyTools commented 1 year ago

I can make a non-gui version it won't take long should be done by tomorrow. If that's what you truly need.

hkvaka commented 1 year ago

Many thanks for your support, and all the efforts you are putting on the project. It will be really helpful to have a wrapper library around bio-formats using C# that can be used to process z stack whole slide images.

BiologyTools commented 1 year ago

I have uploaded a GUI-less version of the library. https://www.nuget.org/packages/BioLib/1.0.0 hopefully this will be more what you are looking for. Now just call BioImage.Initialize(); to initialize the OME library instead of App.Initialize();

hkvaka commented 1 year ago

Thankyou for quickly separating out the library, looks like its now missing the bioformat_package as I cant see that in the project image

BiologyTools commented 1 year ago

I have updated the package https://www.nuget.org/packages/BioLib/1.2.0 and tested it with your use case here is the code I used.

//The initial opening will take a while for large files due to Bioformats ImageReader setID method.
BioImage slide = BioImage.OpenOME(openFileDialog.FileName, 0, false, true, 0, 0, 800, 800);
//However opeing a tile from an already opened file is fast.
BioImage tile = BioImage.OpenOME(openFileDialog.FileName, 0, true, true, 20000, 20000, 800, 800);
BioImage.SaveOME(openFileDialog.FileName + ".ome.tif", tile.ID);
Images.RemoveImage(tile);
tile.Dispose();

I am sorry it took this long, but this worked for the images I have.

BiologyTools commented 1 year ago

Did you try out the code I provided? It does work with the images I have. I would like to solve this issue.

hkvaka commented 1 year ago

Thankyou for querying on this the original issue with related to missing package is solved ho ever noticing issues opening a file and its taking long time to open the file this case I've only used a file of 100 mb ish, however I might end up with larger files around 15-20GB. image image

hkvaka commented 1 year ago

I've a java version of the bioformats code that picks the file so for time being I might stick with java, appreciate your help on this

BiologyTools commented 1 year ago

Performance wise there is not much I can do, it's caused by running Bioformats with IKVM. Bio uses Bitmiracle Libtiff to make it a bit faster to open non-whole-slide-images & saving stacks. To improve performance of whole slide images I would have to write a reader of my own in C#. If someone could provide me with more whole-slide-images to work with their support would be better. This is why I asked you if your images opened up ok in BioGTKApp.

BiologyTools commented 1 year ago

I have found now a better resource for whole-slide-images which include the formats you are using (ndpi, mrxs, and svs). I will be using these to improve whole-slide support. Thank you for considering my library.

hkvaka commented 1 year ago

Thankyou for all the support provided and also at a very quick pace, my best wishes for your project

BiologyTools commented 1 year ago

I have added support .ndpi whole slide images. The performance for .ndpi is actually much faster than the .czi files I had tried before. I love C# & with Glade the GUI is easy to make. Now people like me who don't know Java have something to work off of. Best wished for you as well.