Retaining filenames when importing image sequence

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

Retaining filenames when importing image sequence

Stein Rørvik
When importing images from a folder to a stack using Image Sequence, it is useful to have the filenames shown as the image subtitle.
This is especially useful when importing the series at odd increments higher than 1.
When importing as a virtual stack, the filenames are shown as the image subtitle.
But when importing as a regular stack to memory, the image label (if present) is used instead of the filename.

I have a problem with this, as the images I want to import all have the same label;
which is just the name of the third party software that created the images.
It seems that this behaviour started in ImageJ version 1.52d, as it worked fine in 1.52c.

If the behaviour is intended, it would be useful to have the option to turn it off in the Import -> Image Sequence dialog.
There could for example be added a checkbox "Use file names as slice labels" or similar.
This would be complementary to the "Use slice labels as file names" option in Save As -> Image Sequence.
If this checkbox is unchecked, the image label (if present) is then used as subtitle instead, as there are many cases when this is useful.

The macro below replicates the behaviour.

Demo macro:
------------------------------
run("Close All");
outDir = getDirectory("temp") + "MyImageFolder/";
if (!File.isDirectory(outDir)) File.makeDirectory(outDir);
run("Bridge (174K)");
strLabel = "Software: My Proprietary Software";
setMetadata("Info", strLabel);
saveAs("Tiff", outDir + "bridge_001.tif");
saveAs("Tiff", outDir + "bridge_002.tif");
saveAs("Tiff", outDir + "bridge_003.tif");
saveAs("Tiff", outDir + "bridge_004.tif");
saveAs("Tiff", outDir + "bridge_005.tif");
run("Close All");
run("Image Sequence...", "open=&outDir file=bridge sort");
run("Image Sequence...", "open=&outDir file=bridge sort use");
run("Tile");

//1.52c: filename is used as subtitle in both virtual stack and normal stack
//1.52k: label is used as subtitle in normal stack, filename is used in virtual stack
------------------------------


Stein


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

Re: Retaining filenames when importing image sequence

Wayne Rasband-2
> On Feb 5, 2019, at 4:55 PM, Stein Rørvik <[hidden email]> wrote:
>
> When importing images from a folder to a stack using Image Sequence, it is useful to have the filenames shown as the image subtitle.
> This is especially useful when importing the series at odd increments higher than 1.
> When importing as a virtual stack, the filenames are shown as the image subtitle.
> But when importing as a regular stack to memory, the image label (if present) is used instead of the filename.

This 1.52d regression is fixed in the latest image daily build (1.52m7).

-wayne


> I have a problem with this, as the images I want to import all have the same label;
> which is just the name of the third party software that created the images.
> It seems that this behaviour started in ImageJ version 1.52d, as it worked fine in 1.52c.
>
> If the behaviour is intended, it would be useful to have the option to turn it off in the Import -> Image Sequence dialog.
> There could for example be added a checkbox "Use file names as slice labels" or similar.
> This would be complementary to the "Use slice labels as file names" option in Save As -> Image Sequence.
> If this checkbox is unchecked, the image label (if present) is then used as subtitle instead, as there are many cases when this is useful.
>
> The macro below replicates the behaviour.
>
> Demo macro:
> ------------------------------
> run("Close All");
> outDir = getDirectory("temp") + "MyImageFolder/";
> if (!File.isDirectory(outDir)) File.makeDirectory(outDir);
> run("Bridge (174K)");
> strLabel = "Software: My Proprietary Software";
> setMetadata("Info", strLabel);
> saveAs("Tiff", outDir + "bridge_001.tif");
> saveAs("Tiff", outDir + "bridge_002.tif");
> saveAs("Tiff", outDir + "bridge_003.tif");
> saveAs("Tiff", outDir + "bridge_004.tif");
> saveAs("Tiff", outDir + "bridge_005.tif");
> run("Close All");
> run("Image Sequence...", "open=&outDir file=bridge sort");
> run("Image Sequence...", "open=&outDir file=bridge sort use");
> run("Tile");
>
> //1.52c: filename is used as subtitle in both virtual stack and normal stack
> //1.52k: label is used as subtitle in normal stack, filename is used in virtual stack
> ———————————————

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

Re: Retaining filenames when importing image sequence

Stein Rørvik
Thanks, this works as advertised.

However, I found a case where image names are not shown as subtitles:
If the label is something else than "Software: ... " in the example,
then the label is applied as subtitle for the virtual stack.

In the below macro, only the line with strLabel = "... is different from my previous example.
The behaviour is now the same in 1.52c and 1.52m07.

Demo macro:
------------------------------
run("Close All");
outDir = getDirectory("temp") + "MyImageFolder/";
if (!File.isDirectory(outDir)) File.makeDirectory(outDir);
run("Bridge (174K)");
strLabel = "Version: 123a";
setMetadata("Info", strLabel);
saveAs("Tiff", outDir + "bridge_001.tif");
saveAs("Tiff", outDir + "bridge_002.tif");
saveAs("Tiff", outDir + "bridge_003.tif");
saveAs("Tiff", outDir + "bridge_004.tif");
saveAs("Tiff", outDir + "bridge_005.tif");
run("Close All");
run("Image Sequence...", "open=&outDir file=bridge sort");
run("Image Sequence...", "open=&outDir file=bridge sort use");
run("Tile");

//1.52c and 1.52m07:
//filename is used as subtitle in normal stack,
//label is used as subtitle in virtual stack
------------------------------

Stein

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Wayne Rasband
Sent: 6. februar 2019 06:23
To: [hidden email]
Subject: Re: Retaining filenames when importing image sequence

> On Feb 5, 2019, at 4:55 PM, Stein Rørvik <[hidden email]> wrote:
>
> When importing images from a folder to a stack using Image Sequence, it is useful to have the filenames shown as the image subtitle.
> This is especially useful when importing the series at odd increments higher than 1.
> When importing as a virtual stack, the filenames are shown as the image subtitle.
> But when importing as a regular stack to memory, the image label (if present) is used instead of the filename.

This 1.52d regression is fixed in the latest image daily build (1.52m7).

-wayne


> I have a problem with this, as the images I want to import all have
> the same label; which is just the name of the third party software that created the images.
> It seems that this behaviour started in ImageJ version 1.52d, as it worked fine in 1.52c.
>
> If the behaviour is intended, it would be useful to have the option to turn it off in the Import -> Image Sequence dialog.
> There could for example be added a checkbox "Use file names as slice labels" or similar.
> This would be complementary to the "Use slice labels as file names" option in Save As -> Image Sequence.
> If this checkbox is unchecked, the image label (if present) is then used as subtitle instead, as there are many cases when this is useful.
>
> The macro below replicates the behaviour.
>
> Demo macro:
> ------------------------------
> run("Close All");
> outDir = getDirectory("temp") + "MyImageFolder/"; if
> (!File.isDirectory(outDir)) File.makeDirectory(outDir); run("Bridge
> (174K)"); strLabel = "Software: My Proprietary Software";
> setMetadata("Info", strLabel); saveAs("Tiff", outDir +
> "bridge_001.tif"); saveAs("Tiff", outDir + "bridge_002.tif");
> saveAs("Tiff", outDir + "bridge_003.tif"); saveAs("Tiff", outDir +
> "bridge_004.tif"); saveAs("Tiff", outDir + "bridge_005.tif");
> run("Close All"); run("Image Sequence...", "open=&outDir file=bridge
> sort"); run("Image Sequence...", "open=&outDir file=bridge sort use");
> run("Tile");
>
> //1.52c: filename is used as subtitle in both virtual stack and normal
> stack
> //1.52k: label is used as subtitle in normal stack, filename is used
> in virtual stack ———————————————

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

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