Change in behaviour of getDirectory()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Change in behaviour of getDirectory()

Straub, Volko A. (Dr.)
I noticed a change in behaviour of the getDirectory() macro function between ImageJ v1.52e and ImageJ v1.52f.

Prior to version 1.52e using getDirectory("") to select a directory path returned a string that ended in a \. From version 1.52f onwards it appears to return a string ending in a /.

This change has consequences when using the string to construct file names for opening files with the Bioformats importer as illustrated in the macro below.

The test macro creates a folder in the temp directory and then adds three images to the folder.

Subsequently, the user is asked to select the folder that contains the images, which are then opened in a for-loop (e.g. for processing of all the images contained in that folder).

In version 1.52e, the images are opened and given the correct names. However, in version 1.52f, the images are opened, but their title is changed to include the folder name, i.e. they are now title 'TestFolder/ImageX.tif'.


Any thoughts why this change has occurred and whether it can be reverted as I don't think that a change in image name is desirable.


Best regards,

Volko



path=getDirectory("temp");
path=path+"TestFolder";
File.makeDirectory(path);
for(i=1;i<4;i++){
newImage("Image"+i,"8-bit ramp",400,400,1);
save(path+"\\Image"+i+".tif");
}

path=getDirectory("");
list = getFileList(path);
for (i=0; i<list.length; i++) {
print(path);
print(list[i]);
run("Bio-Formats Importer", "open=["+path+list[i]+"] color_mode=Composite");
print(getTitle());
}


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

Re: Change in behaviour of getDirectory()

Herbie
Good day Volko,

thanks for reporting!

This behavior has already be reported but without the consequences
described by you:
 >http://imagej.1557.x6.nabble.com/DirectoryChooser-and-the-path-separator-td5021165.html>

I guess you are using Windows.

Maybe this is again a case for Wayne...

Regards

Herbie

::::::::::::::::::::::::::::::::::::::::::::::::::::
Am 15.09.18 um 10:05 schrieb Straub, Volko A. (Dr.):

> I noticed a change in behaviour of the getDirectory() macro function between ImageJ v1.52e and ImageJ v1.52f.
>
> Prior to version 1.52e using getDirectory("") to select a directory path returned a string that ended in a \. From version 1.52f onwards it appears to return a string ending in a /.
>
> This change has consequences when using the string to construct file names for opening files with the Bioformats importer as illustrated in the macro below.
>
> The test macro creates a folder in the temp directory and then adds three images to the folder.
>
> Subsequently, the user is asked to select the folder that contains the images, which are then opened in a for-loop (e.g. for processing of all the images contained in that folder).
>
> In version 1.52e, the images are opened and given the correct names. However, in version 1.52f, the images are opened, but their title is changed to include the folder name, i.e. they are now title 'TestFolder/ImageX.tif'.
>
>
> Any thoughts why this change has occurred and whether it can be reverted as I don't think that a change in image name is desirable.
>
>
> Best regards,
>
> Volko
>
>
>
> path=getDirectory("temp");
> path=path+"TestFolder";
> File.makeDirectory(path);
> for(i=1;i<4;i++){
> newImage("Image"+i,"8-bit ramp",400,400,1);
> save(path+"\\Image"+i+".tif");
> }
>
> path=getDirectory("");
> list = getFileList(path);
> for (i=0; i<list.length; i++) {
> print(path);
> print(list[i]);
> run("Bio-Formats Importer", "open=["+path+list[i]+"] color_mode=Composite");
> print(getTitle());
> }
>
>
> --
> 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
|

Re: Change in behaviour of getDirectory()

Wayne Rasband-2
In reply to this post by Straub, Volko A. (Dr.)
> On Sep 15, 2018, at 4:05 AM, Straub, Volko A. (Dr.) <[hidden email]> wrote:
>
> I noticed a change in behaviour of the getDirectory() macro function between ImageJ v1.52e and ImageJ v1.52f.
>
> Prior to version 1.52e using getDirectory("") to select a directory path returned a string that ended in a \. From version 1.52f onwards it appears to return a string ending in a /.

This regression is fixed in the ImageJ 1.52g5 daily build. Upgrade by using the Help>Update ImageJ command and selecting “daily build” from the drop down menu.

-wayne

> This change has consequences when using the string to construct file names for opening files with the Bioformats importer as illustrated in the macro below.
>
> The test macro creates a folder in the temp directory and then adds three images to the folder.
>
> Subsequently, the user is asked to select the folder that contains the images, which are then opened in a for-loop (e.g. for processing of all the images contained in that folder).
>
> In version 1.52e, the images are opened and given the correct names. However, in version 1.52f, the images are opened, but their title is changed to include the folder name, i.e. they are now title 'TestFolder/ImageX.tif'.
>
>
> Any thoughts why this change has occurred and whether it can be reverted as I don't think that a change in image name is desirable.
>
>
> Best regards,
>
> Volko
>
>
>
> path=getDirectory("temp");
> path=path+"TestFolder";
> File.makeDirectory(path);
> for(i=1;i<4;i++){
> newImage("Image"+i,"8-bit ramp",400,400,1);
> save(path+"\\Image"+i+".tif");
> }
>
> path=getDirectory("");
> list = getFileList(path);
> for (i=0; i<list.length; i++) {
> print(path);
> print(list[i]);
> run("Bio-Formats Importer", "open=["+path+list[i]+"] color_mode=Composite");
> print(getTitle());
> }

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

Re: Change in behaviour of getDirectory()

Straub, Volko A. (Dr.)
Thanks Wayne,

Means I don't have to edit my existing macros.

Best regards,

Volko

________________________________
From: Wayne Rasband <[hidden email]>
Sent: 15 September 2018 15:07:16
To: [hidden email]
Subject: Re: Change in behaviour of getDirectory()

> On Sep 15, 2018, at 4:05 AM, Straub, Volko A. (Dr.) <[hidden email]> wrote:
>
> I noticed a change in behaviour of the getDirectory() macro function between ImageJ v1.52e and ImageJ v1.52f.
>
> Prior to version 1.52e using getDirectory("") to select a directory path returned a string that ended in a \. From version 1.52f onwards it appears to return a string ending in a /.

This regression is fixed in the ImageJ 1.52g5 daily build. Upgrade by using the Help>Update ImageJ command and selecting “daily build” from the drop down menu.

-wayne

> This change has consequences when using the string to construct file names for opening files with the Bioformats importer as illustrated in the macro below.
>
> The test macro creates a folder in the temp directory and then adds three images to the folder.
>
> Subsequently, the user is asked to select the folder that contains the images, which are then opened in a for-loop (e.g. for processing of all the images contained in that folder).
>
> In version 1.52e, the images are opened and given the correct names. However, in version 1.52f, the images are opened, but their title is changed to include the folder name, i.e. they are now title 'TestFolder/ImageX.tif'.
>
>
> Any thoughts why this change has occurred and whether it can be reverted as I don't think that a change in image name is desirable.
>
>
> Best regards,
>
> Volko
>
>
>
> path=getDirectory("temp");
> path=path+"TestFolder";
> File.makeDirectory(path);
> for(i=1;i<4;i++){
> newImage("Image"+i,"8-bit ramp",400,400,1);
> save(path+"\\Image"+i+".tif");
> }
>
> path=getDirectory("");
> list = getFileList(path);
> for (i=0; i<list.length; i++) {
> print(path);
> print(list[i]);
> run("Bio-Formats Importer", "open=["+path+list[i]+"] color_mode=Composite");
> print(getTitle());
> }

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

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