Quantcast

File.nameWithoutExtension

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

File.nameWithoutExtension

Straatman, Kees (Dr.)
Dear list and Wayne,

I recently noticed some problems with the function File.nameWithoutExtension()

If I open Fiji or ImageJ and run the macro code:

run("Blobs (25K)");
title=File.nameWithoutExtension();
print(title);

I get as result: "test_"

If I give this macro a name it will give as result the macro name.

I can repeat this multiple times, the result is the same.

If I open manually the blobs sample file, and run line 2 and 3 from the macro I get the same results.  If I open a locally saved file the result is "blobs". If I now run the 3 line macro again the results is "blobs", as expected

However, if I close Fiji, restart and open my images and run line 2 and 3 from the macro I get the macro name as result again.

Can anybody confirm this behaviour?

Best wishes

Kees

University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: File.nameWithoutExtension

ctrueden
Hi Kees,

I see similar behavior. What File.nameWithoutExtension function actually
does is to return the filename of the last file opened by the Open or Save
dialog or by drag and drop [1, 2]. Opening a sample image via Open Samples
does not open an image using one of those mechanisms, and so it does not
"count" for the purposes of File.nameWithoutExtension.

Regards,
Curtis

[1]
https://github.com/imagej/ImageJA/blob/v1.51j/src/main/java/ij/macro/Functions.java#L3892-L3899
[2]
https://github.com/imagej/ImageJA/blob/v1.51j/src/main/java/ij/io/OpenDialog.java#L240-L245

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Tue, Mar 14, 2017 at 9:01 AM, Straatman, Kees (Dr.) <[hidden email]
> wrote:

> Dear list and Wayne,
>
> I recently noticed some problems with the function
> File.nameWithoutExtension()
>
> If I open Fiji or ImageJ and run the macro code:
>
> run("Blobs (25K)");
> title=File.nameWithoutExtension();
> print(title);
>
> I get as result: "test_"
>
> If I give this macro a name it will give as result the macro name.
>
> I can repeat this multiple times, the result is the same.
>
> If I open manually the blobs sample file, and run line 2 and 3 from the
> macro I get the same results.  If I open a locally saved file the result is
> "blobs". If I now run the 3 line macro again the results is "blobs", as
> expected
>
> However, if I close Fiji, restart and open my images and run line 2 and 3
> from the macro I get the macro name as result again.
>
> Can anybody confirm this behaviour?
>
> Best wishes
>
> Kees
>
> University of Leicester
> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: File.nameWithoutExtension

Gabriel Landini
In reply to this post by Straatman, Kees (Dr.)
On Tuesday, 14 March 2017 14:01:05 GMT you wrote:

> Dear list and Wayne,
>
> I recently noticed some problems with the function
> File.nameWithoutExtension()
>
> If I open Fiji or ImageJ and run the macro code:
>
> run("Blobs (25K)");
> title=File.nameWithoutExtension();
> print(title);

Hi Kees,
If I have another opened image, it returns the name of that image, not the one
from "Blobs (25K)!

Maybe issuing to load the blobs image is not registered as the last opened
image?
 
Cheers

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: File.nameWithoutExtension

Michael Entrup
In reply to this post by Straatman, Kees (Dr.)
Hi Kees,

the source code might help to understand what is happening:

```Java
String name = OpenDialog.getLastName();
if (name==null) return "";
int dotIndex = name.lastIndexOf(".");
if (dotIndex>=0 && (name.length()-dotIndex)<=5)
        name = name.substring(0, dotIndex);
return name;
```

It is necessary to use the OpenDialog to get a result from
nameWithoutExtension(). ``run("Blobs (25K)")`` and manually selecting
the sample image from the "File > Open Samples" menu use a different
mechanism to open an image.

Best regards
Michael


On 14.03.2017 15:01, Straatman, Kees (Dr.) wrote:

> Dear list and Wayne,
>
> I recently noticed some problems with the function File.nameWithoutExtension()
>
> If I open Fiji or ImageJ and run the macro code:
>
> run("Blobs (25K)");
> title=File.nameWithoutExtension();
> print(title);
>
> I get as result: "test_"
>
> If I give this macro a name it will give as result the macro name.
>
> I can repeat this multiple times, the result is the same.
>
> If I open manually the blobs sample file, and run line 2 and 3 from the macro I get the same results.  If I open a locally saved file the result is "blobs". If I now run the 3 line macro again the results is "blobs", as expected
>
> However, if I close Fiji, restart and open my images and run line 2 and 3 from the macro I get the macro name as result again.
>
> Can anybody confirm this behaviour?
>
> Best wishes
>
> Kees
>
> University of Leicester
> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: File.nameWithoutExtension

Straatman, Kees (Dr.)
In reply to this post by ctrueden
I see what happens. We opened the images via "Open Recent" as we were testing our macro and this is also not recorded for File.nameWithoutExtension. At least we know where the problem is.

Thanks for the replays.

Kees

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Curtis Rueden [[hidden email]]
Sent: 14 March 2017 14:24
To: [hidden email]
Subject: Re: File.nameWithoutExtension

Hi Kees,

I see similar behavior. What File.nameWithoutExtension function actually
does is to return the filename of the last file opened by the Open or Save
dialog or by drag and drop [1, 2]. Opening a sample image via Open Samples
does not open an image using one of those mechanisms, and so it does not
"count" for the purposes of File.nameWithoutExtension.

Regards,
Curtis

[1]
https://github.com/imagej/ImageJA/blob/v1.51j/src/main/java/ij/macro/Functions.java#L3892-L3899
[2]
https://github.com/imagej/ImageJA/blob/v1.51j/src/main/java/ij/io/OpenDialog.java#L240-L245

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Tue, Mar 14, 2017 at 9:01 AM, Straatman, Kees (Dr.) <[hidden email]
> wrote:

> Dear list and Wayne,
>
> I recently noticed some problems with the function
> File.nameWithoutExtension()
>
> If I open Fiji or ImageJ and run the macro code:
>
> run("Blobs (25K)");
> title=File.nameWithoutExtension();
> print(title);
>
> I get as result: "test_"
>
> If I give this macro a name it will give as result the macro name.
>
> I can repeat this multiple times, the result is the same.
>
> If I open manually the blobs sample file, and run line 2 and 3 from the
> macro I get the same results.  If I open a locally saved file the result is
> "blobs". If I now run the 3 line macro again the results is "blobs", as
> expected
>
> However, if I close Fiji, restart and open my images and run line 2 and 3
> from the macro I get the macro name as result again.
>
> Can anybody confirm this behaviour?
>
> Best wishes
>
> Kees
>
> University of Leicester
> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Loading...