Login  Register

Re: How to know if a file is supported by imageJ without preloading?

Posted by Bill Mohler on Feb 12, 2010; 5:54pm
URL: http://imagej.273.s1.nabble.com/How-to-know-if-a-file-is-supported-by-imageJ-without-preloading-tp3689405p3689408.html

Great move!

Are these supported in the macro language?


Thanks,
Bill

Curtis Rueden wrote:

> Hi everyone,
>
> As others have pointed out there are methods in both ImageJ and BioFormats
>  
>> to determine whether a file can be read, the problem is that they have to
>> read the files to determine this, and in some cases they can take a long
>> time to return.  I found that big compressed archive files could take tens
>> of seconds to return, which is unusably long if you're only trying to decide
>> what icon to use.
>>
>>    
>
> It is worth mentioning that we have since improved the Bio-Formats file type
> recognition. You can now choose whether to allow Bio-Formats to examine the
> file's contents or not.
>
> If speed is paramount, call with the open flag set to false:
> boolean supported =  r.isThisType(filename, false);
>
> This will decide based solely on filename and possibly directory structure.
>
> If accuracy is more important, call with the default (open=true):
> boolean supported =  r.isThisType(filename);
>
> This will decide based on filename if possible, but examine the file
> contents as needed, which as Simon mentions can take more time (though we
> have made an effort to keep the time requirements as minimal as possible).
>
> -Curtis
>
> On Thu, Feb 11, 2010 at 6:32 AM, Simon Andrews <[hidden email]>wrote:
>
>  
>> On 08/02/2010 14:37, Juanjo Vega wrote:
>>
>>    
>>> Hello everybody,
>>>
>>> I'm developing a new plugin and I need a way to know when a file is
>>> supported by imageJ.
>>>
>>> I'm implementing a browser with a preview and the idea is to know when a
>>> file is supported or not to show one or another icon. The main idea is
>>> to use something like: "isASupportedFileType(): boolean", so new file
>>> types will return "true" when a new plugin will be added.
>>>
>>> Right now I'm filtering items by their extension and that's not cool at
>>> all =P
>>>
>>>      
>> That may not be cool but actually it's the only practical way to do it.  I
>> went through this when I was developing our image browser.  As others have
>> pointed out there are methods in both ImageJ and BioFormats to determine
>> whether a file can be read, the problem is that they have to read the files
>> to determine this, and in some cases they can take a long time to return.  I
>> found that big compressed archive files could take tens of seconds to
>> return, which is unusably long if you're only trying to decide what icon to
>> use.
>>
>> If you wanted to go that way you could set a timer on the call and have an
>> 'unknown' icon if it look too long to determine perhaps?
>>
>> Simon.
>>
>>    
> .
>
>  

--
William A. Mohler
Associate Professor
Dept. of Genetics and Developmental Biology
University of Connecticut Health Center
MC-3301
263 Farmington Ave.
Farmington, CT   06030-3301

[hidden email]
*Mobile: (860) 985-2719*
alt. mobile: (860) 331-8514
skype: wmohler

Office: (860) 679-1833, room E2029
Lab: (860) 679-1834, room E2032
Fax: (314) 689-1833

G&DB dept. ofc.: (860) 679-8350
G&DB dept. fax : (860) 679-8345
http://genetics.uchc.edu/Faculty/Mohler/Mohler.html
P Think before you print