Dragging "custom" file type into ImageJ

Hi All

I have a question about handling a custom file type. I wrote a small plugin to load a niche file format for a client. It will only be used internally at their organization. It works fine when called from a separate menu item, but they want to be able to drag these images into Fiji/ImageJ.

I’ve been looking into this, and it seems there is a class called handleextrafiletypes that could be modified to do this. The documentation says

It can be easily modified so that specialised file types can be opened.

So I guess I could modify the class and distribute a custom version (it would only be to a few people). Is this how it was intended to behave at one time?? It looks like HandleExtraFileType is now integrated int IO_

Am I on the right track? Any reccomendations as to the best way to get ImageJ/Fiji to recognize a custom file type??

Thanks for any help people can provide

Brian

1 Like

Oh!

I see the same with HDF5… If you find this out, please report it back here! Unless I find it out first xD

For my use case I got it working by doing the following. First off I had to add the following line to the tryOpen method in HandleExtraFileTypes.java.

if (name.endsWith(".new")) {
	return tryPlugIn("com.reader.ReadThisFile", path);
}

For ImageJ I had to change HandleExtraFileTypes.java, build it and put the .class file in the plugins/Input-Output/ directory.

For Fiji HandleExtraFileTypes is in the IO_ project. So I had to download the IO_ project, change the file, rebuild IO_ and put the new IO_ in the ‘plugins’ directory.

3 Likes

thanks!

[padding to >20 chars] :grin:

1 Like

Just a quick follow-up, which won’t be of much relevance to you @bnorthan since you have found a solution (:+1:): if users have enabled SCIFIO for opening files and you provide a Format, dragging and dropping of that custom file format should work out of the box.

3 Likes

@stelfrich Negative, it does not. I did write a Format yet D&D still does not work :disappointed_relieved:

:scream:. Is SCIFIO activated in the menu (sorry for asking the obvious!)? If that’s the case I guess this is a regression…

2 Likes

Oh… So if you run the imageJ2 instance it’s not active by default? lol… OK I found it :slight_smile: Thanks!

I think it depends on how/what you actually start. For instance, Fiji does not have it enabled by default if I remember correctly.

Does drag and drop work now? *curious*

Works like a charm! Feels so good to open HDF5 by drag&drop :smiley:

1 Like

Dear Radoslaw

I understand this conversation is a bit old, but I am facing some difficulties.

I have the same problem of drag and drop for a custom image file format. I have read these messages and understand I should write a Format, activate SCIFIO in the FIJI preferences and D&D should work automatically.

I am not a Java programmer and I don’t really understand how to do it. Would you have any hints or an example I could clone?

Thank you very much.

Dear @Sidnei_Paciornik,

if you are not familiar with Java, writing a custom SCIFIO Format would be very hard. All the formats are available on github - look for classes that extend Format to find some examples. Look at scifio javadoc do find which classes these are and where to find their code.